Introduce key suri (path derivation) (#358)

* Introduce key suri (path derivation)

* Errant console.log

* let -> const

* Add seed derivation from path

* Allow new-generation derivation

* Add addFromUri to keyring

* Use addFromUri in testing keyring

* Add suri tests

* Prepare for sr25519 derivation

* CHANGELOG entry

* ed25519 is aligned with substrate

* Bump version
This commit is contained in:
Jaco Greeff
2019-03-13 14:39:10 +01:00
committed by GitHub
parent a1e56cfb81
commit f1ca4eef0e
37 changed files with 564 additions and 120 deletions
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { KeypairType } from '../../types';
import { Keypair } from '../../types';
import schnorrkel from '@polkadot/schnorrkel-js';
@@ -13,7 +13,7 @@ const PUB_LEN = 32;
* @name schnorrkelKeypairFromSeed
* @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
*/
export default function schnorrkelKeypairFromSeed (seed: Uint8Array): KeypairType {
export default function schnorrkelKeypairFromSeed (seed: Uint8Array): Keypair {
const full = schnorrkel.keypair_from_seed(seed);
return {
+2 -2
View File
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { KeypairType } from '../types';
import { Keypair } from '../types';
import { assert } from '@polkadot/util/index';
@@ -12,7 +12,7 @@ import schnorrkel from '@polkadot/schnorrkel-js';
* @name schnorrkelSign
* @description Returns message signature of `message`, using the supplied pair
*/
export default function schnorrkelSign (message: Uint8Array, { publicKey, secretKey }: Partial<KeypairType>): Uint8Array {
export default function schnorrkelSign (message: Uint8Array, { publicKey, secretKey }: Partial<Keypair>): Uint8Array {
assert(publicKey && publicKey.length === 32, 'Expected valid publicKey, 32-bytes');
assert(secretKey && secretKey.length === 64, 'Expected valid secretKey, 64-bytes');