1 | import { ed25519 } from '@noble/curves/ed25519';
|
2 | import { hasBigInt, u8aConcatStrict } from '@polkadot/util';
|
3 | import { ed25519KeypairFromSeed, isReady } from '@polkadot/wasm-crypto';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export function ed25519PairFromSeed(seed, onlyJs) {
|
19 | if (!hasBigInt || (!onlyJs && isReady())) {
|
20 | const full = ed25519KeypairFromSeed(seed);
|
21 | return {
|
22 | publicKey: full.slice(32),
|
23 | secretKey: full.slice(0, 64)
|
24 | };
|
25 | }
|
26 | const publicKey = ed25519.getPublicKey(seed);
|
27 | return {
|
28 | publicKey,
|
29 | secretKey: u8aConcatStrict([seed, publicKey])
|
30 | };
|
31 | }
|