diff --git a/CHANGELOG.md b/CHANGELOG.md index 8173a8e1a..6a9711adf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # CHANGELOG +## 5.8.1 Feb 26, 2021 + +Contributed: + +- Add ss58 information for HydraDX (Thanks to https://github.com/jak-pan) +- HD derivation for Ethereum (Thanks to https://github.com/joelamouche) + +Changes: + +- Adjust base64 encoding/decoding to not rely on Buffer being available +- Rework Ethereum derivation to only use Uint8Array internally +- Shared HD path validation for Ledger & Ethereum +- Additional derivation, encoding and decoding tests on keyring +- Align networks with upstream ss58 registry +- `@polkadot/wasm-crypto` 3.2.4 + + ## 5.7.1 Feb 21, 2021 **Breaking change** The signature of `pair.verify` now requires the signer public key as a parameter. If using `pair.verify` pass the publicKey (hex or Uint8Array) of the signer. diff --git a/package.json b/package.json index 303153013..1b78d0556 100644 --- a/package.json +++ b/package.json @@ -21,9 +21,9 @@ }, "devDependencies": { "@babel/core": "^7.13.1", - "@polkadot/dev": "^0.61.27", + "@polkadot/dev": "^0.61.28", "@polkadot/ts": "^0.3.59", "@types/jest": "^26.0.20" }, - "version": "5.7.2-8" + "version": "5.8.0" } diff --git a/packages/hw-ledger-transports/package.json b/packages/hw-ledger-transports/package.json index a696606a1..156752f00 100644 --- a/packages/hw-ledger-transports/package.json +++ b/packages/hw-ledger-transports/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/hw-ledger-transports", - "version": "5.7.2-8", + "version": "5.8.0", "repository": "github:polkadot-js/common", "author": "Jaco Greeff ", "maintainers": [], diff --git a/packages/hw-ledger/package.json b/packages/hw-ledger/package.json index 7d6155e86..6dfc12823 100644 --- a/packages/hw-ledger/package.json +++ b/packages/hw-ledger/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/hw-ledger", - "version": "5.7.2-8", + "version": "5.8.0", "repository": "github:polkadot-js/common", "author": "Jaco Greeff ", "maintainers": [], @@ -10,8 +10,8 @@ "sideEffects": false, "dependencies": { "@babel/runtime": "^7.13.7", - "@polkadot/hw-ledger-transports": "5.7.2-8", - "@polkadot/util": "^5.7.2-8", + "@polkadot/hw-ledger-transports": "5.8.0", + "@polkadot/util": "^5.8.0", "@zondax/ledger-polkadot": "^0.13.1" } } diff --git a/packages/keyring/package.json b/packages/keyring/package.json index aadeeaa50..25682fdba 100644 --- a/packages/keyring/package.json +++ b/packages/keyring/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/keyring", - "version": "5.7.2-8", + "version": "5.8.0", "description": "Keyring management", "author": "Jaco Greeff ", "maintainers": [], @@ -16,11 +16,11 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme", "dependencies": { "@babel/runtime": "^7.13.7", - "@polkadot/util": "5.7.2-8", - "@polkadot/util-crypto": "5.7.2-8" + "@polkadot/util": "5.8.0", + "@polkadot/util-crypto": "5.8.0" }, "peerDependencies": { - "@polkadot/util": "5.7.2-8", - "@polkadot/util-crypto": "5.7.2-8" + "@polkadot/util": "5.8.0", + "@polkadot/util-crypto": "5.8.0" } } diff --git a/packages/keyring/src/pair/index.ts b/packages/keyring/src/pair/index.ts index 7a0315756..742da0ef6 100644 --- a/packages/keyring/src/pair/index.ts +++ b/packages/keyring/src/pair/index.ts @@ -173,7 +173,8 @@ export function createPair ({ toSS58, type }: Setup, { publicKey, secretKey }: P ); }, toJson: (passphrase?: string): KeyringPair$Json => { - // For ecdsa and ethereum, address and publicKey are not the same (and not bijective). We want the publicKey here + // NOTE: For ecdsa and ethereum, the publicKey cannot be extracted from the address. For these + // pass the hex-encoded publicKey through to the address portion of the JSON (before decoding) const address = ['ecdsa', 'ethereum'].includes(type) ? u8aToHex(secp256k1Compress(publicKey)) : encodeAddress(); diff --git a/packages/networks/package.json b/packages/networks/package.json index bf7b8563a..d2da408d3 100644 --- a/packages/networks/package.json +++ b/packages/networks/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/networks", - "version": "5.7.2-8", + "version": "5.8.0", "description": "A list of all available Substrate networks and their applicable prefixes", "main": "index.js", "sideEffects": false, @@ -15,7 +15,7 @@ "@babel/runtime": "^7.13.7" }, "devDependencies": { - "@polkadot/util": "5.7.2-8", - "@polkadot/x-fetch": "5.7.2-8" + "@polkadot/util": "5.8.0", + "@polkadot/x-fetch": "5.8.0" } } diff --git a/packages/util-crypto/package.json b/packages/util-crypto/package.json index f8b27d4fb..977b4a2b7 100644 --- a/packages/util-crypto/package.json +++ b/packages/util-crypto/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-crypto", - "version": "5.7.2-8", + "version": "5.8.0", "description": "A collection of useful crypto utilities for @polkadot", "main": "index.js", "sideEffects": [ @@ -16,10 +16,10 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme", "dependencies": { "@babel/runtime": "^7.13.7", - "@polkadot/networks": "5.7.2-8", - "@polkadot/util": "5.7.2-8", + "@polkadot/networks": "5.8.0", + "@polkadot/util": "5.8.0", "@polkadot/wasm-crypto": "^3.2.4", - "@polkadot/x-randomvalues": "5.7.2-8", + "@polkadot/x-randomvalues": "5.8.0", "base-x": "^3.0.8", "base64-js": "^1.5.1", "blakejs": "^1.1.0", @@ -40,6 +40,6 @@ "@types/xxhashjs": "^0.2.2" }, "peerDependencies": { - "@polkadot/util": "5.7.2-8" + "@polkadot/util": "5.8.0" } } diff --git a/packages/util-crypto/src/hd/ethereum/index.ts b/packages/util-crypto/src/hd/ethereum/index.ts index d990289b2..44212614a 100644 --- a/packages/util-crypto/src/hd/ethereum/index.ts +++ b/packages/util-crypto/src/hd/ethereum/index.ts @@ -22,7 +22,6 @@ export class HDKey { this.chainCode = chainCode; } - // derive public derive (path: string): HDKey { if (path === 'm' || path === 'M' || path === "m'" || path === "M'") { return this; @@ -42,14 +41,12 @@ export class HDKey { ), this); } - // deriveChild private deriveChild (index: number): HDKey { const indexBuffer = bnToU8a(index, { bitLength: 32, isLe: false }); const data = index >= HARDENED ? u8aConcat(new Uint8Array(1), this.secretKey, indexBuffer) : u8aConcat(this.publicKey, indexBuffer); - // Private parent key -> private child key try { const I = hmacSha512(this.chainCode, data); @@ -58,9 +55,7 @@ export class HDKey { I.slice(32) ); } catch (err) { - console.log('error when secp256k1PrivateKeyTweakAdd in eth key derivation', err); - - // In case parse256(IL) >= n or ki == 0, one should proceed with the next value for i + // In case parse256(IL) >= n or ki == 0, proceed with the next value for i return this.deriveChild(index + 1); } } diff --git a/packages/util/package.json b/packages/util/package.json index 8142817a9..6a767bf3c 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util", - "version": "5.7.2-8", + "version": "5.8.0", "description": "A collection of useful utilities for @polkadot", "main": "index.js", "sideEffects": false, @@ -13,8 +13,8 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme", "dependencies": { "@babel/runtime": "^7.13.7", - "@polkadot/x-textdecoder": "5.7.2-8", - "@polkadot/x-textencoder": "5.7.2-8", + "@polkadot/x-textdecoder": "5.8.0", + "@polkadot/x-textencoder": "5.8.0", "@types/bn.js": "^4.11.6", "bn.js": "^4.11.9", "camelcase": "^5.3.1", diff --git a/packages/x-fetch/package.json b/packages/x-fetch/package.json index e1dd75bbe..beee60ab4 100644 --- a/packages/x-fetch/package.json +++ b/packages/x-fetch/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-fetch", - "version": "5.7.2-8", + "version": "5.8.0", "description": "A cross-environment fetch replacement", "browser": "browser.js", "main": "node.js", @@ -15,7 +15,7 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-fetch#readme", "dependencies": { "@babel/runtime": "^7.13.7", - "@polkadot/x-global": "5.7.2-8", + "@polkadot/x-global": "5.8.0", "@types/node-fetch": "^2.5.8", "node-fetch": "^2.6.1" } diff --git a/packages/x-global/package.json b/packages/x-global/package.json index 0a21fe3c1..34be7a173 100644 --- a/packages/x-global/package.json +++ b/packages/x-global/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-global", - "version": "5.7.2-8", + "version": "5.8.0", "description": "A cross-environment global replacement", "main": "index.js", "sideEffects": false, diff --git a/packages/x-randomvalues/package.json b/packages/x-randomvalues/package.json index 422d5dbee..f75ddb23b 100644 --- a/packages/x-randomvalues/package.json +++ b/packages/x-randomvalues/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-randomvalues", - "version": "5.7.2-8", + "version": "5.8.0", "description": "A cross-environment window.crypto.getRandomValues replacement", "browser": "browser.js", "main": "node.js", @@ -15,7 +15,7 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-randomvalues#readme", "dependencies": { "@babel/runtime": "^7.13.7", - "@polkadot/x-global": "5.7.2-8" + "@polkadot/x-global": "5.8.0" }, "devDependencies": { "@types/react-native": "^0.63.50" diff --git a/packages/x-rxjs/package.json b/packages/x-rxjs/package.json index 9b41dc212..a4eb12504 100644 --- a/packages/x-rxjs/package.json +++ b/packages/x-rxjs/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-rxjs", - "version": "5.7.2-8", + "version": "5.8.0", "description": "A pass-through interface for RxJs (allowing node + mjs usage)", "main": "index.js", "sideEffects": false, @@ -13,6 +13,6 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-rxjs#readme", "dependencies": { "@babel/runtime": "^7.13.7", - "rxjs": "^6.6.3" + "rxjs": "^6.6.6" } } diff --git a/packages/x-textdecoder/package.json b/packages/x-textdecoder/package.json index 84d3d3deb..c708f3826 100644 --- a/packages/x-textdecoder/package.json +++ b/packages/x-textdecoder/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-textdecoder", - "version": "5.7.2-8", + "version": "5.8.0", "description": "A TextDecoder replacement", "browser": "browser.js", "main": "node.js", @@ -15,6 +15,6 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-textdecoder#readme", "dependencies": { "@babel/runtime": "^7.13.7", - "@polkadot/x-global": "5.7.2-8" + "@polkadot/x-global": "5.8.0" } } diff --git a/packages/x-textencoder/package.json b/packages/x-textencoder/package.json index 338f752dc..e40043763 100644 --- a/packages/x-textencoder/package.json +++ b/packages/x-textencoder/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-textencoder", - "version": "5.7.2-8", + "version": "5.8.0", "description": "A TextDecoder replacement", "browser": "browser.js", "main": "node.js", @@ -15,6 +15,6 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-textencoder#readme", "dependencies": { "@babel/runtime": "^7.13.7", - "@polkadot/x-global": "5.7.2-8" + "@polkadot/x-global": "5.8.0" } } diff --git a/packages/x-ws/package.json b/packages/x-ws/package.json index 66e1d7d5e..7fa73a1fa 100644 --- a/packages/x-ws/package.json +++ b/packages/x-ws/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-ws", - "version": "5.7.2-8", + "version": "5.8.0", "description": "A cross-environment WebSocket replacement", "browser": "browser.js", "main": "node.js", @@ -15,7 +15,7 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-ws#readme", "dependencies": { "@babel/runtime": "^7.13.7", - "@polkadot/x-global": "5.7.2-8", + "@polkadot/x-global": "5.8.0", "@types/websocket": "^1.0.1", "websocket": "^1.0.33" } diff --git a/yarn.lock b/yarn.lock index 7fdf48a88..f9b4e9c55 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1849,9 +1849,9 @@ __metadata: languageName: node linkType: hard -"@polkadot/dev@npm:^0.61.27": - version: 0.61.27 - resolution: "@polkadot/dev@npm:0.61.27" +"@polkadot/dev@npm:^0.61.28": + version: 0.61.28 + resolution: "@polkadot/dev@npm:0.61.28" dependencies: "@babel/cli": ^7.13.0 "@babel/core": ^7.13.1 @@ -1934,13 +1934,12 @@ __metadata: polkadot-exec-prettier: scripts/polkadot-exec-prettier.cjs polkadot-exec-tsc: scripts/polkadot-exec-tsc.cjs polkadot-exec-typedoc: scripts/polkadot-exec-typedoc.cjs - polkadot-exec-vuepress: scripts/polkadot-exec-vuepress.cjs polkadot-exec-webpack: scripts/polkadot-exec-webpack.cjs - checksum: 08465c15c45facb4b054f9c2a5918ddc9581ad5de5b13d5a1745d99669c8a42d4a6368fa19a889e09804cb0fe9a9a600d08493bf3f02975b0eea66259b912ba5 + checksum: 27be98f0da27d4087cc245c4fd45ee4bfa7bf0fbb09b7d2691b6934f48e14c0991b8c8751e65aa0e51dc73923e2023bc46111b14ae6864ad7900eed590b35de7 languageName: node linkType: hard -"@polkadot/hw-ledger-transports@5.7.2-8, @polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports": +"@polkadot/hw-ledger-transports@5.8.0, @polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports": version: 0.0.0-use.local resolution: "@polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports" dependencies: @@ -1960,8 +1959,8 @@ __metadata: resolution: "@polkadot/hw-ledger@workspace:packages/hw-ledger" dependencies: "@babel/runtime": ^7.13.7 - "@polkadot/hw-ledger-transports": 5.7.2-8 - "@polkadot/util": ^5.7.2-8 + "@polkadot/hw-ledger-transports": 5.8.0 + "@polkadot/util": ^5.8.0 "@zondax/ledger-polkadot": ^0.13.1 languageName: unknown linkType: soft @@ -1971,21 +1970,21 @@ __metadata: resolution: "@polkadot/keyring@workspace:packages/keyring" dependencies: "@babel/runtime": ^7.13.7 - "@polkadot/util": 5.7.2-8 - "@polkadot/util-crypto": 5.7.2-8 + "@polkadot/util": 5.8.0 + "@polkadot/util-crypto": 5.8.0 peerDependencies: - "@polkadot/util": 5.7.2-8 - "@polkadot/util-crypto": 5.7.2-8 + "@polkadot/util": 5.8.0 + "@polkadot/util-crypto": 5.8.0 languageName: unknown linkType: soft -"@polkadot/networks@5.7.2-8, @polkadot/networks@workspace:packages/networks": +"@polkadot/networks@5.8.0, @polkadot/networks@workspace:packages/networks": version: 0.0.0-use.local resolution: "@polkadot/networks@workspace:packages/networks" dependencies: "@babel/runtime": ^7.13.7 - "@polkadot/util": 5.7.2-8 - "@polkadot/x-fetch": 5.7.2-8 + "@polkadot/util": 5.8.0 + "@polkadot/x-fetch": 5.8.0 languageName: unknown linkType: soft @@ -1998,15 +1997,15 @@ __metadata: languageName: node linkType: hard -"@polkadot/util-crypto@5.7.2-8, @polkadot/util-crypto@workspace:packages/util-crypto": +"@polkadot/util-crypto@5.8.0, @polkadot/util-crypto@workspace:packages/util-crypto": version: 0.0.0-use.local resolution: "@polkadot/util-crypto@workspace:packages/util-crypto" dependencies: "@babel/runtime": ^7.13.7 - "@polkadot/networks": 5.7.2-8 - "@polkadot/util": 5.7.2-8 + "@polkadot/networks": 5.8.0 + "@polkadot/util": 5.8.0 "@polkadot/wasm-crypto": ^3.2.4 - "@polkadot/x-randomvalues": 5.7.2-8 + "@polkadot/x-randomvalues": 5.8.0 "@types/bn.js": ^4.11.6 "@types/create-hash": ^1.2.2 "@types/elliptic": ^6.4.12 @@ -2024,17 +2023,17 @@ __metadata: tweetnacl: ^1.0.3 xxhashjs: ^0.2.2 peerDependencies: - "@polkadot/util": 5.7.2-8 + "@polkadot/util": 5.8.0 languageName: unknown linkType: soft -"@polkadot/util@5.7.2-8, @polkadot/util@^5.7.2-8, @polkadot/util@workspace:packages/util": +"@polkadot/util@5.8.0, @polkadot/util@^5.8.0, @polkadot/util@workspace:packages/util": version: 0.0.0-use.local resolution: "@polkadot/util@workspace:packages/util" dependencies: "@babel/runtime": ^7.13.7 - "@polkadot/x-textdecoder": 5.7.2-8 - "@polkadot/x-textencoder": 5.7.2-8 + "@polkadot/x-textdecoder": 5.8.0 + "@polkadot/x-textencoder": 5.8.0 "@types/bn.js": ^4.11.6 bn.js: ^4.11.9 camelcase: ^5.3.1 @@ -2074,18 +2073,18 @@ __metadata: languageName: node linkType: hard -"@polkadot/x-fetch@5.7.2-8, @polkadot/x-fetch@workspace:packages/x-fetch": +"@polkadot/x-fetch@5.8.0, @polkadot/x-fetch@workspace:packages/x-fetch": version: 0.0.0-use.local resolution: "@polkadot/x-fetch@workspace:packages/x-fetch" dependencies: "@babel/runtime": ^7.13.7 - "@polkadot/x-global": 5.7.2-8 + "@polkadot/x-global": 5.8.0 "@types/node-fetch": ^2.5.8 node-fetch: ^2.6.1 languageName: unknown linkType: soft -"@polkadot/x-global@5.7.2-8, @polkadot/x-global@workspace:packages/x-global": +"@polkadot/x-global@5.8.0, @polkadot/x-global@workspace:packages/x-global": version: 0.0.0-use.local resolution: "@polkadot/x-global@workspace:packages/x-global" dependencies: @@ -2095,12 +2094,12 @@ __metadata: languageName: unknown linkType: soft -"@polkadot/x-randomvalues@5.7.2-8, @polkadot/x-randomvalues@workspace:packages/x-randomvalues": +"@polkadot/x-randomvalues@5.8.0, @polkadot/x-randomvalues@workspace:packages/x-randomvalues": version: 0.0.0-use.local resolution: "@polkadot/x-randomvalues@workspace:packages/x-randomvalues" dependencies: "@babel/runtime": ^7.13.7 - "@polkadot/x-global": 5.7.2-8 + "@polkadot/x-global": 5.8.0 "@types/react-native": ^0.63.50 languageName: unknown linkType: soft @@ -2110,25 +2109,25 @@ __metadata: resolution: "@polkadot/x-rxjs@workspace:packages/x-rxjs" dependencies: "@babel/runtime": ^7.13.7 - rxjs: ^6.6.3 + rxjs: ^6.6.6 languageName: unknown linkType: soft -"@polkadot/x-textdecoder@5.7.2-8, @polkadot/x-textdecoder@workspace:packages/x-textdecoder": +"@polkadot/x-textdecoder@5.8.0, @polkadot/x-textdecoder@workspace:packages/x-textdecoder": version: 0.0.0-use.local resolution: "@polkadot/x-textdecoder@workspace:packages/x-textdecoder" dependencies: "@babel/runtime": ^7.13.7 - "@polkadot/x-global": 5.7.2-8 + "@polkadot/x-global": 5.8.0 languageName: unknown linkType: soft -"@polkadot/x-textencoder@5.7.2-8, @polkadot/x-textencoder@workspace:packages/x-textencoder": +"@polkadot/x-textencoder@5.8.0, @polkadot/x-textencoder@workspace:packages/x-textencoder": version: 0.0.0-use.local resolution: "@polkadot/x-textencoder@workspace:packages/x-textencoder" dependencies: "@babel/runtime": ^7.13.7 - "@polkadot/x-global": 5.7.2-8 + "@polkadot/x-global": 5.8.0 languageName: unknown linkType: soft @@ -2137,7 +2136,7 @@ __metadata: resolution: "@polkadot/x-ws@workspace:packages/x-ws" dependencies: "@babel/runtime": ^7.13.7 - "@polkadot/x-global": 5.7.2-8 + "@polkadot/x-global": 5.8.0 "@types/websocket": ^1.0.1 websocket: ^1.0.33 languageName: unknown @@ -9553,7 +9552,7 @@ fsevents@~2.1.2: resolution: "root-workspace-0b6124@workspace:." dependencies: "@babel/core": ^7.13.1 - "@polkadot/dev": ^0.61.27 + "@polkadot/dev": ^0.61.28 "@polkadot/ts": ^0.3.59 "@types/jest": ^26.0.20 languageName: unknown @@ -9580,12 +9579,12 @@ fsevents@~2.1.2: languageName: node linkType: hard -"rxjs@npm:^6.6.0, rxjs@npm:^6.6.3": - version: 6.6.3 - resolution: "rxjs@npm:6.6.3" +"rxjs@npm:^6.6.0, rxjs@npm:^6.6.3, rxjs@npm:^6.6.6": + version: 6.6.6 + resolution: "rxjs@npm:6.6.6" dependencies: tslib: ^1.9.0 - checksum: 61a3da6db947f69b7d805df3a619d8f60678b7372c4d571dd63e45ef3532be984a88307ea0aa2cd8d2578b62c3c022186e8da9dca47c9c1b8c9ecba6f5581deb + checksum: c97b410e791b3259439be48cd37119b63eedc3809a5895d884a7ac27a6934ae4ec246be3d76f1b2f3b47c72a96500ad30977545dc8b0f4a0f98c52f5f773a8ea languageName: node linkType: hard