Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0b984f141 | ||
|
|
56e518fc92 | ||
|
|
87a1ca96e3 | ||
|
|
8ef9e206d6 | ||
|
|
1cdda7ca06 | ||
|
|
fa930e9f09 | ||
|
|
f6cc776e87 | ||
|
|
3c4bfeb3e8 | ||
|
|
6e49aaf1db | ||
|
|
852c4c0398 | ||
|
|
9b03461c7e | ||
|
|
4d11a90188 | ||
|
|
b7666e9de9 | ||
|
|
0129752206 | ||
|
|
11fa66441d | ||
|
|
9ed08def61 | ||
|
|
f1ccfad087 | ||
|
|
4f9198f1f3 | ||
|
|
6bd6c8340f | ||
|
|
4355df9e9b | ||
|
|
272fe62031 | ||
|
|
5ab88bcd35 |
@@ -1,5 +1,21 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 7.3.1 Aug 28, 2021
|
||||
|
||||
Contributed:
|
||||
|
||||
- Added Bifrost genesisHash (Thanks to https://github.com/awesomepan)
|
||||
- Added Stafi genesisHash (Thanks to https://github.com/Tore19)
|
||||
- Add Ledger support for Nodle (Thanks to https://github.com/ETeissonniere)
|
||||
|
||||
Changes:
|
||||
|
||||
- Add support for `schnorrkelAgreement` (as exposed by new `wasm-crypto)
|
||||
- Ensure `schnorrkel*` functions allows hex inputs
|
||||
- `@polkadot/wasm-crypto` 4.2.1
|
||||
- Sync with upstream Substrate ss58 registry
|
||||
|
||||
|
||||
## 7.2.1 Aug 15, 2021
|
||||
|
||||
Contributed:
|
||||
|
||||
+4
-4
@@ -24,11 +24,11 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.15.0",
|
||||
"@polkadot/dev": "^0.62.59",
|
||||
"@polkadot/ts": "^0.4.4",
|
||||
"@polkadot/dev": "^0.62.62",
|
||||
"@polkadot/ts": "^0.4.6",
|
||||
"@types/ed2curve": "^0.2.2",
|
||||
"@types/jest": "^26.0.24"
|
||||
"@types/jest": "^27.0.1"
|
||||
},
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"packageManager": "yarn@3.0.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/hw-ledger-transports",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"repository": "github:polkadot-js/common",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger-transports', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger-transports', version: '7.3.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/hw-ledger",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"repository": "github:polkadot-js/common",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
@@ -17,8 +17,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/hw-ledger-transports": "7.2.1",
|
||||
"@polkadot/util": "7.2.1",
|
||||
"@zondax/ledger-substrate": "^0.17.3"
|
||||
"@polkadot/hw-ledger-transports": "7.3.1",
|
||||
"@polkadot/util": "7.3.1",
|
||||
"@zondax/ledger-substrate": "^0.18.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type Transport from '@ledgerhq/hw-transport';
|
||||
import type { SubstrateApp } from '@zondax/ledger-substrate';
|
||||
|
||||
import { newCentrifugeApp, newDockApp, newEdgewareApp, newEquilibriumApp, newKusamaApp, newPolkadotApp, newPolymeshApp, newStatemineApp } from '@zondax/ledger-substrate';
|
||||
import { newCentrifugeApp, newDockApp, newEdgewareApp, newEquilibriumApp, newKusamaApp, newNodleApp, newPolkadotApp, newPolymeshApp, newStatemineApp } from '@zondax/ledger-substrate';
|
||||
|
||||
// These match up with the keys of the knownLedger object in the @polkadot/networks/defaults.ts
|
||||
export const ledgerApps: Record<string, (transport: Transport) => SubstrateApp> = {
|
||||
@@ -13,6 +13,7 @@ export const ledgerApps: Record<string, (transport: Transport) => SubstrateApp>
|
||||
edgeware: newEdgewareApp,
|
||||
equilibrium: newEquilibriumApp,
|
||||
kusama: newKusamaApp,
|
||||
'nodle-chain': newNodleApp,
|
||||
polkadot: newPolkadotApp,
|
||||
polymesh: newPolymeshApp,
|
||||
statemine: newStatemineApp
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/hw-ledger', version: '7.3.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/keyring",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"description": "Keyring management",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
@@ -20,11 +20,11 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/util": "7.2.1",
|
||||
"@polkadot/util-crypto": "7.2.1"
|
||||
"@polkadot/util": "7.3.1",
|
||||
"@polkadot/util-crypto": "7.3.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "7.2.1",
|
||||
"@polkadot/util-crypto": "7.2.1"
|
||||
"@polkadot/util": "7.3.1",
|
||||
"@polkadot/util-crypto": "7.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/keyring', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/keyring', version: '7.3.1' };
|
||||
|
||||
@@ -168,11 +168,11 @@ export function createPair ({ toSS58, type }: Setup, { publicKey, secretKey }: P
|
||||
encodePkcs8: (passphrase?: string): Uint8Array => {
|
||||
return recode(passphrase);
|
||||
},
|
||||
encryptMessage: (message: string | Uint8Array, recipientPublicKey: string | Uint8Array, _nonce?: Uint8Array): Uint8Array => {
|
||||
encryptMessage: (message: string | Uint8Array, recipientPublicKey: string | Uint8Array, nonceIn?: Uint8Array): Uint8Array => {
|
||||
assert(!isLocked(secretKey), 'Cannot encrypt with a locked key pair');
|
||||
assert(!['ecdsa', 'ethereum'].includes(type), 'Secp256k1 not supported yet');
|
||||
|
||||
const { nonce, sealed } = naclSeal(u8aToU8a(message), convertSecretKeyToCurve25519(secretKey), convertPublicKeyToCurve25519(u8aToU8a(recipientPublicKey)), _nonce);
|
||||
const { nonce, sealed } = naclSeal(u8aToU8a(message), convertSecretKeyToCurve25519(secretKey), convertPublicKeyToCurve25519(u8aToU8a(recipientPublicKey)), nonceIn);
|
||||
|
||||
return u8aConcat(nonce, sealed);
|
||||
},
|
||||
@@ -207,8 +207,8 @@ export function createPair ({ toSS58, type }: Setup, { publicKey, secretKey }: P
|
||||
unlock: (passphrase?: string): void => {
|
||||
return decodePkcs8(passphrase);
|
||||
},
|
||||
verify: (message: string | Uint8Array, signature: Uint8Array, _signerPublic: string | Uint8Array): boolean => {
|
||||
return signatureVerify(message, signature, TYPE_ADDRESS[type](u8aToU8a(_signerPublic))).isValid;
|
||||
verify: (message: string | Uint8Array, signature: Uint8Array, signerPublic: string | Uint8Array): boolean => {
|
||||
return signatureVerify(message, signature, TYPE_ADDRESS[type](u8aToU8a(signerPublic))).isValid;
|
||||
},
|
||||
vrfSign: (message: string | Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): Uint8Array => {
|
||||
assert(!isLocked(secretKey), 'Cannot sign with a locked key pair');
|
||||
@@ -221,14 +221,12 @@ export function createPair ({ toSS58, type }: Setup, { publicKey, secretKey }: P
|
||||
|
||||
return u8aConcat(vrfHash(proof, context, extra), proof);
|
||||
},
|
||||
vrfVerify: (message: string | Uint8Array, vrfResult: Uint8Array, _signerPublic: Uint8Array | string, context?: string | Uint8Array, extra?: string | Uint8Array): boolean => {
|
||||
const signerPublic = TYPE_ADDRESS[type](u8aToU8a(_signerPublic));
|
||||
|
||||
vrfVerify: (message: string | Uint8Array, vrfResult: Uint8Array, signerPublic: Uint8Array | string, context?: string | Uint8Array, extra?: string | Uint8Array): boolean => {
|
||||
if (type === 'sr25519') {
|
||||
return schnorrkelVrfVerify(message, vrfResult, publicKey, context, extra);
|
||||
}
|
||||
|
||||
const result = signatureVerify(message, u8aConcat(TYPE_PREFIX[type], vrfResult.subarray(32)), signerPublic);
|
||||
const result = signatureVerify(message, u8aConcat(TYPE_PREFIX[type], vrfResult.subarray(32)), TYPE_ADDRESS[type](u8aToU8a(signerPublic)));
|
||||
|
||||
return result.isValid && u8aEq(vrfResult.subarray(0, 32), vrfHash(vrfResult.subarray(32), context, extra));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/networks",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"description": "A list of all available Substrate networks and their applicable prefixes",
|
||||
"main": "index.js",
|
||||
@@ -19,7 +19,7 @@
|
||||
"@babel/runtime": "^7.15.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "7.2.1",
|
||||
"@polkadot/x-fetch": "7.2.1"
|
||||
"@polkadot/util": "7.3.1",
|
||||
"@polkadot/x-fetch": "7.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import type { KnownGenesis, KnownIcon, KnownLedger, KnownTestnet } from './types
|
||||
// last. This make lookups for the current a simple genesisHash[0]
|
||||
// (See Kusama as an example)
|
||||
export const knownGenesis: KnownGenesis = {
|
||||
bifrost: [
|
||||
'0x9f28c6a68e0fc9646eff64935684f6eeeece527e37bbe1f213d22caa1d9d6bed'
|
||||
],
|
||||
centrifuge: [
|
||||
'0x67dddf2673b69e5f875f6f25277495834398eafd67f492e09f3f3345e003d1b5'
|
||||
],
|
||||
@@ -37,6 +40,9 @@ export const knownGenesis: KnownGenesis = {
|
||||
'0xe3777fa922cafbff200cadeaea1a76bd7898ad5b89f7848999058b50e715f636', // Kusama CC2
|
||||
'0x3fd7b9eb6a00376e5be61f01abb429ffb0b104be05eaff4d458da48fcd425baf' // Kusama CC1
|
||||
],
|
||||
'nodle-chain': [
|
||||
'0xa3d114c2b8d0627c1aa9b134eafcf7d05ca561fdc19fb388bb9457f81809fb23'
|
||||
],
|
||||
plasm: [
|
||||
'0x3e86364d4b4894021cb2a0390bcf2feb5517d5292f2de2bb9404227e908b0b8b'
|
||||
],
|
||||
@@ -46,6 +52,9 @@ export const knownGenesis: KnownGenesis = {
|
||||
polymesh: [
|
||||
'0x9deeb940c92ae02111c3bd5baca89970384f4c9849f02a1b2e53e66414d30f9f'
|
||||
],
|
||||
stafi: [
|
||||
'0x290a4149f09ea0e402c74c1c7e96ae4239588577fe78932f94f5404c68243d80'
|
||||
],
|
||||
statemine: [
|
||||
'0x48239ef607d7928874027a43a67689209727dfb3d3dc5e5b03a39bdc2eda771a'
|
||||
],
|
||||
@@ -73,6 +82,7 @@ export const knownLedger: KnownLedger = {
|
||||
edgeware: 0x0000020b,
|
||||
equilibrium: 0x05f5e0fd,
|
||||
kusama: 0x000001b2,
|
||||
'nodle-chain': 0x000003eb,
|
||||
polkadot: 0x00000162,
|
||||
polymesh: 0x00000253,
|
||||
statemine: 0x000001b2 // common-good on Kusama, shares derivation
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/networks', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/networks', version: '7.3.1' };
|
||||
|
||||
@@ -129,13 +129,13 @@ export const knownSubstrate: KnownSubstrate[] = [
|
||||
website: 'https://polymath.network/'
|
||||
},
|
||||
{
|
||||
decimals: null,
|
||||
displayName: 'SubstraTEE',
|
||||
network: 'substratee',
|
||||
decimals: [12],
|
||||
displayName: 'Integritee',
|
||||
network: 'integritee',
|
||||
prefix: 13,
|
||||
standardAccount: '*25519',
|
||||
symbols: null,
|
||||
website: 'https://www.substratee.com'
|
||||
symbols: ['TEER'],
|
||||
website: 'https://integritee.network'
|
||||
},
|
||||
{
|
||||
decimals: [0],
|
||||
@@ -551,6 +551,15 @@ export const knownSubstrate: KnownSubstrate[] = [
|
||||
symbols: ['HKO'],
|
||||
website: 'https://parallel.fi/'
|
||||
},
|
||||
{
|
||||
decimals: null,
|
||||
displayName: 'Integritee Incognito',
|
||||
network: 'integritee-incognito',
|
||||
prefix: 113,
|
||||
standardAccount: '*25519',
|
||||
symbols: null,
|
||||
website: 'https://integritee.network'
|
||||
},
|
||||
{
|
||||
decimals: [18],
|
||||
displayName: 'Altair',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/util-crypto",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"description": "A collection of useful crypto utilities for @polkadot",
|
||||
"main": "index.js",
|
||||
@@ -22,14 +22,14 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/networks": "7.2.1",
|
||||
"@polkadot/util": "7.2.1",
|
||||
"@polkadot/wasm-crypto": "^4.1.2",
|
||||
"@polkadot/x-randomvalues": "7.2.1",
|
||||
"@polkadot/networks": "7.3.1",
|
||||
"@polkadot/util": "7.3.1",
|
||||
"@polkadot/wasm-crypto": "^4.2.1",
|
||||
"@polkadot/x-randomvalues": "7.3.1",
|
||||
"base-x": "^3.0.8",
|
||||
"base64-js": "^1.5.1",
|
||||
"blakejs": "^1.1.1",
|
||||
"bn.js": "^4.11.9",
|
||||
"bn.js": "^4.12.0",
|
||||
"create-hash": "^1.2.0",
|
||||
"ed2curve": "^0.3.0",
|
||||
"elliptic": "^6.5.4",
|
||||
@@ -47,6 +47,6 @@
|
||||
"@types/xxhashjs": "^0.2.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "7.2.1"
|
||||
"@polkadot/util": "7.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/util-crypto', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/util-crypto', version: '7.3.1' };
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Keypair } from '../types';
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
import { waitReady } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { schnorrkelAgreement, schnorrkelKeypairFromSeed } from '.';
|
||||
|
||||
describe('agreement', (): void => {
|
||||
let pairA: Keypair;
|
||||
let pairB: Keypair;
|
||||
|
||||
beforeEach(async (): Promise<void> => {
|
||||
await waitReady();
|
||||
|
||||
pairA = schnorrkelKeypairFromSeed('0x98b3d305d5a5eace562387e47e59badd4d77e3f72cabfb10a60f8a197059f0a8');
|
||||
pairB = schnorrkelKeypairFromSeed('0x9732eea001851ff862d949a1699c9971f3a26edbede2ad7922cbbe9a0701f366');
|
||||
});
|
||||
|
||||
it('matches a known agreement (both ways)', (): void => {
|
||||
const TEST = '0xb03a0b198c34c16f35cae933d88b16341b4cef3e84e851f20e664c6a30527f4e';
|
||||
|
||||
expect(
|
||||
u8aToHex(schnorrkelAgreement(pairA.secretKey, pairB.publicKey))
|
||||
).toEqual(TEST);
|
||||
expect(
|
||||
u8aToHex(schnorrkelAgreement(pairB.secretKey, pairA.publicKey))
|
||||
).toEqual(TEST);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { assert, u8aToU8a } from '@polkadot/util';
|
||||
import { sr25519Agree } from '@polkadot/wasm-crypto';
|
||||
|
||||
/**
|
||||
* @name schnorrkelAgreement
|
||||
* @description Key agreement between other's public key and self secret key
|
||||
*/
|
||||
export function schnorrkelAgreement (secretKey: Uint8Array | string, publicKey: Uint8Array | string): Uint8Array {
|
||||
const secretKeyU8a = u8aToU8a(secretKey);
|
||||
const publicKeyU8a = u8aToU8a(publicKey);
|
||||
|
||||
assert(publicKeyU8a.length === 32, () => `Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
|
||||
assert(secretKeyU8a.length === 64, () => `Invalid secretKey, received ${secretKeyU8a.length} bytes, expected 64`);
|
||||
|
||||
return sr25519Agree(publicKeyU8a, secretKeyU8a);
|
||||
}
|
||||
@@ -3,13 +3,14 @@
|
||||
|
||||
import type { Keypair } from '../types';
|
||||
|
||||
import { u8aToU8a } from '@polkadot/util';
|
||||
import { sr25519DeriveKeypairHard } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { schnorrkelKeypairFromU8a } from './keypair/fromU8a';
|
||||
import { schnorrkelKeypairToU8a } from './keypair/toU8a';
|
||||
|
||||
export function schnorrkelDeriveHard (keypair: Keypair, chainCode: Uint8Array): Keypair {
|
||||
export function schnorrkelDeriveHard (keypair: Keypair, chainCode: Uint8Array | string): Keypair {
|
||||
return schnorrkelKeypairFromU8a(
|
||||
sr25519DeriveKeypairHard(schnorrkelKeypairToU8a(keypair), chainCode)
|
||||
sr25519DeriveKeypairHard(schnorrkelKeypairToU8a(keypair), u8aToU8a(chainCode))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { assert, u8aToU8a } from '@polkadot/util';
|
||||
import { sr25519DerivePublicSoft } from '@polkadot/wasm-crypto';
|
||||
|
||||
export function schnorrkelDerivePublic (publicKey: Uint8Array, chainCode: Uint8Array): Uint8Array {
|
||||
return sr25519DerivePublicSoft(publicKey, chainCode);
|
||||
export function schnorrkelDerivePublic (publicKey: Uint8Array | string, chainCode: Uint8Array | string): Uint8Array {
|
||||
const publicKeyU8a = u8aToU8a(publicKey);
|
||||
|
||||
assert(publicKeyU8a.length === 32, () => `Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
|
||||
|
||||
return sr25519DerivePublicSoft(publicKeyU8a, u8aToU8a(chainCode));
|
||||
}
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
|
||||
import type { Keypair } from '../types';
|
||||
|
||||
import { u8aToU8a } from '@polkadot/util';
|
||||
import { sr25519DeriveKeypairSoft } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { schnorrkelKeypairFromU8a } from './keypair/fromU8a';
|
||||
import { schnorrkelKeypairToU8a } from './keypair/toU8a';
|
||||
|
||||
export function schnorrkelDeriveSoft (keypair: Keypair, chainCode: Uint8Array): Keypair {
|
||||
export function schnorrkelDeriveSoft (keypair: Keypair, chainCode: Uint8Array | string): Keypair {
|
||||
return schnorrkelKeypairFromU8a(
|
||||
sr25519DeriveKeypairSoft(schnorrkelKeypairToU8a(keypair), chainCode)
|
||||
sr25519DeriveKeypairSoft(schnorrkelKeypairToU8a(keypair), u8aToU8a(chainCode))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/util-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { schnorrkelAgreement } from './agreement';
|
||||
export { schnorrkelDeriveHard } from './deriveHard';
|
||||
export { schnorrkelDerivePublic } from './derivePublic';
|
||||
export { schnorrkelDeriveSoft } from './deriveSoft';
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import { assert, u8aToU8a } from '@polkadot/util';
|
||||
import { sr25519KeypairFromSeed } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { schnorrkelKeypairFromU8a } from './fromU8a';
|
||||
@@ -11,8 +12,12 @@ import { schnorrkelKeypairFromU8a } from './fromU8a';
|
||||
* @name schnorrkelKeypairFromSeed
|
||||
* @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
|
||||
*/
|
||||
export function schnorrkelKeypairFromSeed (seed: Uint8Array): Keypair {
|
||||
export function schnorrkelKeypairFromSeed (seed: Uint8Array | string): Keypair {
|
||||
const seedU8a = u8aToU8a(seed);
|
||||
|
||||
assert(seedU8a.length === 32, () => `Expected a seed matching 32 bytes, found ${seedU8a.length}`);
|
||||
|
||||
return schnorrkelKeypairFromU8a(
|
||||
sr25519KeypairFromSeed(seed)
|
||||
sr25519KeypairFromSeed(seedU8a)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,12 +3,19 @@
|
||||
|
||||
import type { Keypair } from '../../types';
|
||||
|
||||
import { assert, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
const SEC_LEN = 64;
|
||||
const PUB_LEN = 32;
|
||||
const TOT_LEN = SEC_LEN + PUB_LEN;
|
||||
|
||||
export function schnorrkelKeypairFromU8a (full: Uint8Array | string): Keypair {
|
||||
const fullU8a = u8aToU8a(full);
|
||||
|
||||
assert(fullU8a.length === TOT_LEN, () => `Expected keypair with ${TOT_LEN} bytes, found ${fullU8a.length}`);
|
||||
|
||||
export function schnorrkelKeypairFromU8a (full: Uint8Array): Keypair {
|
||||
return {
|
||||
publicKey: full.slice(SEC_LEN, SEC_LEN + PUB_LEN),
|
||||
secretKey: full.slice(0, SEC_LEN)
|
||||
publicKey: fullU8a.slice(SEC_LEN, TOT_LEN),
|
||||
secretKey: fullU8a.slice(0, SEC_LEN)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/util",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"description": "A collection of useful utilities for @polkadot",
|
||||
"main": "index.js",
|
||||
@@ -20,11 +20,11 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/x-textdecoder": "7.2.1",
|
||||
"@polkadot/x-textencoder": "7.2.1",
|
||||
"@polkadot/x-textdecoder": "7.3.1",
|
||||
"@polkadot/x-textencoder": "7.3.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.11.9",
|
||||
"camelcase": "^5.3.1",
|
||||
"bn.js": "^4.12.0",
|
||||
"camelcase": "^6.2.0",
|
||||
"ip-regex": "^4.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/util', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/util', version: '7.3.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-bundle",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"description": "A bundler helper",
|
||||
"main": "index.js",
|
||||
@@ -17,7 +17,7 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-bundle#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/util": "7.2.1",
|
||||
"@polkadot/util": "7.3.1",
|
||||
"buffer-es6": "^4.9.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-bundle', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-bundle', version: '7.3.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-fetch",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"description": "A cross-environment fetch replacement",
|
||||
"browser": "browser.js",
|
||||
@@ -19,7 +19,7 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-fetch#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/x-global": "7.2.1",
|
||||
"@polkadot/x-global": "7.3.1",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"node-fetch": "^2.6.1"
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-fetch', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-fetch', version: '7.3.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-global",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"description": "A cross-environment global replacement",
|
||||
"main": "index.js",
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-global', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-global', version: '7.3.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-randomvalues",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"description": "A cross-environment window.crypto.getRandomValues replacement",
|
||||
"browser": "browser.js",
|
||||
@@ -19,7 +19,7 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-randomvalues#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/x-global": "7.2.1"
|
||||
"@polkadot/x-global": "7.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react-native": "^0.64.13"
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-randomvalues', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-randomvalues', version: '7.3.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-textdecoder",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"description": "A TextDecoder replacement",
|
||||
"browser": "browser.js",
|
||||
@@ -19,6 +19,6 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-textdecoder#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/x-global": "7.2.1"
|
||||
"@polkadot/x-global": "7.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-textdecoder', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-textdecoder', version: '7.3.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-textencoder",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"description": "A TextDecoder replacement",
|
||||
"browser": "browser.js",
|
||||
@@ -19,6 +19,6 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-textencoder#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/x-global": "7.2.1"
|
||||
"@polkadot/x-global": "7.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-textencoder', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-textencoder', version: '7.3.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/x-ws",
|
||||
"version": "7.2.1",
|
||||
"version": "7.3.1",
|
||||
"type": "module",
|
||||
"description": "A cross-environment WebSocket replacement",
|
||||
"browser": "browser.js",
|
||||
@@ -19,7 +19,7 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-ws#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/x-global": "7.2.1",
|
||||
"@polkadot/x-global": "7.3.1",
|
||||
"@types/websocket": "^1.0.4",
|
||||
"websocket": "^1.0.34"
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/x-ws', version: '7.2.1' };
|
||||
export const packageInfo = { name: '@polkadot/x-ws', version: '7.3.1' };
|
||||
|
||||
Reference in New Issue
Block a user