Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6c704eca8 | ||
|
|
c7053fa112 | ||
|
|
d76ab093a8 | ||
|
|
4a54a37ae1 | ||
|
|
0eb433f3c2 | ||
|
|
278ecc7210 | ||
|
|
03fe7dcb1d | ||
|
|
d99abde915 | ||
|
|
06502e8fe8 | ||
|
|
f3004fdb31 | ||
|
|
f5834e684f | ||
|
|
d7a1060824 | ||
|
|
c6f8748878 | ||
|
|
24a46c7262 | ||
|
|
78a282bda3 | ||
|
|
1713dccba3 | ||
|
|
0a22251212 | ||
|
|
540d46717b | ||
|
|
e5112e690d | ||
|
|
2f8c91fc15 | ||
|
|
6d552f1ced | ||
|
|
afa992b40b | ||
|
|
401c6e5763 | ||
|
|
76d051b16e | ||
|
|
5b69d5aadc | ||
|
|
780323538a | ||
|
|
042d653852 | ||
|
|
da47390fa4 | ||
|
|
488abd68bb | ||
|
|
d926ee63f4 | ||
|
|
6777f8ef5e | ||
|
|
1001083009 | ||
|
|
898b067081 | ||
|
|
acc07b9345 | ||
|
|
bc572b16d5 | ||
|
|
91d2530ea8 | ||
|
|
e679298d8d | ||
|
|
949ad77dab | ||
|
|
24ce35ae43 | ||
|
|
9e22f34720 | ||
|
|
2b867b2e91 | ||
|
|
230593ee17 | ||
|
|
60a3b8916c | ||
|
|
1f20fdf377 | ||
|
|
64dcd40bee | ||
|
|
f3948b90f7 | ||
|
|
83da578b60 | ||
|
|
407ec8e1a1 | ||
|
|
aa30920183 | ||
|
|
35d56606bd | ||
|
|
4083abb1dd | ||
|
|
c6cb3a9226 | ||
|
|
04d46701b1 | ||
|
|
61f4c5eb7d | ||
|
|
d0e99aebef | ||
|
|
dc752685d7 | ||
|
|
9bf3c1be07 | ||
|
|
32bd2172aa | ||
|
|
1f58821cd4 | ||
|
|
8352373fdd | ||
|
|
610fcee9cd | ||
|
|
b086928d01 | ||
|
|
8b3bd58e79 | ||
|
|
e6fd1e20a5 | ||
|
|
22075f8262 | ||
|
|
c8805a09dd | ||
|
|
758066b4ea | ||
|
|
da7c71c32f | ||
|
|
cb38c6f1c5 | ||
|
|
39d5b3bcce | ||
|
|
41c7af32c9 | ||
|
|
68d698502d | ||
|
|
3d4a87af6a | ||
|
|
77b1e338cf | ||
|
|
3af17400ba | ||
|
|
e16029776f | ||
|
|
61624a627b | ||
|
|
c964570806 | ||
|
|
f32846d41b | ||
|
|
705b08765b | ||
|
|
4f6771e758 | ||
|
|
731dee91e4 | ||
|
|
b82e28ad4e | ||
|
|
6d5b3f5404 | ||
|
|
1f643dd705 | ||
|
|
af9491f7fd | ||
|
|
7377da8e7e | ||
|
|
32fa12c3fa | ||
|
|
6aabb2f869 | ||
|
|
0edb0289a9 | ||
|
|
004996d772 | ||
|
|
7611fd1788 | ||
|
|
e4f85e2358 | ||
|
|
6c5e7deaa5 | ||
|
|
1f024c1da0 | ||
|
|
26b6cf843a | ||
|
|
8e54efe4a5 | ||
|
|
daecf47197 | ||
|
|
6f5ed67aad | ||
|
|
8556566c1d | ||
|
|
e28a5ffd4b | ||
|
|
7f3ca3159d | ||
|
|
3a3214e602 | ||
|
|
319f33bec1 | ||
|
|
a8f5189252 | ||
|
|
ee26a6ef98 | ||
|
|
71291442bb | ||
|
|
f26f855942 | ||
|
|
3a06871f82 | ||
|
|
279da24ca1 | ||
|
|
af81a69ba6 | ||
|
|
0b39c9d2f1 | ||
|
|
7d2de26fdb | ||
|
|
fc370eedb2 | ||
|
|
792baf352c | ||
|
|
a79d6ded77 | ||
|
|
51b45133d9 | ||
|
|
b3c934d602 | ||
|
|
25cd084f30 | ||
|
|
9df575ad7b | ||
|
|
0175ac56a7 | ||
|
|
e589fba3b1 | ||
|
|
570c46e889 | ||
|
|
4d002c7563 | ||
|
|
6aeaa69a8b | ||
|
|
4565f85077 | ||
|
|
0d0dcbf005 | ||
|
|
7e38ff8faf | ||
|
|
5640651945 | ||
|
|
657ac95ad9 | ||
|
|
23441ec34d | ||
|
|
b7768c369c | ||
|
|
646eabf516 | ||
|
|
ac36b68a5e | ||
|
|
390edd8b6d | ||
|
|
083eba1d8f | ||
|
|
0a70cc7cfb | ||
|
|
034f625118 | ||
|
|
919c4aa7d4 | ||
|
|
85350b15d2 | ||
|
|
fcc48bf20a | ||
|
|
c408836bc6 | ||
|
|
194d1a6cd4 |
@@ -1,19 +0,0 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const base = require('@polkadot/dev/config/eslint.cjs');
|
||||
|
||||
module.exports = {
|
||||
...base,
|
||||
ignorePatterns: [
|
||||
...base.ignorePatterns,
|
||||
'**/target/*',
|
||||
'**/test/*.ts'
|
||||
],
|
||||
parserOptions: {
|
||||
...base.parserOptions,
|
||||
project: [
|
||||
'./tsconfig.eslint.json'
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -11,6 +11,6 @@ jobs:
|
||||
steps:
|
||||
- uses: jacogr/action-approve@795afd1dd096a2071d7ec98740661af4e853b7da
|
||||
with:
|
||||
authors: jacogr
|
||||
authors: jacogr, TarikGul, valentinfernandez1
|
||||
labels: -auto
|
||||
token: ${{ secrets.GH_PAT_BOT }}
|
||||
|
||||
@@ -11,18 +11,18 @@ jobs:
|
||||
env:
|
||||
YARN_ENABLE_SCRIPTS: false
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- uses: denoland/setup-deno@v1
|
||||
with:
|
||||
deno-version: vx.x.x
|
||||
deno-version: v1.42.x
|
||||
- name: ${{ matrix.step }}
|
||||
if: always()
|
||||
continue-on-error: true
|
||||
run: |
|
||||
yarn install --immutable | grep -v 'YN0013'
|
||||
yarn install --immutable
|
||||
if [ "${{ matrix.step }}" != "lint" ]; then
|
||||
./scripts/install-build-deps.sh
|
||||
fi
|
||||
|
||||
@@ -18,15 +18,19 @@ jobs:
|
||||
GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT_BOT }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GH_PAT_BOT }}
|
||||
- uses: actions/setup-node@v3
|
||||
ref: ${{ github.ref }}
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- name: Set Execute Permissions
|
||||
run: chmod +x ./scripts/*
|
||||
- name: Run Install Build Deps
|
||||
run: bash ./scripts/install-build-deps.sh
|
||||
- name: build
|
||||
run: |
|
||||
yarn install --immutable | grep -v 'YN0013'
|
||||
./scripts/install-build-deps.sh
|
||||
yarn install --immutable
|
||||
yarn ${{ matrix.step }}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2023 @polkadot/dev authors & contributors
|
||||
// Copyright 2017-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = require('@polkadot/dev/config/prettier.cjs');
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"eslint.enable": true,
|
||||
"eslint.experimental.useFlatConfig": true
|
||||
}
|
||||
Vendored
-363
File diff suppressed because one or more lines are too long
-550
File diff suppressed because one or more lines are too long
Vendored
-785
File diff suppressed because one or more lines are too long
+934
File diff suppressed because one or more lines are too long
+9
-7
@@ -1,13 +1,15 @@
|
||||
compressionLevel: mixed
|
||||
|
||||
enableGlobalCache: false
|
||||
|
||||
enableImmutableInstalls: false
|
||||
|
||||
enableProgressBars: false
|
||||
|
||||
logFilters:
|
||||
- code: YN0013
|
||||
level: discard
|
||||
|
||||
nodeLinker: node-modules
|
||||
|
||||
plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-3.2.0.cjs
|
||||
yarnPath: .yarn/releases/yarn-4.6.0.cjs
|
||||
|
||||
+83
-1
@@ -1,10 +1,92 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 7.5.2 Nov 10, 2025
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix/Revert asm build ([#599](https://github.com/polkadot-js/wasm/pull/599))
|
||||
- Bump @polkadot dependencies ([#601](https://github.com/polkadot-js/wasm/pull/601))
|
||||
|
||||
|
||||
## 7.5.1 aug 25, 2025
|
||||
|
||||
Changes:
|
||||
|
||||
- Bump yarn to 4.5.1 ([#573](https://github.com/polkadot-js/wasm/pull/573))
|
||||
- Update comments and labels from 2024 to 2025 ([#574](https://github.com/polkadot-js/wasm/pull/574))
|
||||
- Bump yarn to 4.6.0 ([#575](https://github.com/polkadot-js/wasm/pull/575))
|
||||
- Set execute for build script in CI ([#576](https://github.com/polkadot-js/wasm/pull/576))
|
||||
- Set permissions on all scripts ([#577](https://github.com/polkadot-js/wasm/pull/577))
|
||||
- Bump dev to 0.83.2 ([#578](https://github.com/polkadot-js/wasm/pull/578))
|
||||
- chore: added check in ext_secp_recover for signature normalization ([#579](https://github.com/polkadot-js/wasm/pull/579))
|
||||
- chore: Improve CI ([#580](https://github.com/polkadot-js/wasm/pull/580))
|
||||
- Revert CI improvements and wasm-bindgen version ([#583](https://github.com/polkadot-js/wasm/pull/583))
|
||||
- Added validation checks in PBKDF2 and Scrypt hashing functions ([#584](https://github.com/polkadot-js/wasm/pull/584))
|
||||
- Rollback wasm-bindgen version change ([#586](https://github.com/polkadot-js/wasm/pull/586))
|
||||
- Fix rust version to 1.84 ([#587](https://github.com/polkadot-js/wasm/pull/587))
|
||||
- Default to installed rust version ([#588](https://github.com/polkadot-js/wasm/pull/588))
|
||||
- Default to nightly rust version ([#589](https://github.com/polkadot-js/wasm/pull/589))
|
||||
- Ci Fix ([#590](https://github.com/polkadot-js/wasm/pull/590))
|
||||
- Read lock file ([#591](https://github.com/polkadot-js/wasm/pull/591))
|
||||
- Setup nightly as default ([#592](https://github.com/polkadot-js/wasm/pull/592))
|
||||
- Tweak install-build-deps.sh script ([#593](https://github.com/polkadot-js/wasm/pull/593))
|
||||
- Remove ASM build ([#594](https://github.com/polkadot-js/wasm/pull/594))
|
||||
- Bump @polkadot deps ([#595](https://github.com/polkadot-js/wasm/pull/595))
|
||||
|
||||
|
||||
## 7.4.1 Oct 20, 2024
|
||||
|
||||
- Bump dev deps to 0.81.2
|
||||
- Bump TS
|
||||
- Ensure CJS is exported correctly
|
||||
- Bump yarn
|
||||
- Add missing sideEffect declarations
|
||||
- Set Deno build in CI to 1.42.x
|
||||
|
||||
|
||||
## 7.3.2 Dec 6, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
- Apply fixes for OOB array access
|
||||
|
||||
|
||||
## 7.3.1 Nov 17, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
- Drop support for Node 16 (EOL 11 Sep 2023)
|
||||
|
||||
|
||||
## 7.2.2 Aug 17, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust cjs exports for consistency
|
||||
- Adjust usage of `?.` as per (latest) linting rules
|
||||
|
||||
|
||||
## 7.2.1 May 13, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust `cjs/bytes.js` generation to follow `export.<var> = ...` form
|
||||
- Add `module` to `package.json` export map (ESM-only)
|
||||
|
||||
|
||||
## 7.1.2 Apr 28, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
- Apply `readonly` specifiers to private class fields where applicable
|
||||
- Adjust compilation output for `__internal__` class fields
|
||||
|
||||
|
||||
## 7.1.1 Apr 22, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `wasm-util` as dependency where `x-randowmvalues` is a peer
|
||||
- Add `wasm-util` as dependency where `x-randomvalues` is a peer
|
||||
- Drop support for Node 14 (EOL 30 Apr 2023)
|
||||
|
||||
|
||||
|
||||
+4
-1
@@ -1,4 +1,7 @@
|
||||
575 Jaco 7.1.1 (#513)
|
||||
618 Jaco 2024 (#559)
|
||||
19 Tarik Gul Bump dev to 0.83.2 (#578)
|
||||
12 Valentin Fernandez 7.5.1 (#596)
|
||||
6 rajk93 7.5.2 (#602)
|
||||
1 Evgeny Fixed type (#121)
|
||||
1 Shunfan Zhou Support sr25519 agreement (#209)
|
||||
1 Steve Degosserie Expose Schnorrkel's VRF capabilities (#170)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import baseConfig from '@polkadot/dev/config/eslint';
|
||||
|
||||
export default [
|
||||
...baseConfig,
|
||||
{
|
||||
ignores: [
|
||||
'mod.ts'
|
||||
]
|
||||
}
|
||||
];
|
||||
+9
-11
@@ -6,7 +6,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm#readme",
|
||||
"license": "Apache-2.0",
|
||||
"packageManager": "yarn@3.2.0",
|
||||
"packageManager": "yarn@4.6.0",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -14,10 +14,10 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "7.1.1",
|
||||
"version": "7.5.2",
|
||||
"versions": {
|
||||
"git": "7.1.1",
|
||||
"npm": "7.1.1"
|
||||
"git": "7.5.2",
|
||||
"npm": "7.5.2"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
@@ -25,7 +25,6 @@
|
||||
"scripts": {
|
||||
"build": "yarn build:wasm",
|
||||
"build:js": "./scripts/build-js.sh",
|
||||
"build:mac": "PATH=\"/opt/homebrew/opt/llvm/bin:$PATH\" CC=/opt/homebrew/opt/llvm/bin/clang AR=/opt/homebrew/opt/llvm/bin/llvm-ar yarn build",
|
||||
"build:release": "polkadot-ci-ghact-build",
|
||||
"build:rollup": "polkadot-exec-rollup --config",
|
||||
"build:wasm": "./scripts/build.sh",
|
||||
@@ -44,13 +43,12 @@
|
||||
"test:wasm-crypto:rust": "cd packages/wasm-crypto && RUST_BACKTRACE=full cargo test --release -- --test-threads=1 --nocapture"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/dev": "^0.73.2",
|
||||
"@polkadot/util": "^11.1.3",
|
||||
"@polkadot/x-randomvalues": "^11.1.3",
|
||||
"@types/node": "^18.15.13",
|
||||
"fflate": "^0.7.4"
|
||||
"@polkadot/dev": "^0.83.3",
|
||||
"@polkadot/util": "^13.5.7",
|
||||
"@types/node": "^20.16.1",
|
||||
"fflate": "^0.8.2"
|
||||
},
|
||||
"resolutions": {
|
||||
"typescript": "^5.0.4"
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"description": "A bridge layer between JS and Wasm",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=18"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-bridge#readme",
|
||||
"license": "Apache-2.0",
|
||||
@@ -14,19 +14,19 @@
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
"./packageDetect.js",
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.1.1",
|
||||
"version": "7.5.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/wasm-util": "7.1.1",
|
||||
"tslib": "^2.5.0"
|
||||
"@polkadot/wasm-util": "7.5.2",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^11.1.3",
|
||||
"@polkadot/x-randomvalues": "^11.1.3"
|
||||
"@polkadot/util": "^13.5.7",
|
||||
"@polkadot/x-randomvalues": "^13.5.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// A number of functions are "unsafe" and purposefully so - it is
|
||||
@@ -18,20 +18,21 @@ import { Wbg } from './wbg.js';
|
||||
* @description
|
||||
* Creates a bridge between the JS and WASM environments.
|
||||
*
|
||||
* For any bridge it is passed an function white is then called internally at the
|
||||
* For any bridge it is passed an function which is then called internally at the
|
||||
* time of initialization. This affectively implements the layer between WASM and
|
||||
* the native environment, providing all the plumbing needed for the Wbg classes.
|
||||
*/
|
||||
export class Bridge<C extends WasmBaseInstance> implements BridgeBase<C> {
|
||||
readonly #createWasm: InitFn<C>;
|
||||
readonly #heap: unknown[];
|
||||
readonly #wbg: WasmImports;
|
||||
|
||||
#cachegetInt32: Int32Array | null;
|
||||
#cachegetUint8: Uint8Array | null;
|
||||
#createWasm: InitFn<C>;
|
||||
#heap: unknown[];
|
||||
#heapNext: number;
|
||||
#wasm: C | null;
|
||||
#wasmError: string | null;
|
||||
#wasmPromise: InitPromise<C> | null;
|
||||
#wbg: WasmImports;
|
||||
#type: 'asm' | 'wasm' | 'none';
|
||||
|
||||
constructor (createWasm: InitFn<C>) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './bridge.js';
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default [];
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import others from './detectOther.js';
|
||||
import { packageInfo } from './packageInfo.js';
|
||||
|
||||
detectPackage(packageInfo, null, others);
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage.js';
|
||||
import './packageDetect.js';
|
||||
|
||||
export * from './bundle.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-bundle authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitFn, InitPromise, InitResult, WasmBaseInstance, WasmImports } from './types.js';
|
||||
@@ -11,7 +11,7 @@ import type { InitFn, InitPromise, InitResult, WasmBaseInstance, WasmImports } f
|
||||
* It will attempt to create a WASM interface first and if this fails or is not available in
|
||||
* the environment, will fallback to attempting to create an ASM.js interface.
|
||||
*/
|
||||
export function createWasmFn <C extends WasmBaseInstance> (root: string, wasmBytes: null | Uint8Array, asmFn: null | ((wbg: WasmImports) => C)): InitFn<C> {
|
||||
export function createWasmFn <C extends WasmBaseInstance> (root: 'crypto', wasmBytes: null | Uint8Array, asmFn: null | ((wbg: WasmImports) => C)): InitFn<C> {
|
||||
return async (wbg: WasmImports): InitPromise<C> => {
|
||||
const result: InitResult<C> = {
|
||||
error: null,
|
||||
@@ -20,7 +20,7 @@ export function createWasmFn <C extends WasmBaseInstance> (root: string, wasmByt
|
||||
};
|
||||
|
||||
try {
|
||||
if (!wasmBytes || !wasmBytes.length) {
|
||||
if (!wasmBytes?.length) {
|
||||
throw new Error('No WebAssembly provided for initialization');
|
||||
} else if (typeof WebAssembly !== 'object' || typeof WebAssembly.instantiate !== 'function') {
|
||||
throw new Error('WebAssembly is not available in your environment');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './index.js';
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2017-2025 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
// (packageInfo imports will be kept as-is, user-editable)
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import others from './detectOther.js';
|
||||
import { packageInfo } from './packageInfo.js';
|
||||
|
||||
detectPackage(packageInfo, null, others);
|
||||
detectPackage(packageInfo, null, []);
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2017-2025 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/wasm-bridge', path: 'auto', type: 'auto', version: '7.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-bridge', path: 'auto', type: 'auto', version: '7.5.2' };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Use non-strong types instead of WasmImports which may not
|
||||
@@ -7,7 +7,7 @@ export type WasmImports = Record<string, (...args: never[]) => unknown>;
|
||||
|
||||
// Use non-strong types instead of WebAssembly.Memory which may not
|
||||
// be available as part of the TS environment types (it needs dom)
|
||||
export type WasmMemory = { buffer: ArrayBuffer };
|
||||
export interface WasmMemory { buffer: ArrayBuffer }
|
||||
|
||||
export declare interface InitResult<C extends WasmBaseInstance> {
|
||||
error: string | null;
|
||||
@@ -35,13 +35,13 @@ export interface BridgeBase<C extends WasmBaseInstance> extends InitResult<C> {
|
||||
resultString (): string;
|
||||
}
|
||||
|
||||
export interface WasmBaseInstance {
|
||||
memory: WasmMemory;
|
||||
|
||||
// wbindgen functions (required and used internally)
|
||||
|
||||
export interface WasmBindGen {
|
||||
__wbindgen_exn_store (a: number): void;
|
||||
__wbindgen_free (a: number, b: number): void;
|
||||
__wbindgen_malloc (a: number): number;
|
||||
__wbindgen_realloc (a: number, b: number, c: number): number;
|
||||
}
|
||||
|
||||
export interface WasmBaseInstance extends WasmBindGen {
|
||||
memory: WasmMemory;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { BridgeBase, WasmBaseInstance } from './types.js';
|
||||
@@ -20,7 +20,7 @@ const DEFAULT_SELF = { crypto: DEFAULT_CRYPTO };
|
||||
* Internally the implementation does a thin layer into the supplied bridge.
|
||||
*/
|
||||
export class Wbg<C extends WasmBaseInstance> {
|
||||
#bridge: BridgeBase<C>;
|
||||
readonly #bridge: BridgeBase<C>;
|
||||
|
||||
constructor (bridge: BridgeBase<C>) {
|
||||
this.#bridge = bridge;
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"references": [
|
||||
]
|
||||
"exclude": [
|
||||
"**/mod.ts"
|
||||
],
|
||||
"references": []
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"description": "Asm.js content for wasm-crypto",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=18"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto-asmjs#readme",
|
||||
"license": "Apache-2.0",
|
||||
@@ -13,15 +13,18 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./packageDetect.js",
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.1.1",
|
||||
"version": "7.5.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"tslib": "^2.5.0"
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^11.1.3"
|
||||
"@polkadot/util": "^13.5.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { asmJsInit } from './cjs/data.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const data = require('../data.js');
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare const asmJsInit: null;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const asmJsInit = null;
|
||||
|
||||
module.exports.asmJsInit = asmJsInit;
|
||||
exports.asmJsInit = asmJsInit;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare const asmJsInit: null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export const asmJsInit = null;
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default [];
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage.js';
|
||||
import './packageDetect.js';
|
||||
|
||||
export * from './bundle.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './index.js';
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2017-2025 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
// (packageInfo imports will be kept as-is, user-editable)
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import others from './detectOther.js';
|
||||
import { packageInfo } from './packageInfo.js';
|
||||
|
||||
detectPackage(packageInfo, null, others);
|
||||
detectPackage(packageInfo, null, []);
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2017-2025 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', path: 'auto', type: 'auto', version: '7.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', path: 'auto', type: 'auto', version: '7.5.2' };
|
||||
|
||||
@@ -5,5 +5,8 @@
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"exclude": [
|
||||
"**/mod.ts"
|
||||
],
|
||||
"references": []
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"description": "Init handlers for wasm-crypto",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=18"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto-init#readme",
|
||||
"license": "Apache-2.0",
|
||||
@@ -14,24 +14,24 @@
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
"./packageDetect.js",
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.1.1",
|
||||
"version": "7.5.2",
|
||||
"browser": "wasm.js",
|
||||
"main": "wasm.js",
|
||||
"react-native": "asm.js",
|
||||
"dependencies": {
|
||||
"@polkadot/wasm-bridge": "7.1.1",
|
||||
"@polkadot/wasm-crypto-asmjs": "7.1.1",
|
||||
"@polkadot/wasm-crypto-wasm": "7.1.1",
|
||||
"@polkadot/wasm-util": "7.1.1",
|
||||
"tslib": "^2.5.0"
|
||||
"@polkadot/wasm-bridge": "7.5.2",
|
||||
"@polkadot/wasm-crypto-asmjs": "7.5.2",
|
||||
"@polkadot/wasm-crypto-wasm": "7.5.2",
|
||||
"@polkadot/wasm-util": "7.5.2",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^11.1.3",
|
||||
"@polkadot/x-randomvalues": "^11.1.3"
|
||||
"@polkadot/util": "^13.5.7",
|
||||
"@polkadot/x-randomvalues": "^13.5.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitFn } from '@polkadot/wasm-bridge/types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitFn } from '@polkadot/wasm-bridge/types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './wasm.js';
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as bridgeInfo } from '@polkadot/wasm-bridge/packageInfo';
|
||||
import { packageInfo as asmInfo } from '@polkadot/wasm-crypto-asmjs/packageInfo';
|
||||
import { packageInfo as wasmInfo } from '@polkadot/wasm-crypto-wasm/packageInfo';
|
||||
|
||||
export default [bridgeInfo, asmInfo, wasmInfo];
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './wasm.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitFn } from '@polkadot/wasm-bridge/types';
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2017-2025 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
// (packageInfo imports will be kept as-is, user-editable)
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
import { packageInfo as bridgeInfo } from '@polkadot/wasm-bridge/packageInfo';
|
||||
import { packageInfo as asmInfo } from '@polkadot/wasm-crypto-asmjs/packageInfo';
|
||||
import { packageInfo as wasmInfo } from '@polkadot/wasm-crypto-wasm/packageInfo';
|
||||
|
||||
import { packageInfo } from './packageInfo.js';
|
||||
|
||||
detectPackage(packageInfo, null, [asmInfo, bridgeInfo, wasmInfo]);
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2017-2025 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-init', path: 'auto', type: 'auto', version: '7.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-init', path: 'auto', type: 'auto', version: '7.5.2' };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { WasmBaseInstance } from '@polkadot/wasm-bridge/types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitFn } from '@polkadot/wasm-bridge/types';
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"exclude": [
|
||||
"**/mod.ts"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../wasm-bridge/tsconfig.build.json" },
|
||||
{ "path": "../wasm-crypto-asmjs/tsconfig.build.json" },
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"description": "Wasm content for wasm-crypto",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=18"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto-wasm#readme",
|
||||
"license": "Apache-2.0",
|
||||
@@ -13,16 +13,19 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./packageDetect.js",
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.1.1",
|
||||
"version": "7.5.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/wasm-util": "7.1.1",
|
||||
"tslib": "^2.5.0"
|
||||
"@polkadot/wasm-util": "7.5.2",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^11.1.3"
|
||||
"@polkadot/util": "^13.5.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { base64Decode, unzlibSync } from '@polkadot/wasm-util';
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare const bytes: string;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports.bytes = '';
|
||||
exports.lenIn = 0;
|
||||
|
||||
module.exports.lenIn = 0;
|
||||
exports.lenOut = 0;
|
||||
|
||||
module.exports.lenOut = 0;
|
||||
exports.bytes = '';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const bytes = require('../bytes.js');
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare const bytes: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export const bytes = '';
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default [];
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import others from './detectOther.js';
|
||||
import { packageInfo } from './packageInfo.js';
|
||||
|
||||
detectPackage(packageInfo, null, others);
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage.js';
|
||||
import './packageDetect.js';
|
||||
|
||||
export * from './bundle.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './index.js';
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2017-2025 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
// (packageInfo imports will be kept as-is, user-editable)
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import others from './detectOther.js';
|
||||
import { packageInfo } from './packageInfo.js';
|
||||
|
||||
detectPackage(packageInfo, null, others);
|
||||
detectPackage(packageInfo, null, []);
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2017-2025 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', path: 'auto', type: 'auto', version: '7.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', path: 'auto', type: 'auto', version: '7.5.2' };
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"exclude": [
|
||||
"**/mod.ts"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../wasm-util/tsconfig.build.json" }
|
||||
]
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
[dependencies]
|
||||
std = { default-features = false, features = ["panic_immediate_abort"] }
|
||||
std = { default-features = false, features = ["panic_immediate_abort"] }
|
||||
@@ -3,7 +3,7 @@
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"description": "A wasm interface layer for use by @polkadot/util-crypto",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=18"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto#readme",
|
||||
"license": "Apache-2.0",
|
||||
@@ -14,8 +14,6 @@
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs",
|
||||
"./initNone.js",
|
||||
"./initNone.cjs",
|
||||
"./initOnlyAsm.js",
|
||||
@@ -23,22 +21,24 @@
|
||||
"./initOnlyWasm.js",
|
||||
"./initOnlyWasm.cjs",
|
||||
"./initWasmAsm.js",
|
||||
"./initWasmAsm.cjs"
|
||||
"./initWasmAsm.cjs",
|
||||
"./packageDetect.js",
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.1.1",
|
||||
"version": "7.5.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/wasm-bridge": "7.1.1",
|
||||
"@polkadot/wasm-crypto-asmjs": "7.1.1",
|
||||
"@polkadot/wasm-crypto-init": "7.1.1",
|
||||
"@polkadot/wasm-crypto-wasm": "7.1.1",
|
||||
"@polkadot/wasm-util": "7.1.1",
|
||||
"tslib": "^2.5.0"
|
||||
"@polkadot/wasm-bridge": "7.5.2",
|
||||
"@polkadot/wasm-crypto-asmjs": "7.5.2",
|
||||
"@polkadot/wasm-crypto-init": "7.5.2",
|
||||
"@polkadot/wasm-crypto-wasm": "7.5.2",
|
||||
"@polkadot/wasm-util": "7.5.2",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^11.1.3",
|
||||
"@polkadot/x-randomvalues": "^11.1.3"
|
||||
"@polkadot/util": "^13.5.7",
|
||||
"@polkadot/x-randomvalues": "^13.5.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { WasmCryptoInstance } from '@polkadot/wasm-crypto-init/types';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage.js';
|
||||
import './packageDetect.js';
|
||||
|
||||
export * from './bundle.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitFn } from '@polkadot/wasm-bridge/types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { createWasm } from '@polkadot/wasm-crypto-init/none';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { createWasm } from '@polkadot/wasm-crypto-init/asm';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { createWasm } from '@polkadot/wasm-crypto-init/wasm';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { createWasm } from '@polkadot/wasm-crypto-init/both';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Use `wee_alloc` as the global allocator.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './index.js';
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2017-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
// (packageInfo imports will be kept as-is, user-editable)
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
import { packageInfo as bridgeInfo } from '@polkadot/wasm-bridge/packageInfo';
|
||||
import { packageInfo as asmInfo } from '@polkadot/wasm-crypto-asmjs/packageInfo';
|
||||
import { packageInfo as initInfo } from '@polkadot/wasm-crypto-init/packageInfo';
|
||||
import { packageInfo as wasmInfo } from '@polkadot/wasm-crypto-wasm/packageInfo';
|
||||
import { packageInfo as utilInfo } from '@polkadot/wasm-util/packageInfo';
|
||||
|
||||
export default [bridgeInfo, asmInfo, initInfo, wasmInfo, utilInfo];
|
||||
import { packageInfo } from './packageInfo.js';
|
||||
|
||||
detectPackage(packageInfo, null, [asmInfo, bridgeInfo, initInfo, utilInfo, wasmInfo]);
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2017-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto', path: 'auto', type: 'auto', version: '7.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto', path: 'auto', type: 'auto', version: '7.5.2' };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use bip39::{Mnemonic, MnemonicType, Language, Seed};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use blake2_rfc::blake2b::blake2b;
|
||||
@@ -100,6 +100,11 @@ pub fn ext_keccak512(data: &[u8]) -> Vec<u8> {
|
||||
/// Returns a vector with the hashed result
|
||||
#[wasm_bindgen]
|
||||
pub fn ext_pbkdf2(data: &[u8], salt: &[u8], rounds: u32) -> Vec<u8> {
|
||||
// As per RFC 2898 [https://datatracker.ietf.org/doc/html/rfc2898], the number of rounds must be greater than 0
|
||||
if rounds == 0 {
|
||||
panic!("PBKDF2 rounds must be greater than 0");
|
||||
}
|
||||
|
||||
let mut res = [0u8; 64];
|
||||
|
||||
// we cast to usize here - due to the WASM, we'd rather have u32 inputs
|
||||
@@ -119,6 +124,11 @@ pub fn ext_pbkdf2(data: &[u8], salt: &[u8], rounds: u32) -> Vec<u8> {
|
||||
/// Returns vector with the hashed result
|
||||
#[wasm_bindgen]
|
||||
pub fn ext_scrypt(password: &[u8], salt: &[u8], log2_n: u8, r: u32, p: u32) -> Vec<u8> {
|
||||
// As per RFC 7914 [https://datatracker.ietf.org/doc/html/rfc7914.html], the cost parameter N (2 ^ log2_n) must be larger than 1
|
||||
if log2_n == 0 {
|
||||
panic!("Scrypt cost parameter N must be larger than 1, log2_n must be at least 1");
|
||||
}
|
||||
|
||||
match ScryptParams::new(log2_n, r, p) {
|
||||
Ok(p) => {
|
||||
let mut res = [0u8; 64];
|
||||
@@ -254,6 +264,14 @@ pub mod tests {
|
||||
assert_eq!(hash[..], expected[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "PBKDF2 rounds must be greater than 0")]
|
||||
fn pbkdf2_zero_rounds_panics() {
|
||||
let salt = b"this is a salt";
|
||||
let data = b"hello world";
|
||||
ext_pbkdf2(data, salt, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_scrypt() {
|
||||
let password = b"password";
|
||||
@@ -264,6 +282,14 @@ pub mod tests {
|
||||
assert_eq!(hash[..], expected[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "Scrypt cost parameter N must be larger than 1, log2_n must be at least 1")]
|
||||
fn scrypt_zero_log2_n_panics() {
|
||||
let password = b"password";
|
||||
let salt = b"salt";
|
||||
ext_scrypt(password, salt, 0, 8, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_sha256() {
|
||||
let data = b"hello world";
|
||||
|
||||
@@ -1,130 +1,150 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use secp256k1::{ecdsa::{RecoverableSignature, RecoveryId}, Message, PublicKey, SecretKey, SECP256K1};
|
||||
use secp256k1::{
|
||||
ecdsa::{RecoverableSignature, RecoveryId},
|
||||
Message, PublicKey, SecretKey, SECP256K1,
|
||||
};
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn ext_secp_pub_compress(pubkey: &[u8]) -> Vec<u8> {
|
||||
match PublicKey::from_slice(&pubkey) {
|
||||
Ok(p) => p
|
||||
.serialize()
|
||||
.to_vec(),
|
||||
_ => panic!("Invalid pubkey provided.")
|
||||
}
|
||||
match PublicKey::from_slice(&pubkey) {
|
||||
Ok(p) => p.serialize().to_vec(),
|
||||
_ => panic!("Invalid pubkey provided."),
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn ext_secp_pub_expand(pubkey: &[u8]) -> Vec<u8> {
|
||||
match PublicKey::from_slice(&pubkey) {
|
||||
Ok(p) => p
|
||||
.serialize_uncompressed()
|
||||
.to_vec(),
|
||||
_ => panic!("Invalid pubkey provided.")
|
||||
}
|
||||
match PublicKey::from_slice(&pubkey) {
|
||||
Ok(p) => p.serialize_uncompressed().to_vec(),
|
||||
_ => panic!("Invalid pubkey provided."),
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn ext_secp_from_seed(seed: &[u8]) -> Vec<u8> {
|
||||
match SecretKey::from_slice(seed) {
|
||||
Ok(s) => {
|
||||
let mut res = vec![];
|
||||
let pubkey = PublicKey::from_secret_key(SECP256K1, &s);
|
||||
match SecretKey::from_slice(seed) {
|
||||
Ok(s) => {
|
||||
let mut res = vec![];
|
||||
let pubkey = PublicKey::from_secret_key(SECP256K1, &s);
|
||||
|
||||
res.extend_from_slice(&s.serialize_secret());
|
||||
res.extend_from_slice(&pubkey.serialize());
|
||||
res.extend_from_slice(&s.serialize_secret());
|
||||
res.extend_from_slice(&pubkey.serialize());
|
||||
|
||||
res
|
||||
},
|
||||
_ => panic!("Invalid seed provided.")
|
||||
}
|
||||
res
|
||||
}
|
||||
_ => panic!("Invalid seed provided."),
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn ext_secp_recover(hash: &[u8], sig: &[u8], rec: i32) -> Vec<u8> {
|
||||
match RecoveryId::from_i32(rec) {
|
||||
Ok(r) => match (Message::from_slice(hash), RecoverableSignature::from_compact(&sig, r)) {
|
||||
(Ok(m), Ok(s)) => match s.recover(&m) {
|
||||
Ok(k) => k
|
||||
.serialize()
|
||||
.to_vec(),
|
||||
_ => panic!("Unable to recover.")
|
||||
},
|
||||
_ => panic!("Invalid signature provided.")
|
||||
},
|
||||
_ => panic!("Invalid recovery data provided.")
|
||||
}
|
||||
match RecoveryId::from_i32(rec) {
|
||||
Ok(r) => match (
|
||||
Message::from_slice(hash),
|
||||
RecoverableSignature::from_compact(&sig, r),
|
||||
) {
|
||||
(Ok(m), Ok(s)) => {
|
||||
let standard = s.to_standard();
|
||||
let mut normalized = standard;
|
||||
normalized.normalize_s();
|
||||
|
||||
// check if the signature is normalized
|
||||
if normalized.ne(&standard) {
|
||||
panic!("Non-normalized signature provided.");
|
||||
}
|
||||
|
||||
match s.recover(&m) {
|
||||
Ok(k) => k.serialize().to_vec(),
|
||||
_ => panic!("Unable to recover."),
|
||||
}
|
||||
}
|
||||
_ => panic!("Invalid signature provided."),
|
||||
},
|
||||
_ => panic!("Invalid recovery data provided."),
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn ext_secp_sign(hash: &[u8], seckey: &[u8]) -> Vec<u8> {
|
||||
match (Message::from_slice(hash), SecretKey::from_slice(seckey)) {
|
||||
(Ok(m), Ok(s)) => {
|
||||
let mut res = vec![];
|
||||
let (rec, sig) = SECP256K1
|
||||
.sign_ecdsa_recoverable(&m, &s)
|
||||
.serialize_compact();
|
||||
match (Message::from_slice(hash), SecretKey::from_slice(seckey)) {
|
||||
(Ok(m), Ok(s)) => {
|
||||
let mut res = vec![];
|
||||
let (rec, sig) = SECP256K1.sign_ecdsa_recoverable(&m, &s).serialize_compact();
|
||||
|
||||
res.extend_from_slice(&sig);
|
||||
res.push(rec.to_i32() as u8);
|
||||
res.extend_from_slice(&sig);
|
||||
res.push(rec.to_i32() as u8);
|
||||
|
||||
res
|
||||
},
|
||||
_ => panic!("Invalid message or secret provided.")
|
||||
}
|
||||
res
|
||||
}
|
||||
_ => panic!("Invalid message or secret provided."),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use hex_literal::hex;
|
||||
use super::*;
|
||||
use super::*;
|
||||
use hex_literal::hex;
|
||||
|
||||
#[test]
|
||||
fn can_create_pair() {
|
||||
let seckey = hex!("4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae");
|
||||
let expected = hex!("4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae03fd8c74f795ced92064b86191cb2772b1e3a0947740aa0a5a6e379592471fd85b");
|
||||
let res = ext_secp_from_seed(&seckey);
|
||||
#[test]
|
||||
fn can_create_pair() {
|
||||
let seckey = hex!("4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae");
|
||||
let expected = hex!("4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae03fd8c74f795ced92064b86191cb2772b1e3a0947740aa0a5a6e379592471fd85b");
|
||||
let res = ext_secp_from_seed(&seckey);
|
||||
|
||||
assert_eq!(res[..], expected[..]);
|
||||
}
|
||||
assert_eq!(res[..], expected[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_pub_compress_full() {
|
||||
let pubkey = hex!("04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af");
|
||||
let expected = hex!("03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077");
|
||||
let res = ext_secp_pub_compress(&pubkey);
|
||||
#[test]
|
||||
fn can_pub_compress_full() {
|
||||
let pubkey = hex!("04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af");
|
||||
let expected = hex!("03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077");
|
||||
let res = ext_secp_pub_compress(&pubkey);
|
||||
|
||||
assert_eq!(res[..], expected[..]);
|
||||
}
|
||||
assert_eq!(res[..], expected[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_pub_expand_comp() {
|
||||
let pubkey = hex!("03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077");
|
||||
let expected = hex!("04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af");
|
||||
let res = ext_secp_pub_expand(&pubkey);
|
||||
#[test]
|
||||
fn can_pub_expand_comp() {
|
||||
let pubkey = hex!("03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077");
|
||||
let expected = hex!("04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af");
|
||||
let res = ext_secp_pub_expand(&pubkey);
|
||||
|
||||
assert_eq!(res[..], expected[..]);
|
||||
}
|
||||
assert_eq!(res[..], expected[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_recover() {
|
||||
let expected = hex!("028d13da15a02f3a70677339d51b14177ee9b49657662b35e56a9d9dee17db1d30");
|
||||
let sig = hex!("7505f2880114da51b3f5d535f8687953c0ab9af4ab81e592eaebebf53b728d2b6dfd9b5bcd70fee412b1f31360e7c2774009305cb84fc50c1d0ff8034dfa5fff");
|
||||
let msg = hex!("a30b64ce1eedf409c8afb801d72c05234e64849ea538c15dd3c8cf4ffcf166c9");
|
||||
let res = ext_secp_recover(&msg, &sig, 0);
|
||||
#[test]
|
||||
fn can_recover() {
|
||||
let expected = hex!("028d13da15a02f3a70677339d51b14177ee9b49657662b35e56a9d9dee17db1d30");
|
||||
let sig = hex!("7505f2880114da51b3f5d535f8687953c0ab9af4ab81e592eaebebf53b728d2b6dfd9b5bcd70fee412b1f31360e7c2774009305cb84fc50c1d0ff8034dfa5fff");
|
||||
let msg = hex!("a30b64ce1eedf409c8afb801d72c05234e64849ea538c15dd3c8cf4ffcf166c9");
|
||||
let res = ext_secp_recover(&msg, &sig, 0);
|
||||
|
||||
assert_eq!(res[..], expected[..]);
|
||||
}
|
||||
assert_eq!(res[..], expected[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_sign() {
|
||||
// JS expectation - doesn't match?
|
||||
// let expected = hex!("df92f73d9f060cefacf187b5414491cb992998ace017fa48839b5cda3e264ba8c4efa521361678d9b8582744d77aa4b8d886d7380b7808a683174afad9c4700300");
|
||||
let expected = hex!("df92f73d9f060cefacf187b5414491cb992998ace017fa48839b5cda3e264ba83b105adec9e9872647a7d8bb28855b45e22805aea3d097953cbb1391f671d13e01");
|
||||
let seckey = hex!("4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae");
|
||||
let msg = hex!("68c731589a583d08b70861683b59ce3dd56284cb2f0da5b6cd83e6641dac3aab");
|
||||
let res = ext_secp_sign(&msg, &seckey);
|
||||
#[test]
|
||||
fn can_sign() {
|
||||
// JS expectation - doesn't match?
|
||||
// let expected = hex!("df92f73d9f060cefacf187b5414491cb992998ace017fa48839b5cda3e264ba8c4efa521361678d9b8582744d77aa4b8d886d7380b7808a683174afad9c4700300");
|
||||
let expected = hex!("df92f73d9f060cefacf187b5414491cb992998ace017fa48839b5cda3e264ba83b105adec9e9872647a7d8bb28855b45e22805aea3d097953cbb1391f671d13e01");
|
||||
let seckey = hex!("4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae");
|
||||
let msg = hex!("68c731589a583d08b70861683b59ce3dd56284cb2f0da5b6cd83e6641dac3aab");
|
||||
let res = ext_secp_sign(&msg, &seckey);
|
||||
|
||||
assert_eq!(res[..], expected[..]);
|
||||
}
|
||||
assert_eq!(res[..], expected[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "Non-normalized signature provided.")]
|
||||
fn rejects_high_s_signature() {
|
||||
// valid ECDSA signature with a high S value (non-normalized)
|
||||
let sig = hex!(
|
||||
"fa1b7a71500322d70bcd5b982c678c96c95f68893063e1621b8b85c867b80b1caae8c7c4f8b5c6d181e4c8898a3f4c329da0e2c21f6f80552a660e6c1d9fa201");
|
||||
let msg = hex!("9a3c9be3a14a94df8cda1c474c0e9f8b1b35b1d85d2122cb87e6eb3c518e3be3");
|
||||
|
||||
let _ = ext_secp_recover(&msg, &sig, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Copyright 2019 Paritytech via https://github.com/paritytech/schnorrkel-js/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Copyright 2019 Paritytech via https://github.com/paritytech/schnorrkel-js/
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/* global it */
|
||||
|
||||
import { assert, u8aToHex } from '@polkadot/util';
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function bip39Generate (wasm) {
|
||||
it('generates a bip39 phrase', () => {
|
||||
const res = wasm.bip39Generate(21);
|
||||
@@ -13,6 +18,9 @@ export function bip39Generate (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function bip39GenerateSubsequent (wasm) {
|
||||
it('generates different subsequent mnemonics', () => {
|
||||
const val1 = wasm.bip39Generate(24);
|
||||
@@ -25,6 +33,9 @@ export function bip39GenerateSubsequent (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function bip39Validate (wasm) {
|
||||
it('validates a created mnemonic', () => {
|
||||
const res = wasm.bip39Validate(wasm.bip39Generate(12));
|
||||
@@ -35,6 +46,9 @@ export function bip39Validate (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function bip39ToEntropy (wasm) {
|
||||
it('creates correct entropy for a known mnemonic', () => {
|
||||
const res = u8aToHex(wasm.bip39ToEntropy('legal winner thank year wave sausage worth useful legal winner thank yellow'));
|
||||
@@ -45,6 +59,9 @@ export function bip39ToEntropy (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function bip39ToMiniSecret (wasm) {
|
||||
it('creates the correct minisecret from a mnemonic', () => {
|
||||
const res = u8aToHex(wasm.bip39ToMiniSecret('legal winner thank year wave sausage worth useful legal winner thank yellow', 'Substrate'));
|
||||
@@ -55,6 +72,9 @@ export function bip39ToMiniSecret (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function bip39ToSeed (wasm) {
|
||||
it('creates the correct seed for a mnemonic', () => {
|
||||
const res = u8aToHex(wasm.bip39ToSeed('seed sock milk update focus rotate barely fade car face mechanic mercy', ''));
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/* global it */
|
||||
|
||||
import crypto from 'crypto';
|
||||
|
||||
import { assert, hexToU8a, stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
/** @internal */
|
||||
/**
|
||||
* @internal
|
||||
* @param {*} pair
|
||||
*/
|
||||
function extractKeys (pair) {
|
||||
return [pair, pair.slice(32), pair.slice(0, 32)];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/**
|
||||
* @internal
|
||||
* @param {*} wasm
|
||||
*/
|
||||
function randomPair (wasm) {
|
||||
return extractKeys(wasm.ed25519KeypairFromSeed(crypto.randomBytes(32)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function ed25519PairFromSeed (wasm) {
|
||||
it('creates a known pair from a known seed', () => {
|
||||
const [pair, pk, sk] = extractKeys(wasm.ed25519KeypairFromSeed(stringToU8a('12345678901234567890123456789012')));
|
||||
@@ -22,12 +33,15 @@ export function ed25519PairFromSeed (wasm) {
|
||||
// console.log('\tSEC', u8aToHex(sk));
|
||||
// console.log('\tPUB', u8aToHex(pk));
|
||||
|
||||
assert(u8aToHex(sk) === '0x3132333435363738393031323334353637383930313233343536373839303132');
|
||||
assert(u8aToHex(pk) === '0x2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee');
|
||||
assert(u8aToHex(sk) === '0x3132333435363738393031323334353637383930313233343536373839303132', 'Secretkey does not match');
|
||||
assert(u8aToHex(pk) === '0x2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee', 'Public key does not match');
|
||||
assert(u8aToHex(pair) === '0x31323334353637383930313233343536373839303132333435363738393031322f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee', 'ERROR: pairFromSeed() does not match');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function ed25519SignAndVerify (wasm) {
|
||||
it('signs and verifies', () => {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
@@ -41,6 +55,9 @@ export function ed25519SignAndVerify (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function ed25519VerifyExisting (wasm) {
|
||||
it('verifies a known signature', () => {
|
||||
const isValid = wasm.ed25519Verify(hexToU8a('0x90588f3f512496f2dd40571d162e8182860081c74e2085316e7c4396918f07da412ee029978e4dd714057fe973bd9e7d645148bf7b66680d67c93227cde95202'), stringToU8a('this is a message'), hexToU8a('0x2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee'));
|
||||
@@ -51,6 +68,9 @@ export function ed25519VerifyExisting (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function ed25519Benchmark (wasm) {
|
||||
it('runs a verification benchamark', () => {
|
||||
const MESSAGE = stringToU8a('this is a message');
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/* global it */
|
||||
|
||||
import { assert, stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function blake2bHash (wasm) {
|
||||
it('creates a known blake2b hash', () => {
|
||||
const hash = u8aToHex(wasm.blake2b(stringToU8a('abc'), new Uint8Array(), 64));
|
||||
@@ -13,6 +18,9 @@ export function blake2bHash (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function hmacSha256 (wasm) {
|
||||
it('creates a known hmacSha256', () => {
|
||||
const hash = u8aToHex(wasm.hmacSha256(stringToU8a('secret'), stringToU8a('some message')));
|
||||
@@ -23,6 +31,9 @@ export function hmacSha256 (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function hmacSha512 (wasm) {
|
||||
it('creates a known hmacSha512', () => {
|
||||
const hash = u8aToHex(wasm.hmacSha512(stringToU8a('secret'), stringToU8a('some message')));
|
||||
@@ -33,6 +44,9 @@ export function hmacSha512 (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function keccak256 (wasm) {
|
||||
it('creates a known keccak256 hash', () => {
|
||||
const hash = u8aToHex(wasm.keccak256(stringToU8a('test value')));
|
||||
@@ -43,6 +57,9 @@ export function keccak256 (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function keccak512 (wasm) {
|
||||
it('creates a known keccak512 hash', () => {
|
||||
const hash = u8aToHex(wasm.keccak512(stringToU8a('test')));
|
||||
@@ -53,6 +70,9 @@ export function keccak512 (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function pbkdf2Hash (wasm) {
|
||||
it('creates a known pbkdf2 hash', () => {
|
||||
const hash = u8aToHex(wasm.pbkdf2(stringToU8a('hello world'), stringToU8a('this is a salt'), 2048));
|
||||
@@ -63,6 +83,9 @@ export function pbkdf2Hash (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function scryptHash (wasm) {
|
||||
it('creates a known scrypt hash', () => {
|
||||
const hash = u8aToHex(wasm.scrypt(stringToU8a('password'), stringToU8a('salt'), 14, 8, 1));
|
||||
@@ -73,6 +96,9 @@ export function scryptHash (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sha256Hash (wasm) {
|
||||
it('creates a known sha256 hash', () => {
|
||||
const hash = u8aToHex(wasm.sha256(stringToU8a('hello world')));
|
||||
@@ -83,6 +109,9 @@ export function sha256Hash (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sha512Hash (wasm) {
|
||||
it('creates a known sha512 hash', () => {
|
||||
const hash = u8aToHex(wasm.sha512(stringToU8a('hello world')));
|
||||
@@ -93,6 +122,9 @@ export function sha512Hash (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function twoxHash (wasm) {
|
||||
it('creates a known twox hash', () => {
|
||||
const hash64 = u8aToHex(wasm.twox(stringToU8a('abc'), 1));
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/* global describe */
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import * as bip39 from './bip39.js';
|
||||
@@ -23,6 +25,10 @@ export const tests = {
|
||||
vrf
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export async function initRun (name, wasm) {
|
||||
const result = await wasm.waitReady();
|
||||
|
||||
@@ -33,7 +39,12 @@ export async function initRun (name, wasm) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function runAll (name, wasm) {
|
||||
/** @type {string[]} */
|
||||
const failed = [];
|
||||
let count = 0;
|
||||
|
||||
@@ -51,7 +62,6 @@ export function runAll (name, wasm) {
|
||||
try {
|
||||
console.time(timerId);
|
||||
console.log();
|
||||
// console.log(timerId);
|
||||
|
||||
test(wasm);
|
||||
|
||||
@@ -71,20 +81,28 @@ export function runAll (name, wasm) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} type
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function runUnassisted (type, wasm) {
|
||||
console.log(`\n*** ${type}: Running tests`);
|
||||
|
||||
// for these we are pass-through describe and it handlers
|
||||
// For these we are pass-through describe and it handlers
|
||||
// @ts-expect-error We are hacking this, so expect TS to be unhappy...
|
||||
globalThis.describe = (name, fn) => {
|
||||
console.log('\n', name);
|
||||
|
||||
// We expect this to be handled top-level, in the test itself
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
fn();
|
||||
};
|
||||
|
||||
// @ts-expect-error We are hacking this, so expect TS to be unhappy...
|
||||
globalThis.it = (name, fn) => {
|
||||
console.log(`\t${name}`);
|
||||
|
||||
// We expect this to be handled top-level, in the test itself
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
fn();
|
||||
};
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/* global it */
|
||||
|
||||
import { assert, hexToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function secp256k1Compress (wasm) {
|
||||
it('compresses a known publicKey', () => {
|
||||
const pubkey = '0x04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af';
|
||||
@@ -14,6 +19,9 @@ export function secp256k1Compress (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function secp256k1Expand (wasm) {
|
||||
it('expands a known compressed key', () => {
|
||||
const pubkey = '0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077';
|
||||
@@ -25,6 +33,9 @@ export function secp256k1Expand (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function secp256k1FromSeed1 (wasm) {
|
||||
it('creates a known pair from seed (1)', () => {
|
||||
const seckey = '0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae';
|
||||
@@ -36,6 +47,9 @@ export function secp256k1FromSeed1 (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function secp256k1FromSeed2 (wasm) {
|
||||
it('creates a known pair from seed (2)', () => {
|
||||
// https://github.com/polkadot-js/wasm/issues/307
|
||||
@@ -60,6 +74,9 @@ export function secp256k1FromSeed2 (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function secp256k1Recover (wasm) {
|
||||
it('recovers a publicKey from signature', () => {
|
||||
const sig = '0x7505f2880114da51b3f5d535f8687953c0ab9af4ab81e592eaebebf53b728d2b6dfd9b5bcd70fee412b1f31360e7c2774009305cb84fc50c1d0ff8034dfa5fff';
|
||||
@@ -72,6 +89,9 @@ export function secp256k1Recover (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function secp256k1Sign (wasm) {
|
||||
it('creates a known signature', () => {
|
||||
const sec = '0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae';
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/* global it */
|
||||
|
||||
import crypto from 'crypto';
|
||||
|
||||
import { assert, hexToU8a, stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
/** @internal */
|
||||
/**
|
||||
* @internal
|
||||
* @param {*} pair
|
||||
*/
|
||||
function extractKeys (pair) {
|
||||
return [pair, pair.slice(64), pair.slice(0, 64)];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/**
|
||||
* @internal
|
||||
* @param {*} wasm
|
||||
*/
|
||||
function randomPair (wasm) {
|
||||
return extractKeys(wasm.sr25519KeypairFromSeed(crypto.randomBytes(32)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sr25519PairFromSeed (wasm) {
|
||||
it('creates a known pair from a known seed', () => {
|
||||
const pair = wasm.sr25519KeypairFromSeed(stringToU8a('12345678901234567890123456789012'));
|
||||
@@ -26,6 +37,9 @@ export function sr25519PairFromSeed (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sr25519DevFromSeed (wasm) {
|
||||
it('creates a known development pair', () => {
|
||||
const pair = wasm.sr25519KeypairFromSeed(hexToU8a('0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e'));
|
||||
@@ -37,6 +51,9 @@ export function sr25519DevFromSeed (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sr25519VerifyExisting (wasm) {
|
||||
it('verifies a known signature', () => {
|
||||
const PK = hexToU8a('0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d');
|
||||
@@ -51,6 +68,9 @@ export function sr25519VerifyExisting (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sr25519SignDeterministic (wasm) {
|
||||
it('creates non-deterministic signatures', () => {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
@@ -64,6 +84,9 @@ export function sr25519SignDeterministic (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sr25519SignAndVerify (wasm) {
|
||||
it('verifies a created signature', () => {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
@@ -77,6 +100,9 @@ export function sr25519SignAndVerify (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sr25519DeriveHard (wasm) {
|
||||
it('derives using a hard path', () => {
|
||||
const [pair] = randomPair(wasm);
|
||||
@@ -85,10 +111,13 @@ export function sr25519DeriveHard (wasm) {
|
||||
// console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
|
||||
// console.log('\tPUB', u8aToHex(derived.slice(64)));
|
||||
|
||||
assert(derived.length === 96);
|
||||
assert(derived.length === 96, 'Derived key length mismatch');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sr25519DeriveHardKnown (wasm) {
|
||||
it('derives a known hard key', () => {
|
||||
const derived = wasm.sr25519DeriveKeypairHard(hexToU8a('0x28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca3446ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'), hexToU8a('0x14416c6963650000000000000000000000000000000000000000000000000000'));
|
||||
@@ -101,6 +130,9 @@ export function sr25519DeriveHardKnown (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sr25519DeriveSoft (wasm) {
|
||||
it('derives using a soft path', () => {
|
||||
const [pair] = randomPair(wasm);
|
||||
@@ -109,10 +141,13 @@ export function sr25519DeriveSoft (wasm) {
|
||||
// console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
|
||||
// console.log('\tPUB', u8aToHex(derived.slice(64)));
|
||||
|
||||
assert(derived.length === 96);
|
||||
assert(derived.length === 96, 'Derived key length mismatch');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sr25519DeriveSoftKnown (wasm) {
|
||||
it('derives a known soft key', () => {
|
||||
const derived = wasm.sr25519DeriveKeypairSoft(hexToU8a('0x28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca3446ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'), hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000'));
|
||||
@@ -125,6 +160,9 @@ export function sr25519DeriveSoftKnown (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sr25519DeriveSoftPubkey (wasm) {
|
||||
it('derives a known soft publicKey', () => {
|
||||
const derived = u8aToHex(wasm.sr25519DerivePublicSoft(hexToU8a('0x46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'), hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000')));
|
||||
@@ -135,6 +173,9 @@ export function sr25519DeriveSoftPubkey (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sr25519KeyAgreement (wasm) {
|
||||
it('allows for agreements', () => {
|
||||
const pair1 = wasm.sr25519KeypairFromSeed(hexToU8a('0x3b44c558f9a8f3dc9690d53088558c1ba2529b677e316c6054d1852595b004af'));
|
||||
@@ -154,6 +195,9 @@ export function sr25519KeyAgreement (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function sr25519Benchmark (wasm) {
|
||||
it('runs a verification benchmark', () => {
|
||||
const MESSAGE = stringToU8a('this is a message');
|
||||
|
||||
@@ -1,18 +1,31 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/* global it */
|
||||
|
||||
import crypto from 'crypto';
|
||||
|
||||
import { assert, stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @param {*} pair
|
||||
*/
|
||||
function extractKeys (pair) {
|
||||
return [pair, pair.slice(64), pair.slice(0, 64)];
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @param {*} wasm
|
||||
*/
|
||||
function randomPair (wasm) {
|
||||
return extractKeys(wasm.sr25519KeypairFromSeed(crypto.randomBytes(32)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function vrfSignAndVerifyCompat (wasm) {
|
||||
it('can sign and verify (1)', () => {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
@@ -26,6 +39,9 @@ export function vrfSignAndVerifyCompat (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function vrfSignAndVerify (wasm) {
|
||||
it('can sign and verify (2)', () => {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
@@ -39,6 +55,9 @@ export function vrfSignAndVerify (wasm) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} wasm
|
||||
*/
|
||||
export function vrfSignAndVerifyDeterministic (wasm) {
|
||||
it('has non-deterministic outputs', () => {
|
||||
const [,, sk] = randomPair(wasm);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import '@polkadot/wasm-crypto/initOnlyAsm';
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// This is a Deno file, so we can allow .ts imports
|
||||
/* eslint-disable import/extensions */
|
||||
|
||||
// NOTE We don't use ts-expect-error here since the build folder may or may
|
||||
// not exist (so the error may or may not be there)
|
||||
//
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore This should only run against the compiled ouput, where this should exist
|
||||
import * as wasm from '../build-deno/mod.ts';
|
||||
import { initRun, tests } from './all/index.js';
|
||||
|
||||
declare const globalThis;
|
||||
type Tests = Record<string, (wasm: unknown) => void>;
|
||||
|
||||
declare const globalThis: {
|
||||
it: (name: string, fn: () => void) => unknown;
|
||||
};
|
||||
declare const Deno: {
|
||||
test: (name: string, test: () => unknown) => unknown;
|
||||
}
|
||||
};
|
||||
|
||||
await initRun('wasm', wasm);
|
||||
|
||||
@@ -15,7 +27,7 @@ await initRun('wasm', wasm);
|
||||
globalThis.it = (name: string, fn: () => void) => Deno.test(name, () => fn());
|
||||
|
||||
Object
|
||||
.entries<{ [key: string]: (wasm: unknown) => void }>(tests)
|
||||
.entries<Tests>(tests)
|
||||
.forEach(([describeName, tests]) => {
|
||||
console.log('***', describeName);
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
// NOTE We don't use ts-expect-error here since the build folder may or may
|
||||
// not exist (so the error may or may not be there)
|
||||
//
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore This should only run against the compiled ouput, where this should exist
|
||||
import * as wasm from '../build/index.js';
|
||||
import { initRun, tests } from './all/index.js';
|
||||
|
||||
@@ -10,9 +15,9 @@ describe('wasm-crypto', (): void => {
|
||||
beforeAll(() => initRun('wasm', wasm));
|
||||
|
||||
for (const name of Object.keys(tests)) {
|
||||
describe(name, (): void => {
|
||||
describe(`${name}`, (): void => {
|
||||
Object
|
||||
.values<(wasm: unknown) => void>(tests[name])
|
||||
.values<(wasm: unknown) => void>(tests[name as keyof typeof tests])
|
||||
.forEach((fn) => fn(wasm));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
// Adjusts the resolver to point to the build output
|
||||
/**
|
||||
* Adjusts the resolver to point to the build output
|
||||
*
|
||||
* @param {*} specifier
|
||||
* @param {*} context
|
||||
* @param {*} nextResolve
|
||||
* @returns {*}
|
||||
*/
|
||||
export function resolve (specifier, context, nextResolve) {
|
||||
if (/^@polkadot\/wasm-/.test(specifier)) {
|
||||
if (specifier.startsWith('@polkadot/wasm-')) {
|
||||
const parts = specifier.split(/[\\/]/);
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2025 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import * as wasm from '@polkadot/wasm-crypto';
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"exclude": [
|
||||
"**/test/*.ts"
|
||||
"**/mod.ts",
|
||||
"**/test/**/*"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../wasm-bridge/tsconfig.build.json" },
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user