Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
fbb7d77f06 | ||
|
|
1536cd9b48 | ||
|
|
695ccae218 | ||
|
|
bd8d729765 | ||
|
|
2453c8728b | ||
|
|
f39f0d72f2 | ||
|
|
89739683f5 | ||
|
|
7f0c60b4f0 | ||
|
|
6ee5b6da86 | ||
|
|
68575449f1 | ||
|
|
ea7035a484 | ||
|
|
cbb7cd94f7 | ||
|
|
d0af71031f | ||
|
|
929401b8b6 | ||
|
|
778879b1c1 | ||
|
|
cadb0d9123 | ||
|
|
4e505bbe29 | ||
|
|
72cbdf6eaa | ||
|
|
a032cbce6e | ||
|
|
12a5b0da0f | ||
|
|
f1129ddcbb | ||
|
|
7d2a29d231 | ||
|
|
c5550ad559 | ||
|
|
d1fd2a74a4 | ||
|
|
f1d678132a | ||
|
|
784422a129 | ||
|
|
0a6b25fbdd | ||
|
|
6bc249181b | ||
|
|
a47fb3bff9 | ||
|
|
d21c3fc639 | ||
|
|
7da2f705dc | ||
|
|
69278851bc | ||
|
|
41dbf12257 | ||
|
|
7a8ce5ea3a | ||
|
|
7d24e46947 |
@@ -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 }}
|
||||
|
||||
@@ -13,13 +13,13 @@ jobs:
|
||||
- uses: dessant/lock-threads@c1b35aecc5cdb1a34539d14196df55838bb2f836
|
||||
with:
|
||||
github-token: ${{ secrets.GH_PAT_BOT }}
|
||||
issue-lock-inactive-days: '7'
|
||||
issue-lock-comment: >
|
||||
issue-inactive-days: '7'
|
||||
issue-comment: >
|
||||
This thread has been automatically locked since there has not been
|
||||
any recent activity after it was closed. Please open a new issue
|
||||
if you think you have a related problem or query.
|
||||
pr-lock-inactive-days: '2'
|
||||
pr-lock-comment: >
|
||||
pr-inactive-days: '2'
|
||||
pr-comment: >
|
||||
This pull request has been automatically locked since there
|
||||
has not been any recent activity after it was closed.
|
||||
Please open a new issue for related bugs.
|
||||
|
||||
@@ -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,19 +0,0 @@
|
||||
name: 'Close stale issues and PRs'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '35 1/3 * * *'
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
YARN_ENABLE_SCRIPTS: false
|
||||
steps:
|
||||
- uses: actions/stale@v7
|
||||
with:
|
||||
repo-token: ${{ secrets.GH_PAT_BOT }}
|
||||
stale-issue-message: 'This issue has been open for 365 days with no activity and is not labelled as an enhancement. It will be closed in 7 days.'
|
||||
stale-issue-label: 'stale'
|
||||
exempt-issue-labels: '-size-l,-size-m,-size-s,-size-xl,-size-xs,[bug]'
|
||||
days-before-stale: 365
|
||||
days-before-close: 7
|
||||
+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
|
||||
|
||||
@@ -1,5 +1,87 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 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-randomvalues` is a peer
|
||||
- Drop support for Node 14 (EOL 30 Apr 2023)
|
||||
|
||||
|
||||
## 7.0.3 Mar 11, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
+4
-1
@@ -1,4 +1,7 @@
|
||||
557 Jaco 7.0.3 (#495)
|
||||
618 Jaco 2024 (#559)
|
||||
19 Tarik Gul Bump dev to 0.83.2 (#578)
|
||||
12 Valentin Fernandez 7.5.1 (#596)
|
||||
3 rajk93 Added validation checks in PBKDF2 and Scrypt hashing functions (#584)
|
||||
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'
|
||||
]
|
||||
}
|
||||
];
|
||||
+14
-14
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"engines": {
|
||||
"node": ">=18.14"
|
||||
},
|
||||
"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",
|
||||
@@ -11,10 +14,10 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "7.0.3",
|
||||
"version": "7.5.1",
|
||||
"versions": {
|
||||
"git": "7.0.3",
|
||||
"npm": "7.0.3"
|
||||
"git": "7.5.1",
|
||||
"npm": "7.5.1"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
@@ -22,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",
|
||||
@@ -36,19 +38,17 @@
|
||||
"test:js": "yarn test:wasm-crypto:js",
|
||||
"test:wasm-crypto:deno": "deno test --allow-read --import-map=import_map.json packages/wasm-crypto/test/deno.ts",
|
||||
"test:wasm-crypto:js": "yarn test:wasm-crypto:js:jest && yarn test:wasm-crypto:js:node",
|
||||
"test:wasm-crypto:js:jest": "polkadot-dev-run-test --env node --loader ./packages/wasm-crypto/test/loader-build.js test/jest.spec.ts",
|
||||
"test:wasm-crypto:js:node": "node --no-warnings --loader ./packages/wasm-crypto/test/loader-build.js ./packages/wasm-crypto/test/wasm.js && node --no-warnings --loader ./packages/wasm-crypto/test/loader-build.js ./packages/wasm-crypto/test/asm.js",
|
||||
"test:wasm-crypto:js:jest": "polkadot-dev-run-test --env node --loader ./packages/wasm-crypto/test/loader-build.js",
|
||||
"test:wasm-crypto:js:node": "node --no-warnings --loader ./packages/wasm-crypto/test/loader-build.js ./packages/wasm-crypto/test/wasm.js",
|
||||
"test:wasm-crypto:rust": "cd packages/wasm-crypto && RUST_BACKTRACE=full cargo test --release -- --test-threads=1 --nocapture"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.21.0",
|
||||
"@polkadot/dev": "^0.71.4",
|
||||
"@polkadot/util": "^11.0.1",
|
||||
"@polkadot/x-randomvalues": "^11.0.1",
|
||||
"@types/node": "^18.15.0",
|
||||
"fflate": "^0.7.4"
|
||||
"@polkadot/dev": "^0.83.3",
|
||||
"@polkadot/util": "^13.5.5",
|
||||
"@types/node": "^20.16.1",
|
||||
"fflate": "^0.8.2"
|
||||
},
|
||||
"resolutions": {
|
||||
"typescript": "^4.9.5"
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
{
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"contributors": [],
|
||||
"description": "A bridge layer between JS and Wasm",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
"node": ">=18"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-bridge#readme",
|
||||
"license": "Apache-2.0",
|
||||
"maintainers": [],
|
||||
"name": "@polkadot/wasm-bridge",
|
||||
"repository": {
|
||||
"directory": "packages/wasm-bridge",
|
||||
@@ -16,18 +14,19 @@
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
"./packageDetect.js",
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.0.3",
|
||||
"version": "7.5.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"tslib": "^2.5.0"
|
||||
"@polkadot/wasm-util": "7.5.1",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^11.0.1",
|
||||
"@polkadot/x-randomvalues": "^11.0.1"
|
||||
"@polkadot/util": "^13.5.5",
|
||||
"@polkadot/x-randomvalues": "^13.5.5"
|
||||
},
|
||||
"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.0.3' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-bridge', path: 'auto', type: 'auto', version: '7.5.1' };
|
||||
|
||||
@@ -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;
|
||||
@@ -52,25 +52,21 @@ export class Wbg<C extends WasmBaseInstance> {
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
__wbg_crypto_968f1772287e2df0 = (_idx: number): number => {
|
||||
return this.#bridge.addObject(DEFAULT_CRYPTO);
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
__wbg_getRandomValues_a3d34b4fee3c2869 = (_idx: number): number => {
|
||||
return this.#bridge.addObject(DEFAULT_CRYPTO.getRandomValues);
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
__wbg_getRandomValues_f5e14ab7ac8e995d = (_arg0: number, ptr: number, len: number): void => {
|
||||
DEFAULT_CRYPTO.getRandomValues(this.#bridge.getU8a(ptr, len));
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
__wbg_randomFillSync_d5bd2d655fdf256a = (_idx: number, _ptr: number, _len: number): never => {
|
||||
throw new Error('randomFillsync is not available');
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"references": [
|
||||
]
|
||||
"exclude": [
|
||||
"**/mod.ts"
|
||||
],
|
||||
"references": []
|
||||
}
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
{
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"contributors": [],
|
||||
"description": "Asm.js content for wasm-crypto",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
"node": ">=18"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto-asmjs#readme",
|
||||
"license": "Apache-2.0",
|
||||
"maintainers": [],
|
||||
"name": "@polkadot/wasm-crypto-asmjs",
|
||||
"repository": {
|
||||
"directory": "packages/wasm-crypto-asmjs",
|
||||
"type": "git",
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./packageDetect.js",
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.0.3",
|
||||
"version": "7.5.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"tslib": "^2.5.0"
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^11.0.1"
|
||||
"@polkadot/util": "^13.5.5"
|
||||
},
|
||||
"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.0.3' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', path: 'auto', type: 'auto', version: '7.5.1' };
|
||||
|
||||
@@ -5,5 +5,8 @@
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"exclude": [
|
||||
"**/mod.ts"
|
||||
],
|
||||
"references": []
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
{
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"contributors": [],
|
||||
"description": "Init handlers for wasm-crypto",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
"node": ">=18"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto-init#readme",
|
||||
"license": "Apache-2.0",
|
||||
"maintainers": [],
|
||||
"name": "@polkadot/wasm-crypto-init",
|
||||
"repository": {
|
||||
"directory": "packages/wasm-crypto-init",
|
||||
@@ -16,23 +14,24 @@
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
"./packageDetect.js",
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.0.3",
|
||||
"version": "7.5.1",
|
||||
"browser": "wasm.js",
|
||||
"main": "wasm.js",
|
||||
"react-native": "asm.js",
|
||||
"dependencies": {
|
||||
"@polkadot/wasm-bridge": "7.0.3",
|
||||
"@polkadot/wasm-crypto-asmjs": "7.0.3",
|
||||
"@polkadot/wasm-crypto-wasm": "7.0.3",
|
||||
"tslib": "^2.5.0"
|
||||
"@polkadot/wasm-bridge": "7.5.1",
|
||||
"@polkadot/wasm-crypto-asmjs": "7.5.1",
|
||||
"@polkadot/wasm-crypto-wasm": "7.5.1",
|
||||
"@polkadot/wasm-util": "7.5.1",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^11.0.1",
|
||||
"@polkadot/x-randomvalues": "^11.0.1"
|
||||
"@polkadot/util": "^13.5.5",
|
||||
"@polkadot/x-randomvalues": "^13.5.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*",
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
// 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';
|
||||
import type { WasmCryptoInstance } from './types.js';
|
||||
|
||||
import { createWasmFn } from '@polkadot/wasm-bridge';
|
||||
import { asmJsInit } from '@polkadot/wasm-crypto-asmjs';
|
||||
import * as mod from '@polkadot/wasm-crypto-asmjs';
|
||||
|
||||
const { asmJsInit } = mod;
|
||||
|
||||
export { packageInfo } from './packageInfo.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';
|
||||
|
||||
@@ -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.0.3' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-init', path: 'auto', type: 'auto', version: '7.5.1' };
|
||||
|
||||
@@ -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" },
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
{
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"contributors": [],
|
||||
"description": "Wasm content for wasm-crypto",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
"node": ">=18"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto-wasm#readme",
|
||||
"license": "Apache-2.0",
|
||||
"maintainers": [],
|
||||
"name": "@polkadot/wasm-crypto-wasm",
|
||||
"repository": {
|
||||
"directory": "packages/wasm-crypto-wasm",
|
||||
"type": "git",
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"sideEffects": [
|
||||
"./packageDetect.js",
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.0.3",
|
||||
"version": "7.5.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/wasm-util": "7.0.3",
|
||||
"tslib": "^2.5.0"
|
||||
"@polkadot/wasm-util": "7.5.1",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^11.0.1"
|
||||
"@polkadot/util": "^13.5.5"
|
||||
},
|
||||
"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.0.3' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', path: 'auto', type: 'auto', version: '7.5.1' };
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"exclude": [
|
||||
"**/mod.ts"
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../wasm-util/tsconfig.build.json" }
|
||||
]
|
||||
|
||||
Generated
+104
-66
@@ -1,6 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
@@ -54,9 +54,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
version = "2.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
|
||||
|
||||
[[package]]
|
||||
name = "blake2-rfc"
|
||||
@@ -125,15 +125,6 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "cloudabi"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.1.5"
|
||||
@@ -315,9 +306,9 @@ checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
@@ -325,15 +316,6 @@ version = "0.2.108"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75"
|
||||
dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.11"
|
||||
@@ -384,11 +366,11 @@ checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.4.0"
|
||||
version = "1.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
dependencies = [
|
||||
"parking_lot",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -397,28 +379,17 @@ version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.7.2"
|
||||
version = "0.9.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
|
||||
checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"cloudabi",
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"winapi",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -445,18 +416,18 @@ checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.36"
|
||||
version = "1.0.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
|
||||
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.7"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@@ -504,9 +475,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.57"
|
||||
version = "0.5.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
||||
checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
@@ -538,12 +512,6 @@ dependencies = [
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "scrypt"
|
||||
version = "0.2.0"
|
||||
@@ -601,9 +569,9 @@ checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.4.1"
|
||||
version = "1.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f"
|
||||
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
@@ -686,6 +654,12 @@ version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.13"
|
||||
@@ -740,9 +714,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.79"
|
||||
version = "0.2.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06"
|
||||
checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"wasm-bindgen-macro",
|
||||
@@ -750,9 +724,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.79"
|
||||
version = "0.2.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca"
|
||||
checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"lazy_static",
|
||||
@@ -765,9 +739,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.79"
|
||||
version = "0.2.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01"
|
||||
checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -775,9 +749,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.79"
|
||||
version = "0.2.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc"
|
||||
checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -788,9 +762,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.79"
|
||||
version = "0.2.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2"
|
||||
checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744"
|
||||
|
||||
[[package]]
|
||||
name = "wee_alloc"
|
||||
@@ -826,6 +800,70 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.1.0"
|
||||
|
||||
@@ -32,7 +32,7 @@ sha2 = "0.8.1"
|
||||
tiny-bip39 = { version = "0.7", default-features = false }
|
||||
tiny-keccak = { version = "2.0.1", features = ["keccak"] }
|
||||
twox-hash = "1.5.0"
|
||||
wasm-bindgen = "=0.2.79"
|
||||
wasm-bindgen = "0.2"
|
||||
wee_alloc = "0.4.3"
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
{
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"contributors": [],
|
||||
"description": "A wasm interface layer for use by @polkadot/util-crypto",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
"node": ">=18"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/wasm/tree/master/packages/wasm-crypto#readme",
|
||||
"license": "Apache-2.0",
|
||||
"maintainers": [],
|
||||
"name": "@polkadot/wasm-crypto",
|
||||
"repository": {
|
||||
"directory": "packages/wasm-crypto",
|
||||
@@ -16,8 +14,6 @@
|
||||
"url": "https://github.com/polkadot-js/wasm.git"
|
||||
},
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs",
|
||||
"./initNone.js",
|
||||
"./initNone.cjs",
|
||||
"./initOnlyAsm.js",
|
||||
@@ -25,22 +21,24 @@
|
||||
"./initOnlyWasm.js",
|
||||
"./initOnlyWasm.cjs",
|
||||
"./initWasmAsm.js",
|
||||
"./initWasmAsm.cjs"
|
||||
"./initWasmAsm.cjs",
|
||||
"./packageDetect.js",
|
||||
"./packageDetect.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "7.0.3",
|
||||
"version": "7.5.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@polkadot/wasm-bridge": "7.0.3",
|
||||
"@polkadot/wasm-crypto-asmjs": "7.0.3",
|
||||
"@polkadot/wasm-crypto-init": "7.0.3",
|
||||
"@polkadot/wasm-crypto-wasm": "7.0.3",
|
||||
"@polkadot/wasm-util": "7.0.3",
|
||||
"tslib": "^2.5.0"
|
||||
"@polkadot/wasm-bridge": "7.5.1",
|
||||
"@polkadot/wasm-crypto-asmjs": "7.5.1",
|
||||
"@polkadot/wasm-crypto-init": "7.5.1",
|
||||
"@polkadot/wasm-crypto-wasm": "7.5.1",
|
||||
"@polkadot/wasm-util": "7.5.1",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^11.0.1",
|
||||
"@polkadot/x-randomvalues": "^11.0.1"
|
||||
"@polkadot/util": "^13.5.5",
|
||||
"@polkadot/x-randomvalues": "^13.5.5"
|
||||
},
|
||||
"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.0.3' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto', path: 'auto', type: 'auto', version: '7.5.1' };
|
||||
|
||||
@@ -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/node/test/node" />
|
||||
/// <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));
|
||||
});
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user