Schnorrkel support (#297)
* Initial schnorrkel support * Start conversion of actual keyring * Wrap encoding/decoding (needs another check) * Manage encoding version & types with passthrough * Update to version with working sign * Cleanup pair interface (with seed) * Fix failing tests * Align naclSign signature * Update tests for nacl (with TS conversion) * Bump version with CHANGELOG * Remove unneeded dep * Use KeyringOptions instead of PairType * Do isNumber check on addressPrefix
This commit is contained in:
@@ -2,17 +2,19 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { stringToU8a, u8aConcat, u8aFixLength } from '@polkadot/util/index';
|
||||
import { stringToU8a, u8aConcat, u8aFixLength, assert } from '@polkadot/util/index';
|
||||
import { naclEncrypt } from '@polkadot/util-crypto/index';
|
||||
|
||||
import { PKCS8_DIVIDER, PKCS8_HEADER } from './defaults';
|
||||
|
||||
export default function encode (secretKey: Uint8Array, passphrase?: string): Uint8Array {
|
||||
export default function encode (publicKey: Uint8Array, seed?: Uint8Array | null, passphrase?: string): Uint8Array {
|
||||
assert(seed, 'Expected a valid seed to be passed to encode');
|
||||
|
||||
const encoded = u8aConcat(
|
||||
PKCS8_HEADER,
|
||||
secretKey.subarray(0, 32),
|
||||
seed as Uint8Array,
|
||||
PKCS8_DIVIDER,
|
||||
secretKey.subarray(32, 64)
|
||||
publicKey
|
||||
);
|
||||
|
||||
if (!passphrase) {
|
||||
|
||||
Reference in New Issue
Block a user