UNPKG

565 BJavaScriptView Raw
1import { keyHdkdEcdsa } from './hdkdEcdsa.js';
2import { keyHdkdEd25519 } from './hdkdEd25519.js';
3import { keyHdkdSr25519 } from './hdkdSr25519.js';
4const generators = {
5 ecdsa: keyHdkdEcdsa,
6 ed25519: keyHdkdEd25519,
7 // FIXME This is Substrate-compatible, not Ethereum-compatible
8 ethereum: keyHdkdEcdsa,
9 sr25519: keyHdkdSr25519
10};
11export function keyFromPath(pair, path, type) {
12 const keyHdkd = generators[type];
13 let result = pair;
14 for (const junction of path) {
15 result = keyHdkd(result, junction);
16 }
17 return result;
18}