Pre-checks on verify input lengths (#608)

* Pre-checks on verify input lengths

* Small cleanup

* Update error signatures
This commit is contained in:
Jaco Greeff
2020-06-01 10:27:08 +02:00
committed by GitHub
parent cc5b7ed0ad
commit bdb14f91a8
12 changed files with 67 additions and 21 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ export interface ExtractResult {
}
/**
* @description Extract derivation juntions from the supplied path
* @description Extract derivation junctions from the supplied path
*/
export default function keyExtractPath (derivePath: string): ExtractResult {
const parts = derivePath.match(RE_JUNCTION);
+7 -5
View File
@@ -9,12 +9,14 @@ import keyHdkdEd15519 from './hdkdEd25519';
import keyHdkdSr15519 from './hdkdSr25519';
import keyHdkdEcdsa from './hdkdEcdsa';
const generators = {
ecdsa: keyHdkdEcdsa,
ed25519: keyHdkdEd15519,
sr25519: keyHdkdSr15519
};
export default function keyFromPath (pair: Keypair, path: DeriveJunction[], type: KeypairType): Keypair {
const keyHdkd = {
ecdsa: keyHdkdEcdsa,
ed25519: keyHdkdEd15519,
sr25519: keyHdkdSr15519
}[type];
const keyHdkd = generators[type];
return path.reduce((pair, junction): Keypair => {
return keyHdkd(pair, junction);