Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13e8c6af1d | ||
|
|
56f98e67a1 | ||
|
|
5023c02a73 | ||
|
|
3b286e6034 | ||
|
|
bccb16f691 | ||
|
|
aeae6c137e | ||
|
|
2a2bd06284 | ||
|
|
1310dca729 | ||
|
|
34f2b544f0 | ||
|
|
dde2f92445 | ||
|
|
b9ad508d27 | ||
|
|
ca7e44c25a | ||
|
|
a0de0ac427 | ||
|
|
2893343bf2 | ||
|
|
8b70740a18 | ||
|
|
5e54136fff | ||
|
|
35b4c38be4 | ||
|
|
e1b24a61c6 | ||
|
|
a71d353fff | ||
|
|
218d2b9217 | ||
|
|
0429de0429 | ||
|
|
5f18253ba8 | ||
|
|
b17de3422a | ||
|
|
935f92dd5b | ||
|
|
ea79adf45d | ||
|
|
e71807c2a3 | ||
|
|
04365b87a5 | ||
|
|
f5856d091b | ||
|
|
45554b753f | ||
|
|
5967b48515 | ||
|
|
2d85a62bb7 | ||
|
|
39ca57f059 | ||
|
|
5a08739f24 | ||
|
|
fe09bc21ed | ||
|
|
8706cdb9c2 | ||
|
|
498a58d95a | ||
|
|
2501f771a7 | ||
|
|
55aef41eee | ||
|
|
e14c249ae2 | ||
|
|
561abdbf0d | ||
|
|
964432c184 | ||
|
|
4944d228cd | ||
|
|
de4a6c69fe | ||
|
|
f3ffb229ff | ||
|
|
3910ad5241 | ||
|
|
e8cc388f3a | ||
|
|
888a5d00ed | ||
|
|
dcd5533149 | ||
|
|
f3a5b7e373 | ||
|
|
6f06fe6b2a | ||
|
|
ac96179904 | ||
|
|
c37f707b15 | ||
|
|
80f40a500c | ||
|
|
445863a940 | ||
|
|
30a8ab0d8c | ||
|
|
4a239f5ed5 | ||
|
|
3db8d49d11 | ||
|
|
9885b65cf0 | ||
|
|
5c867e0cd4 | ||
|
|
00b79f4f9f | ||
|
|
0f82e9c5d8 | ||
|
|
007fc9923a | ||
|
|
ccfe31d9b5 | ||
|
|
f921359f64 | ||
|
|
4463395dfe | ||
|
|
f4080e5754 | ||
|
|
c6bb302f9c | ||
|
|
6d7ace4291 | ||
|
|
53a62bec02 | ||
|
|
263caf3238 | ||
|
|
6e0d56e955 | ||
|
|
cf9d894556 | ||
|
|
1c1a10f14b | ||
|
|
7d3ce85684 | ||
|
|
5fd16cda08 | ||
|
|
87fc9d9ee1 | ||
|
|
bf1a4b7b7f | ||
|
|
4c10357c41 | ||
|
|
4ceb620462 | ||
|
|
97ef0b0dd6 |
@@ -1,21 +0,0 @@
|
||||
checks:
|
||||
argument-count:
|
||||
config:
|
||||
threshold: 5
|
||||
method-complexity:
|
||||
config:
|
||||
threshold: 7
|
||||
method-count:
|
||||
config:
|
||||
threshold: 25
|
||||
method-lines:
|
||||
config:
|
||||
threshold: 30
|
||||
|
||||
exclude_patterns:
|
||||
- "**/*.spec.js"
|
||||
- "**/*.spec.ts"
|
||||
- "docs/**/*.js"
|
||||
- "**/test/**/*.js"
|
||||
- "packages/wasm-crypto/src/bundle.ts"
|
||||
- "packages/wasm-util/src/fflate.ts"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const base = require('@polkadot/dev/config/eslint.cjs');
|
||||
|
||||
@@ -9,7 +9,7 @@ jobs:
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && (!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository)"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: jacogr/action-approve@9d6ce78d26f23ad29d009d034822cf773f2cb50e
|
||||
- uses: jacogr/action-approve@795afd1dd096a2071d7ec98740661af4e853b7da
|
||||
with:
|
||||
authors: jacogr
|
||||
labels: -auto
|
||||
|
||||
@@ -8,9 +8,9 @@ jobs:
|
||||
merge:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: jacogr/action-merge@3b4b49af8a8644bf5cbb5409ee236abe04eeb1b0
|
||||
- uses: jacogr/action-merge@d2d64b4545acd93b0a9575177d3d215ae3f92029
|
||||
with:
|
||||
checks: build,lint,test
|
||||
checks: pr (build),pr (lint),pr (test)
|
||||
labels: -auto
|
||||
strategy: squash
|
||||
token: ${{ secrets.GH_PAT_BOT }}
|
||||
|
||||
@@ -3,16 +3,19 @@ on: [pull_request]
|
||||
|
||||
jobs:
|
||||
pr:
|
||||
continue-on-error: true
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['lint', 'test', 'build', 'deno']
|
||||
name: ${{ matrix.step }}
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
YARN_ENABLE_SCRIPTS: false
|
||||
steps:
|
||||
- uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e
|
||||
- uses: denoland/setup-deno@004814556e37c54a2f6e31384c9e18e983317366
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- uses: denoland/setup-deno@v1
|
||||
with:
|
||||
deno-version: vx.x.x
|
||||
- name: ${{ matrix.step }}
|
||||
|
||||
@@ -10,19 +10,21 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['build:release']
|
||||
name: ${{ matrix.step }}
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
YARN_ENABLE_SCRIPTS: false
|
||||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT }}
|
||||
GH_PAT: ${{ secrets.GH_PAT_BOT }}
|
||||
GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT_BOT }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
token: ${{ secrets.GH_PAT_BOT }}
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- name: build
|
||||
run: |
|
||||
yarn install --immutable | grep -v 'YN0013'
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
name: Semgrep
|
||||
on:
|
||||
pull_request: {}
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
check:
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && (!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository)"
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
YARN_ENABLE_SCRIPTS: false
|
||||
steps:
|
||||
- uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e
|
||||
- uses: returntocorp/semgrep-action@aeafd770072c4f48798b991e3449592bddc2c435
|
||||
with:
|
||||
auditOn: push
|
||||
publishToken: ${{ secrets.SEMGREP_APP_TOKEN }}
|
||||
publishDeployment: 1395
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/dev authors & contributors
|
||||
// Copyright 2017-2023 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = require('@polkadot/dev/config/prettier.cjs');
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 7.0.1 Mar 4, 2023
|
||||
|
||||
Changes:
|
||||
|
||||
- Swap TS -> JS compiler to use tsc (from babel)
|
||||
- Adjust all tests to use `node:test` runner (ESM & CJS variants)
|
||||
|
||||
|
||||
## 6.4.1 Dec 3, 2022
|
||||
|
||||
Changes:
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
508 Jaco 6.4.1 (#445)
|
||||
549 Jaco 7.0.1 (#487)
|
||||
1 Evgeny Fixed type (#121)
|
||||
1 Shunfan Zhou Support sr25519 agreement (#209)
|
||||
1 Steve Degosserie Expose Schnorrkel's VRF capabilities (#170)
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
[](https://polkadot.js.org)
|
||||

|
||||
[](https://www.npmjs.com/package/@polkadot/wasm-crypto)
|
||||
[](https://www.npmjs.com/package/@polkadot/wasm-crypto)
|
||||
[](https://codeclimate.com/github/polkadot-js/wasm/maintainability)
|
||||
|
||||
# @polkadot/wasm
|
||||
|
||||
Various WASM wrappers around Rust crates
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = require('@polkadot/dev/config/babel-config-cjs.cjs');
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const config = require('@polkadot/dev/config/jest.cjs');
|
||||
|
||||
module.exports = {
|
||||
...config,
|
||||
moduleNameMapper: {
|
||||
'@polkadot/wasm-crypto-(init|asmjs|wasm)(.*)$': '<rootDir>/packages/wasm-crypto-$1/build/$2',
|
||||
// eslint-disable-next-line sort-keys
|
||||
'@polkadot/wasm-(bridge|crypto|util)(.*)$': '<rootDir>/packages/wasm-$1/build/$2'
|
||||
}
|
||||
};
|
||||
+13
-13
@@ -11,10 +11,10 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "6.4.1",
|
||||
"version": "7.0.1",
|
||||
"versions": {
|
||||
"git": "6.4.1",
|
||||
"npm": "6.4.1"
|
||||
"git": "7.0.1",
|
||||
"npm": "7.0.1"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
@@ -33,22 +33,22 @@
|
||||
"lint": "polkadot-dev-run-lint",
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
"test": "yarn test:wasm-crypto:rust",
|
||||
"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 ./test/jest.spec.js",
|
||||
"test:wasm-crypto:js:node": "cd packages/wasm-crypto && node ./test/wasm.cjs && node ./test/asm.cjs",
|
||||
"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:rust": "cd packages/wasm-crypto && RUST_BACKTRACE=full cargo test --release -- --test-threads=1 --nocapture"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.20.5",
|
||||
"@polkadot/dev": "^0.67.167",
|
||||
"@polkadot/util": "^10.1.14",
|
||||
"@polkadot/x-randomvalues": "^10.1.14",
|
||||
"@types/jest": "^29.2.3",
|
||||
"fflate": "^0.7.4",
|
||||
"override-require": "^1.1.1"
|
||||
"@babel/core": "^7.21.0",
|
||||
"@polkadot/dev": "^0.69.26",
|
||||
"@polkadot/util": "^10.4.2",
|
||||
"@polkadot/x-randomvalues": "^10.4.2",
|
||||
"@types/node": "^18.14.6",
|
||||
"fflate": "^0.7.4"
|
||||
},
|
||||
"resolutions": {
|
||||
"typescript": "^4.9.3"
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -20,14 +20,14 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "6.4.1",
|
||||
"version": "7.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.6"
|
||||
"tslib": "^2.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^10.1.14",
|
||||
"@polkadot/x-randomvalues": "^10.1.14"
|
||||
"@polkadot/util": "^10.4.2",
|
||||
"@polkadot/x-randomvalues": "^10.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// A number of functions are "unsafe" and purposefully so - it is
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './bridge';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2017-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default [];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2017-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-bundle authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-bundle authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitFn, InitPromise, InitResult, WasmBaseInstance, WasmImports } from './types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './index';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2017-2023 @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: '6.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-bridge', path: 'auto', type: 'auto', version: '7.0.1' };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Use non-strong types instead of WasmImports which may not
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-bridge authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-bridge authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { BridgeBase, WasmBaseInstance } from './types';
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "6.4.1",
|
||||
"version": "7.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.6"
|
||||
"tslib": "^2.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^10.1.14"
|
||||
"@polkadot/util": "^10.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { asmJsInit } from './cjs/data.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const data = require('../data');
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare const asmJsInit: null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const asmJsInit = null;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare const asmJsInit: null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export const asmJsInit = null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default [];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './index';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// Copyright 2017-2023 @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: '6.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', path: 'auto', type: 'auto', version: '7.0.1' };
|
||||
|
||||
@@ -20,19 +20,19 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "6.4.1",
|
||||
"version": "7.0.1",
|
||||
"browser": "wasm.js",
|
||||
"main": "wasm.js",
|
||||
"react-native": "asm.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.6",
|
||||
"@polkadot/wasm-bridge": "6.4.1",
|
||||
"@polkadot/wasm-crypto-asmjs": "6.4.1",
|
||||
"@polkadot/wasm-crypto-wasm": "6.4.1"
|
||||
"@polkadot/wasm-bridge": "7.0.1",
|
||||
"@polkadot/wasm-crypto-asmjs": "7.0.1",
|
||||
"@polkadot/wasm-crypto-wasm": "7.0.1",
|
||||
"tslib": "^2.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^10.1.14",
|
||||
"@polkadot/x-randomvalues": "^10.1.14"
|
||||
"@polkadot/util": "^10.4.2",
|
||||
"@polkadot/x-randomvalues": "^10.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2023 @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-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2023 @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-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './wasm';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as bridgeInfo } from '@polkadot/wasm-bridge/packageInfo';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './wasm';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitFn } from '@polkadot/wasm-bridge/types';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2017-2023 @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: '6.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-init', path: 'auto', type: 'auto', version: '7.0.1' };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2023 @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-2022 @polkadot/wasm-crypto-init authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-init authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { InitFn } from '@polkadot/wasm-bridge/types';
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "6.4.1",
|
||||
"version": "7.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.6",
|
||||
"@polkadot/wasm-util": "6.4.1"
|
||||
"@polkadot/wasm-util": "7.0.1",
|
||||
"tslib": "^2.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^10.1.14"
|
||||
"@polkadot/util": "^10.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { base64Decode, unzlibSync } from '@polkadot/wasm-util';
|
||||
@@ -13,7 +13,7 @@ export { packageInfo } from './packageInfo';
|
||||
* The decoded WASM interface as exposed by this package.
|
||||
*
|
||||
* The build process will output into cjs/* into a compressed base64 format.
|
||||
* Upon loading the exposed bytes will be decoded and decompressed form this
|
||||
* Upon loading the exposed bytes will be decoded and decompressed from this
|
||||
* specific format and returned.
|
||||
*/
|
||||
export const wasmBytes = /*#__PURE__*/ unzlibSync(base64Decode(bytes, new Uint8Array(lenIn)), new Uint8Array(lenOut));
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare const bytes: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports.bytes = '';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const bytes = require('../bytes');
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare const bytes: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export const bytes = '';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default [];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './index';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// Copyright 2017-2023 @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: '6.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', path: 'auto', type: 'auto', version: '7.0.1' };
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -28,19 +28,19 @@
|
||||
"./initWasmAsm.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "6.4.1",
|
||||
"version": "7.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.6",
|
||||
"@polkadot/wasm-bridge": "6.4.1",
|
||||
"@polkadot/wasm-crypto-asmjs": "6.4.1",
|
||||
"@polkadot/wasm-crypto-init": "6.4.1",
|
||||
"@polkadot/wasm-crypto-wasm": "6.4.1",
|
||||
"@polkadot/wasm-util": "6.4.1"
|
||||
"@polkadot/wasm-bridge": "7.0.1",
|
||||
"@polkadot/wasm-crypto-asmjs": "7.0.1",
|
||||
"@polkadot/wasm-crypto-init": "7.0.1",
|
||||
"@polkadot/wasm-crypto-wasm": "7.0.1",
|
||||
"@polkadot/wasm-util": "7.0.1",
|
||||
"tslib": "^2.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^10.1.14",
|
||||
"@polkadot/x-randomvalues": "^10.1.14"
|
||||
"@polkadot/util": "^10.4.2",
|
||||
"@polkadot/x-randomvalues": "^10.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { WasmCryptoInstance } from '@polkadot/wasm-crypto-init/types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { packageInfo as bridgeInfo } from '@polkadot/wasm-bridge/packageInfo';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2017-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @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-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @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-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @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-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @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-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @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-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Use `wee_alloc` as the global allocator.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './index';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2017-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2017-2023 @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: '6.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto', path: 'auto', type: 'auto', version: '7.0.1' };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use bip39::{Mnemonic, MnemonicType, Language, Seed};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use blake2_rfc::blake2b::blake2b;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use secp256k1::{ecdsa::{RecoverableSignature, RecoveryId}, Message, PublicKey, SecretKey, SECP256K1};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @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-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Copyright 2019 Paritytech via https://github.com/paritytech/schnorrkel-js/
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const rootIncl = [
|
||||
'@polkadot/wasm-bridge',
|
||||
'@polkadot/wasm-crypto',
|
||||
'@polkadot/wasm-crypto-init',
|
||||
'@polkadot/wasm-crypto-asmjs',
|
||||
'@polkadot/wasm-crypto-wasm',
|
||||
'@polkadot/wasm-util'
|
||||
];
|
||||
|
||||
const detcIncl = [
|
||||
...rootIncl.map((p) => `${p}/initOnlyAsm`),
|
||||
...rootIncl.map((p) => `${p}/cjs/asm`),
|
||||
...rootIncl.map((p) => `${p}/cjs/packageInfo`)
|
||||
];
|
||||
|
||||
require('override-require')(
|
||||
(request) =>
|
||||
rootIncl.some((p) => request.endsWith(p)) ||
|
||||
detcIncl.some((p) => request.endsWith(p)),
|
||||
(request) =>
|
||||
rootIncl.some((p) => request.endsWith(p))
|
||||
? rootIncl.find((p) => request.endsWith(p)) === '@polkadot/wasm-crypto-init'
|
||||
? require('@polkadot/wasm-crypto-init/build/cjs/wasm')
|
||||
: require(`${rootIncl.find((p) => request.endsWith(p))}/build/cjs`)
|
||||
: require(`${detcIncl.find((p) => request.endsWith(p))
|
||||
.replace('/initOnlyAsm', '/build/cjs/initOnlyAsm.js')
|
||||
.replace('/cjs/asm', '/build/cjs/asm.js')
|
||||
.replace('/cjs/packageInfo', '/build/cjs/packageInfo.js')
|
||||
}`)
|
||||
);
|
||||
@@ -1,63 +1,66 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const { assert, u8aToHex } = require('@polkadot/util');
|
||||
import { assert, u8aToHex } from '@polkadot/util';
|
||||
|
||||
function bip39Generate (wasm) {
|
||||
const res = wasm.bip39Generate(21);
|
||||
export function bip39Generate (wasm) {
|
||||
it('generates a bip39 phrase', () => {
|
||||
const res = wasm.bip39Generate(21);
|
||||
|
||||
console.log('\tPHR', res);
|
||||
// console.log('\tPHR', res);
|
||||
|
||||
assert(res.split(' ').length === 21, 'ERROR: Invalid bip39 Phase length');
|
||||
assert(res.split(' ').length === 21, 'ERROR: Invalid bip39 Phase length');
|
||||
});
|
||||
}
|
||||
|
||||
function bip39GenerateSubsequent (wasm) {
|
||||
const val1 = wasm.bip39Generate(24);
|
||||
const val2 = wasm.bip39Generate(24);
|
||||
export function bip39GenerateSubsequent (wasm) {
|
||||
it('generates different subsequent mnemonics', () => {
|
||||
const val1 = wasm.bip39Generate(24);
|
||||
const val2 = wasm.bip39Generate(24);
|
||||
|
||||
console.log('\tVL1', val1);
|
||||
console.log('\tVL2', val2);
|
||||
// console.log('\tVL1', val1);
|
||||
// console.log('\tVL2', val2);
|
||||
|
||||
assert(val1 !== val2, 'ERROR: Subsequent mnemonics are the same');
|
||||
assert(val1 !== val2, 'ERROR: Subsequent mnemonics are the same');
|
||||
});
|
||||
}
|
||||
|
||||
function bip39Validate (wasm) {
|
||||
const res = wasm.bip39Validate(wasm.bip39Generate(12));
|
||||
export function bip39Validate (wasm) {
|
||||
it('validates a created mnemonic', () => {
|
||||
const res = wasm.bip39Validate(wasm.bip39Generate(12));
|
||||
|
||||
console.log('\tVAL', res);
|
||||
// console.log('\tVAL', res);
|
||||
|
||||
assert(res, 'ERROR: Invalid bip39 validation');
|
||||
assert(res, 'ERROR: Invalid bip39 validation');
|
||||
});
|
||||
}
|
||||
|
||||
function bip39ToEntropy (wasm) {
|
||||
const res = u8aToHex(wasm.bip39ToEntropy('legal winner thank year wave sausage worth useful legal winner thank yellow'));
|
||||
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'));
|
||||
|
||||
console.log('\tENT', res);
|
||||
// console.log('\tENT', res);
|
||||
|
||||
assert(res === '0x7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f', 'ERROR: Invalid bip39 entropy');
|
||||
assert(res === '0x7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f', 'ERROR: Invalid bip39 entropy');
|
||||
});
|
||||
}
|
||||
|
||||
function bip39ToMiniSecret (wasm) {
|
||||
const res = u8aToHex(wasm.bip39ToMiniSecret('legal winner thank year wave sausage worth useful legal winner thank yellow', 'Substrate'));
|
||||
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'));
|
||||
|
||||
console.log('\tMIN', res);
|
||||
// console.log('\tMIN', res);
|
||||
|
||||
assert(res === '0x4313249608fe8ac10fd5886c92c4579007272cb77c21551ee5b8d60b78041685', 'ERROR: Invalid bip39 mini secret');
|
||||
assert(res === '0x4313249608fe8ac10fd5886c92c4579007272cb77c21551ee5b8d60b78041685', 'ERROR: Invalid bip39 mini secret');
|
||||
});
|
||||
}
|
||||
|
||||
function bip39ToSeed (wasm) {
|
||||
const res = u8aToHex(wasm.bip39ToSeed('seed sock milk update focus rotate barely fade car face mechanic mercy', ''));
|
||||
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', ''));
|
||||
|
||||
console.log('\tSEE', res);
|
||||
// console.log('\tSEE', res);
|
||||
|
||||
assert(res === '0x3c121e20de068083b49c2315697fb59a2d9e8643c24e5ea7628132c58969a027', 'ERROR: Invalid bip39 mini secret');
|
||||
assert(res === '0x3c121e20de068083b49c2315697fb59a2d9e8643c24e5ea7628132c58969a027', 'ERROR: Invalid bip39 mini secret');
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
bip39Generate,
|
||||
bip39GenerateSubsequent,
|
||||
bip39ToEntropy,
|
||||
bip39ToMiniSecret,
|
||||
bip39ToSeed,
|
||||
bip39Validate
|
||||
};
|
||||
|
||||
@@ -1,58 +1,64 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const crypto = require('crypto');
|
||||
const { assert, hexToU8a, stringToU8a, u8aToHex } = require('@polkadot/util');
|
||||
import crypto from 'crypto';
|
||||
|
||||
import { assert, hexToU8a, stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
/** @internal */
|
||||
function extractKeys (pair) {
|
||||
return [pair, pair.slice(32), pair.slice(0, 32)];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function randomPair (wasm) {
|
||||
return extractKeys(wasm.ed25519KeypairFromSeed(crypto.randomBytes(32)));
|
||||
}
|
||||
|
||||
function ed25519PairFromSeed (wasm) {
|
||||
const [pair, pk, sk] = extractKeys(wasm.ed25519KeypairFromSeed(stringToU8a('12345678901234567890123456789012')));
|
||||
export function ed25519PairFromSeed (wasm) {
|
||||
it('creates a known pair from a known seed', () => {
|
||||
const [pair, pk, sk] = extractKeys(wasm.ed25519KeypairFromSeed(stringToU8a('12345678901234567890123456789012')));
|
||||
|
||||
console.log('\tSEC', u8aToHex(sk));
|
||||
console.log('\tPUB', u8aToHex(pk));
|
||||
// console.log('\tSEC', u8aToHex(sk));
|
||||
// console.log('\tPUB', u8aToHex(pk));
|
||||
|
||||
assert(u8aToHex(pair) === '0x31323334353637383930313233343536373839303132333435363738393031322f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee', 'ERROR: pairFromSeed() does not match');
|
||||
assert(u8aToHex(sk) === '0x3132333435363738393031323334353637383930313233343536373839303132');
|
||||
assert(u8aToHex(pk) === '0x2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee');
|
||||
assert(u8aToHex(pair) === '0x31323334353637383930313233343536373839303132333435363738393031322f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee', 'ERROR: pairFromSeed() does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function ed25519SignAndVerify (wasm) {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
const signature = wasm.ed25519Sign(pk, sk, stringToU8a('this is a message'));
|
||||
const isValid = wasm.ed25519Verify(signature, stringToU8a('this is a message'), pk);
|
||||
|
||||
console.log('\tSIG', u8aToHex(signature));
|
||||
console.log('\tRES', isValid);
|
||||
|
||||
assert(isValid, 'ERROR: Unable to verify signature');
|
||||
}
|
||||
|
||||
function ed25519VerifyExisting (wasm) {
|
||||
const isValid = wasm.ed25519Verify(hexToU8a('0x90588f3f512496f2dd40571d162e8182860081c74e2085316e7c4396918f07da412ee029978e4dd714057fe973bd9e7d645148bf7b66680d67c93227cde95202'), stringToU8a('this is a message'), hexToU8a('0x2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee'));
|
||||
|
||||
console.log('\tRES', isValid);
|
||||
|
||||
assert(isValid, 'ERROR: Unable to verify signature');
|
||||
}
|
||||
|
||||
function ed25519Benchmark (wasm) {
|
||||
const MESSAGE = stringToU8a('this is a message');
|
||||
|
||||
for (let i = 0; i < 256; i++) {
|
||||
export function ed25519SignAndVerify (wasm) {
|
||||
it('signs and verifies', () => {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
const signature = wasm.ed25519Sign(pk, sk, stringToU8a('this is a message'));
|
||||
const isValid = wasm.ed25519Verify(signature, stringToU8a('this is a message'), pk);
|
||||
|
||||
assert(wasm.ed25519Verify(wasm.ed25519Sign(pk, sk, MESSAGE), MESSAGE, pk), 'ERROR: Unable to verify signature');
|
||||
}
|
||||
// console.log('\tSIG', u8aToHex(signature));
|
||||
// console.log('\tRES', isValid);
|
||||
|
||||
assert(isValid, 'ERROR: Unable to verify signature');
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ed25519Benchmark,
|
||||
ed25519PairFromSeed,
|
||||
ed25519SignAndVerify,
|
||||
ed25519VerifyExisting
|
||||
};
|
||||
export function ed25519VerifyExisting (wasm) {
|
||||
it('verifies a known signature', () => {
|
||||
const isValid = wasm.ed25519Verify(hexToU8a('0x90588f3f512496f2dd40571d162e8182860081c74e2085316e7c4396918f07da412ee029978e4dd714057fe973bd9e7d645148bf7b66680d67c93227cde95202'), stringToU8a('this is a message'), hexToU8a('0x2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee'));
|
||||
|
||||
// console.log('\tRES', isValid);
|
||||
|
||||
assert(isValid, 'ERROR: Unable to verify signature');
|
||||
});
|
||||
}
|
||||
|
||||
export function ed25519Benchmark (wasm) {
|
||||
it('runs a verification benchamark', () => {
|
||||
const MESSAGE = stringToU8a('this is a message');
|
||||
|
||||
for (let i = 0; i < 256; i++) {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
|
||||
assert(wasm.ed25519Verify(wasm.ed25519Sign(pk, sk, MESSAGE), MESSAGE, pk), 'ERROR: Unable to verify signature');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,99 +1,106 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const { assert, stringToU8a, u8aToHex } = require('@polkadot/util');
|
||||
import { assert, stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
function blake2bHash (wasm) {
|
||||
const hash = u8aToHex(wasm.blake2b(stringToU8a('abc'), new Uint8Array(), 64));
|
||||
export function blake2bHash (wasm) {
|
||||
it('creates a known blake2b hash', () => {
|
||||
const hash = u8aToHex(wasm.blake2b(stringToU8a('abc'), new Uint8Array(), 64));
|
||||
|
||||
console.log('\tRES', hash);
|
||||
// console.log('\tRES', hash);
|
||||
|
||||
assert(hash === '0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923', 'ERROR: blake2bHash does not match');
|
||||
assert(hash === '0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923', 'ERROR: blake2bHash does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function hmacSha256 (wasm) {
|
||||
const hash = u8aToHex(wasm.hmacSha256(stringToU8a('secret'), stringToU8a('some message')));
|
||||
export function hmacSha256 (wasm) {
|
||||
it('creates a known hmacSha256', () => {
|
||||
const hash = u8aToHex(wasm.hmacSha256(stringToU8a('secret'), stringToU8a('some message')));
|
||||
|
||||
console.log('\tRES', hash);
|
||||
// console.log('\tRES', hash);
|
||||
|
||||
assert(hash === '0xf28a70b41263840e5c059a0a733336e0957efba87902aa8cca11441d4b0c96d7', 'ERROR: hmacSha256 does not match');
|
||||
assert(hash === '0xf28a70b41263840e5c059a0a733336e0957efba87902aa8cca11441d4b0c96d7', 'ERROR: hmacSha256 does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function hmacSha512 (wasm) {
|
||||
const hash = u8aToHex(wasm.hmacSha512(stringToU8a('secret'), stringToU8a('some message')));
|
||||
export function hmacSha512 (wasm) {
|
||||
it('creates a known hmacSha512', () => {
|
||||
const hash = u8aToHex(wasm.hmacSha512(stringToU8a('secret'), stringToU8a('some message')));
|
||||
|
||||
console.log('\tRES', hash);
|
||||
// console.log('\tRES', hash);
|
||||
|
||||
assert(hash === '0x295832e97ed77be75a9fa98029497e4a722c4b9a2f21b39d34f1befa931a39ec520fd24711d6f5c03501384ea66b83066a01a82c57a0460f8cd1f471fcce5841', 'ERROR: hmacSha512 does not match');
|
||||
assert(hash === '0x295832e97ed77be75a9fa98029497e4a722c4b9a2f21b39d34f1befa931a39ec520fd24711d6f5c03501384ea66b83066a01a82c57a0460f8cd1f471fcce5841', 'ERROR: hmacSha512 does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function keccak256 (wasm) {
|
||||
const hash = u8aToHex(wasm.keccak256(stringToU8a('test value')));
|
||||
export function keccak256 (wasm) {
|
||||
it('creates a known keccak256 hash', () => {
|
||||
const hash = u8aToHex(wasm.keccak256(stringToU8a('test value')));
|
||||
|
||||
console.log('\tRES', hash);
|
||||
// console.log('\tRES', hash);
|
||||
|
||||
assert(hash === '0x2d07364b5c231c56ce63d49430e085ea3033c750688ba532b24029124c26ca5e', 'ERROR: keccak256 does not match');
|
||||
assert(hash === '0x2d07364b5c231c56ce63d49430e085ea3033c750688ba532b24029124c26ca5e', 'ERROR: keccak256 does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function keccak512 (wasm) {
|
||||
const hash = u8aToHex(wasm.keccak512(stringToU8a('test')));
|
||||
export function keccak512 (wasm) {
|
||||
it('creates a known keccak512 hash', () => {
|
||||
const hash = u8aToHex(wasm.keccak512(stringToU8a('test')));
|
||||
|
||||
console.log('\tRES', hash);
|
||||
// console.log('\tRES', hash);
|
||||
|
||||
assert(hash === '0x1e2e9fc2002b002d75198b7503210c05a1baac4560916a3c6d93bcce3a50d7f00fd395bf1647b9abb8d1afcc9c76c289b0c9383ba386a956da4b38934417789e', 'ERROR: keccak512 does not match');
|
||||
assert(hash === '0x1e2e9fc2002b002d75198b7503210c05a1baac4560916a3c6d93bcce3a50d7f00fd395bf1647b9abb8d1afcc9c76c289b0c9383ba386a956da4b38934417789e', 'ERROR: keccak512 does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function pbkdf2Hash (wasm) {
|
||||
const hash = u8aToHex(wasm.pbkdf2(stringToU8a('hello world'), stringToU8a('this is a salt'), 2048));
|
||||
export function pbkdf2Hash (wasm) {
|
||||
it('creates a known pbkdf2 hash', () => {
|
||||
const hash = u8aToHex(wasm.pbkdf2(stringToU8a('hello world'), stringToU8a('this is a salt'), 2048));
|
||||
|
||||
console.log('\tRES', hash);
|
||||
// console.log('\tRES', hash);
|
||||
|
||||
assert(hash === '0x5fcbe04f05300a3ecc5c35d18ea0b78f3f6853d2ae5f3fca374f69a7d1f78b5def5c60dae1a568026c7492511e0c53521e8bb6e03a650e1263265fee92722270', 'ERROR: pbkdf2Hash does not match');
|
||||
assert(hash === '0x5fcbe04f05300a3ecc5c35d18ea0b78f3f6853d2ae5f3fca374f69a7d1f78b5def5c60dae1a568026c7492511e0c53521e8bb6e03a650e1263265fee92722270', 'ERROR: pbkdf2Hash does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function scryptHash (wasm) {
|
||||
const hash = u8aToHex(wasm.scrypt(stringToU8a('password'), stringToU8a('salt'), 14, 8, 1));
|
||||
export function scryptHash (wasm) {
|
||||
it('creates a known scrypt hash', () => {
|
||||
const hash = u8aToHex(wasm.scrypt(stringToU8a('password'), stringToU8a('salt'), 14, 8, 1));
|
||||
|
||||
console.log('\tRES', hash);
|
||||
// console.log('\tRES', hash);
|
||||
|
||||
assert(hash === '0x745731af4484f323968969eda289aeee005b5903ac561e64a5aca121797bf7734ef9fd58422e2e22183bcacba9ec87ba0c83b7a2e788f03ce0da06463433cda6', 'ERROR: scryptHash does not match');
|
||||
assert(hash === '0x745731af4484f323968969eda289aeee005b5903ac561e64a5aca121797bf7734ef9fd58422e2e22183bcacba9ec87ba0c83b7a2e788f03ce0da06463433cda6', 'ERROR: scryptHash does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function sha256Hash (wasm) {
|
||||
const hash = u8aToHex(wasm.sha256(stringToU8a('hello world')));
|
||||
export function sha256Hash (wasm) {
|
||||
it('creates a known sha256 hash', () => {
|
||||
const hash = u8aToHex(wasm.sha256(stringToU8a('hello world')));
|
||||
|
||||
console.log('\tRES', hash);
|
||||
// console.log('\tRES', hash);
|
||||
|
||||
assert(hash === '0xb94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9', 'ERROR: sha256Hash does not match');
|
||||
assert(hash === '0xb94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9', 'ERROR: sha256Hash does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function sha512Hash (wasm) {
|
||||
const hash = u8aToHex(wasm.sha512(stringToU8a('hello world')));
|
||||
export function sha512Hash (wasm) {
|
||||
it('creates a known sha512 hash', () => {
|
||||
const hash = u8aToHex(wasm.sha512(stringToU8a('hello world')));
|
||||
|
||||
console.log('\tRES', hash);
|
||||
// console.log('\tRES', hash);
|
||||
|
||||
assert(hash === '0x309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f', 'ERROR: sha512Hash does not match');
|
||||
assert(hash === '0x309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f', 'ERROR: sha512Hash does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function twoxHash (wasm) {
|
||||
const hash64 = u8aToHex(wasm.twox(stringToU8a('abc'), 1));
|
||||
const hash256 = u8aToHex(wasm.twox(stringToU8a('abc'), 4));
|
||||
export function twoxHash (wasm) {
|
||||
it('creates a known twox hash', () => {
|
||||
const hash64 = u8aToHex(wasm.twox(stringToU8a('abc'), 1));
|
||||
const hash256 = u8aToHex(wasm.twox(stringToU8a('abc'), 4));
|
||||
|
||||
console.log('\t64 ', hash64);
|
||||
console.log('\t256', hash256);
|
||||
// console.log('\t64 ', hash64);
|
||||
// console.log('\t256', hash256);
|
||||
|
||||
assert(hash64 === '0x990977adf52cbc44' && hash256 === '0x990977adf52cbc440889329981caa9bef7da5770b2b8a05303b75d95360dd62b', 'ERROR: twoxHash does not match');
|
||||
assert(hash64 === '0x990977adf52cbc44' && hash256 === '0x990977adf52cbc440889329981caa9bef7da5770b2b8a05303b75d95360dd62b', 'ERROR: twoxHash does not match');
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
blake2bHash,
|
||||
hmacSha256,
|
||||
hmacSha512,
|
||||
keccak256,
|
||||
keccak512,
|
||||
pbkdf2Hash,
|
||||
scryptHash,
|
||||
sha256Hash,
|
||||
sha512Hash,
|
||||
twoxHash
|
||||
};
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const { assert } = require('@polkadot/util');
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
const bip39 = require('./bip39.js');
|
||||
const ed25519 = require('./ed25519.js');
|
||||
const hashing = require('./hashing.js');
|
||||
const secp256k1 = require('./secp256k1.js');
|
||||
const sr25519 = require('./sr25519.js');
|
||||
const vrf = require('./vrf.js');
|
||||
import * as bip39 from './bip39.js';
|
||||
import * as ed25519 from './ed25519.js';
|
||||
import * as hashing from './hashing.js';
|
||||
import * as secp256k1 from './secp256k1.js';
|
||||
import * as sr25519 from './sr25519.js';
|
||||
import * as vrf from './vrf.js';
|
||||
|
||||
const tests = {
|
||||
export const tests = {
|
||||
// We place secp256k1 first, this allows the interaction with it in the
|
||||
// hashing (specifically scrypt) test not be an issue (ASM.js only)
|
||||
// https://github.com/polkadot-js/wasm/issues/307
|
||||
...secp256k1,
|
||||
...ed25519,
|
||||
...sr25519,
|
||||
...vrf,
|
||||
...bip39,
|
||||
...hashing
|
||||
secp256k1,
|
||||
// eslint-disable-next-line sort-keys
|
||||
bip39,
|
||||
ed25519,
|
||||
hashing,
|
||||
sr25519,
|
||||
vrf
|
||||
};
|
||||
|
||||
async function beforeAll (name, wasm) {
|
||||
export async function initRun (name, wasm) {
|
||||
const result = await wasm.waitReady();
|
||||
|
||||
console.log(`*** waitReady()=${result} for ${wasm.bridge.type}`);
|
||||
@@ -32,31 +33,37 @@ async function beforeAll (name, wasm) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function runAll (name, wasm) {
|
||||
export function runAll (name, wasm) {
|
||||
const failed = [];
|
||||
let count = 0;
|
||||
|
||||
Object
|
||||
.entries(tests)
|
||||
.forEach(([name, test]) => {
|
||||
const timerId = `\t${name}`;
|
||||
.forEach(([describeName, tests]) => {
|
||||
describe(describeName, () => {
|
||||
Object
|
||||
.entries(tests)
|
||||
.forEach(([name, test]) => {
|
||||
const timerId = `\t${name}`;
|
||||
|
||||
count++;
|
||||
count++;
|
||||
|
||||
try {
|
||||
console.time(timerId);
|
||||
console.log();
|
||||
console.log(timerId);
|
||||
try {
|
||||
console.time(timerId);
|
||||
console.log();
|
||||
// console.log(timerId);
|
||||
|
||||
test(wasm);
|
||||
test(wasm);
|
||||
|
||||
console.timeEnd(timerId);
|
||||
} catch (error) {
|
||||
console.error();
|
||||
console.error(error);
|
||||
console.timeEnd(timerId);
|
||||
} catch (error) {
|
||||
console.error();
|
||||
console.error(error);
|
||||
|
||||
failed.push(name);
|
||||
}
|
||||
failed.push(name);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (failed.length) {
|
||||
@@ -64,24 +71,38 @@ function runAll (name, wasm) {
|
||||
}
|
||||
}
|
||||
|
||||
function runUnassisted (name, wasm) {
|
||||
console.log(`\n*** ${name}: Running tests`);
|
||||
export function runUnassisted (type, wasm) {
|
||||
console.log(`\n*** ${type}: Running tests`);
|
||||
|
||||
beforeAll(name, wasm)
|
||||
.then(() => runAll(name, wasm))
|
||||
// for these we are pass-through describe and it handlers
|
||||
globalThis.describe = (name, fn) => {
|
||||
console.log('\n', name);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
fn();
|
||||
};
|
||||
|
||||
globalThis.it = (name, fn) => {
|
||||
console.log(`\t${name}`);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
fn();
|
||||
};
|
||||
|
||||
console.time(type);
|
||||
|
||||
initRun(type, wasm)
|
||||
.then(() => {
|
||||
console.log(`\n*** ${name}: All passed`);
|
||||
runAll(type, wasm);
|
||||
console.log(`\n*** ${type}: All passed`);
|
||||
console.timeEnd(type);
|
||||
console.log();
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error.message, '\n');
|
||||
console.error(`\n*** ${type}: FAILED:`, error.message, '\n');
|
||||
console.timeEnd(type);
|
||||
console.log();
|
||||
process.exit(-1);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
beforeAll,
|
||||
runAll,
|
||||
runUnassisted,
|
||||
tests
|
||||
};
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{ "type": "commonjs" }
|
||||
@@ -1,82 +1,85 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const { assert, hexToU8a, u8aToHex } = require('@polkadot/util');
|
||||
import { assert, hexToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
function secp256k1Compress (wasm) {
|
||||
const pubkey = '0x04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af';
|
||||
const result = u8aToHex(wasm.secp256k1Compress(hexToU8a(pubkey)));
|
||||
export function secp256k1Compress (wasm) {
|
||||
it('compresses a known publicKey', () => {
|
||||
const pubkey = '0x04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af';
|
||||
const result = u8aToHex(wasm.secp256k1Compress(hexToU8a(pubkey)));
|
||||
|
||||
console.log('\tRES', result);
|
||||
// console.log('\tRES', result);
|
||||
|
||||
assert(result === '0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077', 'ERROR: secp256k1Compress does not match');
|
||||
assert(result === '0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077', 'ERROR: secp256k1Compress does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function secp256k1Expand (wasm) {
|
||||
const pubkey = '0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077';
|
||||
const result = u8aToHex(wasm.secp256k1Expand(hexToU8a(pubkey)));
|
||||
export function secp256k1Expand (wasm) {
|
||||
it('expands a known compressed key', () => {
|
||||
const pubkey = '0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077';
|
||||
const result = u8aToHex(wasm.secp256k1Expand(hexToU8a(pubkey)));
|
||||
|
||||
console.log('\tRES', result);
|
||||
// console.log('\tRES', result);
|
||||
|
||||
assert(result === '0x04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af', 'ERROR: secp256k1Expand does not match');
|
||||
assert(result === '0x04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af', 'ERROR: secp256k1Expand does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function secp256k1FromSeed1 (wasm) {
|
||||
const seckey = '0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae';
|
||||
const result = u8aToHex(wasm.secp256k1FromSeed(hexToU8a(seckey)));
|
||||
export function secp256k1FromSeed1 (wasm) {
|
||||
it('creates a known pair from seed (1)', () => {
|
||||
const seckey = '0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae';
|
||||
const result = u8aToHex(wasm.secp256k1FromSeed(hexToU8a(seckey)));
|
||||
|
||||
console.log('\tRES', result);
|
||||
// console.log('\tRES', result);
|
||||
|
||||
assert(result === '0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae03fd8c74f795ced92064b86191cb2772b1e3a0947740aa0a5a6e379592471fd85b', 'ERROR: secp256k1FromSeed does not match');
|
||||
assert(result === '0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae03fd8c74f795ced92064b86191cb2772b1e3a0947740aa0a5a6e379592471fd85b', 'ERROR: secp256k1FromSeed does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function secp256k1FromSeed2 (wasm) {
|
||||
// https://github.com/polkadot-js/wasm/issues/307
|
||||
const seckey = new Uint8Array([
|
||||
203, 109, 249, 222, 30, 252, 167, 163, 153, 138, 142,
|
||||
173, 78, 2, 21, 157, 95, 169, 156, 62, 13, 79,
|
||||
214, 67, 38, 103, 57, 11, 180, 114, 104, 84
|
||||
]);
|
||||
const expected = u8aToHex(new Uint8Array([
|
||||
203, 109, 249, 222, 30, 252, 167, 163, 153, 138, 142,
|
||||
173, 78, 2, 21, 157, 95, 169, 156, 62, 13, 79,
|
||||
214, 67, 38, 103, 57, 11, 180, 114, 104, 84, 2,
|
||||
10, 16, 145, 52, 31, 229, 102, 75, 250, 23, 130,
|
||||
213, 224, 71, 121, 104, 144, 104, 201, 22, 176, 76,
|
||||
179, 101, 236, 49, 83, 117, 86, 132, 217, 161
|
||||
]));
|
||||
const result = u8aToHex(wasm.secp256k1FromSeed(seckey));
|
||||
export function secp256k1FromSeed2 (wasm) {
|
||||
it('creates a known pair from seed (2)', () => {
|
||||
// https://github.com/polkadot-js/wasm/issues/307
|
||||
const seckey = new Uint8Array([
|
||||
203, 109, 249, 222, 30, 252, 167, 163, 153, 138, 142,
|
||||
173, 78, 2, 21, 157, 95, 169, 156, 62, 13, 79,
|
||||
214, 67, 38, 103, 57, 11, 180, 114, 104, 84
|
||||
]);
|
||||
const expected = u8aToHex(new Uint8Array([
|
||||
203, 109, 249, 222, 30, 252, 167, 163, 153, 138, 142,
|
||||
173, 78, 2, 21, 157, 95, 169, 156, 62, 13, 79,
|
||||
214, 67, 38, 103, 57, 11, 180, 114, 104, 84, 2,
|
||||
10, 16, 145, 52, 31, 229, 102, 75, 250, 23, 130,
|
||||
213, 224, 71, 121, 104, 144, 104, 201, 22, 176, 76,
|
||||
179, 101, 236, 49, 83, 117, 86, 132, 217, 161
|
||||
]));
|
||||
const result = u8aToHex(wasm.secp256k1FromSeed(seckey));
|
||||
|
||||
console.log('\tRES', result);
|
||||
// console.log('\tRES', result);
|
||||
|
||||
assert(result === expected, 'ERROR: secp256k1FromSeed does not match');
|
||||
assert(result === expected, 'ERROR: secp256k1FromSeed does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function secp256k1Recover (wasm) {
|
||||
const sig = '0x7505f2880114da51b3f5d535f8687953c0ab9af4ab81e592eaebebf53b728d2b6dfd9b5bcd70fee412b1f31360e7c2774009305cb84fc50c1d0ff8034dfa5fff';
|
||||
const msg = '0xa30b64ce1eedf409c8afb801d72c05234e64849ea538c15dd3c8cf4ffcf166c9';
|
||||
const result = u8aToHex(wasm.secp256k1Recover(hexToU8a(msg), hexToU8a(sig), 0));
|
||||
export function secp256k1Recover (wasm) {
|
||||
it('recovers a publicKey from signature', () => {
|
||||
const sig = '0x7505f2880114da51b3f5d535f8687953c0ab9af4ab81e592eaebebf53b728d2b6dfd9b5bcd70fee412b1f31360e7c2774009305cb84fc50c1d0ff8034dfa5fff';
|
||||
const msg = '0xa30b64ce1eedf409c8afb801d72c05234e64849ea538c15dd3c8cf4ffcf166c9';
|
||||
const result = u8aToHex(wasm.secp256k1Recover(hexToU8a(msg), hexToU8a(sig), 0));
|
||||
|
||||
console.log('\tRES', result);
|
||||
// console.log('\tRES', result);
|
||||
|
||||
assert(result === '0x028d13da15a02f3a70677339d51b14177ee9b49657662b35e56a9d9dee17db1d30', 'ERROR: secp256k1Recover does not match');
|
||||
assert(result === '0x028d13da15a02f3a70677339d51b14177ee9b49657662b35e56a9d9dee17db1d30', 'ERROR: secp256k1Recover does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function secp256k1Sign (wasm) {
|
||||
const sec = '0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae';
|
||||
const msg = '0x68c731589a583d08b70861683b59ce3dd56284cb2f0da5b6cd83e6641dac3aab';
|
||||
const result = u8aToHex(wasm.secp256k1Sign(hexToU8a(msg), hexToU8a(sec)));
|
||||
export function secp256k1Sign (wasm) {
|
||||
it('creates a known signature', () => {
|
||||
const sec = '0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae';
|
||||
const msg = '0x68c731589a583d08b70861683b59ce3dd56284cb2f0da5b6cd83e6641dac3aab';
|
||||
const result = u8aToHex(wasm.secp256k1Sign(hexToU8a(msg), hexToU8a(sec)));
|
||||
|
||||
console.log('\tRES', result);
|
||||
// console.log('\tRES', result);
|
||||
|
||||
assert(result === '0xdf92f73d9f060cefacf187b5414491cb992998ace017fa48839b5cda3e264ba83b105adec9e9872647a7d8bb28855b45e22805aea3d097953cbb1391f671d13e01', 'ERROR: secp256k1Sign does not match');
|
||||
assert(result === '0xdf92f73d9f060cefacf187b5414491cb992998ace017fa48839b5cda3e264ba83b105adec9e9872647a7d8bb28855b45e22805aea3d097953cbb1391f671d13e01', 'ERROR: secp256k1Sign does not match');
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
secp256k1Compress,
|
||||
secp256k1Expand,
|
||||
secp256k1FromSeed1,
|
||||
secp256k1FromSeed2,
|
||||
secp256k1Recover,
|
||||
secp256k1Sign
|
||||
};
|
||||
|
||||
@@ -1,151 +1,167 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const crypto = require('crypto');
|
||||
const { assert, hexToU8a, stringToU8a, u8aToHex } = require('@polkadot/util');
|
||||
import crypto from 'crypto';
|
||||
|
||||
import { assert, hexToU8a, stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
/** @internal */
|
||||
function extractKeys (pair) {
|
||||
return [pair, pair.slice(64), pair.slice(0, 64)];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function randomPair (wasm) {
|
||||
return extractKeys(wasm.sr25519KeypairFromSeed(crypto.randomBytes(32)));
|
||||
}
|
||||
|
||||
function sr25519PairFromSeed (wasm) {
|
||||
const pair = wasm.sr25519KeypairFromSeed(stringToU8a('12345678901234567890123456789012'));
|
||||
export function sr25519PairFromSeed (wasm) {
|
||||
it('creates a known pair from a known seed', () => {
|
||||
const pair = wasm.sr25519KeypairFromSeed(stringToU8a('12345678901234567890123456789012'));
|
||||
|
||||
console.log('\tSEC', u8aToHex(pair.slice(0, 64)));
|
||||
console.log('\tPUB', u8aToHex(pair.slice(64)));
|
||||
// console.log('\tSEC', u8aToHex(pair.slice(0, 64)));
|
||||
// console.log('\tPUB', u8aToHex(pair.slice(64)));
|
||||
|
||||
assert(u8aToHex(pair) === '0xf0106660c3dda23f16daa9ac5b811b963077f5bc0af89f85804f0de8e424f050f98d66f39442506ff947fd911f18c7a7a5da639a63e8d3b4e233f74143d951c1741c08a06f41c596608f6774259bd9043304adfa5d3eea62760bd9be97634d63', 'ERROR: pairFromSeed() does not match');
|
||||
assert(u8aToHex(pair) === '0xf0106660c3dda23f16daa9ac5b811b963077f5bc0af89f85804f0de8e424f050f98d66f39442506ff947fd911f18c7a7a5da639a63e8d3b4e233f74143d951c1741c08a06f41c596608f6774259bd9043304adfa5d3eea62760bd9be97634d63', 'ERROR: pairFromSeed() does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function sr25519DevFromSeed (wasm) {
|
||||
const pair = wasm.sr25519KeypairFromSeed(hexToU8a('0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e'));
|
||||
export function sr25519DevFromSeed (wasm) {
|
||||
it('creates a known development pair', () => {
|
||||
const pair = wasm.sr25519KeypairFromSeed(hexToU8a('0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e'));
|
||||
|
||||
console.log('\tSEC', u8aToHex(pair.slice(0, 64)));
|
||||
console.log('\tPUB', u8aToHex(pair.slice(64)));
|
||||
// console.log('\tSEC', u8aToHex(pair.slice(0, 64)));
|
||||
// console.log('\tPUB', u8aToHex(pair.slice(64)));
|
||||
|
||||
assert(u8aToHex(pair) === '0x28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca3446ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a', 'ERROR: devFromSeed() does not match');
|
||||
assert(u8aToHex(pair) === '0x28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca3446ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a', 'ERROR: devFromSeed() does not match');
|
||||
});
|
||||
}
|
||||
|
||||
function sr25519VerifyExisting (wasm) {
|
||||
const PK = hexToU8a('0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d');
|
||||
const MESSAGE = stringToU8a('I hereby verify that I control 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
|
||||
const SIGNATURE = hexToU8a('0xb83881d3bd7302981ee1c504fe5b7b394682927131fc0846fd616bb40fa14d02640fd2aca785b4cb57904765c2e4e75f59a7dd30154c209964369912091f6981');
|
||||
export function sr25519VerifyExisting (wasm) {
|
||||
it('verifies a known signature', () => {
|
||||
const PK = hexToU8a('0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d');
|
||||
const MESSAGE = stringToU8a('I hereby verify that I control 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY');
|
||||
const SIGNATURE = hexToU8a('0xb83881d3bd7302981ee1c504fe5b7b394682927131fc0846fd616bb40fa14d02640fd2aca785b4cb57904765c2e4e75f59a7dd30154c209964369912091f6981');
|
||||
|
||||
const isValid = wasm.sr25519Verify(SIGNATURE, MESSAGE, PK);
|
||||
const isValid = wasm.sr25519Verify(SIGNATURE, MESSAGE, PK);
|
||||
|
||||
console.log('\tRES', isValid);
|
||||
// console.log('\tRES', isValid);
|
||||
|
||||
assert(isValid, 'ERROR: Unable to verify signature');
|
||||
assert(isValid, 'ERROR: Unable to verify signature');
|
||||
});
|
||||
}
|
||||
|
||||
function sr25519SignDeterministic (wasm) {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
const sig1 = u8aToHex(wasm.sr25519Sign(pk, sk, stringToU8a('this is a message')));
|
||||
const sig2 = u8aToHex(wasm.sr25519Sign(pk, sk, stringToU8a('this is a message')));
|
||||
|
||||
console.log('\tSG1', sig1);
|
||||
console.log('\tSG2', sig2);
|
||||
|
||||
assert(sig1 !== sig2, 'ERROR: Signatures are deterministic');
|
||||
}
|
||||
|
||||
function sr25519SignAndVerify (wasm) {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
const signature = wasm.sr25519Sign(pk, sk, stringToU8a('this is a message'));
|
||||
const isValid = wasm.sr25519Verify(signature, stringToU8a('this is a message'), pk);
|
||||
|
||||
console.log('\tSIG', u8aToHex(signature));
|
||||
console.log('\tRES', isValid);
|
||||
|
||||
assert(isValid, 'ERROR: Unable to verify signature');
|
||||
}
|
||||
|
||||
function sr25519DeriveHard (wasm) {
|
||||
const [pair] = randomPair(wasm);
|
||||
const derived = wasm.sr25519DeriveKeypairHard(pair, hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000'));
|
||||
|
||||
console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
|
||||
console.log('\tPUB', u8aToHex(derived.slice(64)));
|
||||
}
|
||||
|
||||
function sr25519DeriveHardKnown (wasm) {
|
||||
const derived = wasm.sr25519DeriveKeypairHard(hexToU8a('0x28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca3446ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'), hexToU8a('0x14416c6963650000000000000000000000000000000000000000000000000000'));
|
||||
const publicKey = u8aToHex(derived.slice(64));
|
||||
|
||||
console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
|
||||
console.log('\tPUB', publicKey);
|
||||
|
||||
assert(publicKey === '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d', 'Unmatched resulting public keys');
|
||||
}
|
||||
|
||||
function sr25519DeriveSoft (wasm) {
|
||||
const [pair] = randomPair(wasm);
|
||||
const derived = wasm.sr25519DeriveKeypairSoft(pair, hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000'));
|
||||
|
||||
console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
|
||||
console.log('\tPUB', u8aToHex(derived.slice(64)));
|
||||
}
|
||||
|
||||
function sr25519DeriveSoftKnown (wasm) {
|
||||
const derived = wasm.sr25519DeriveKeypairSoft(hexToU8a('0x28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca3446ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'), hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000'));
|
||||
const publicKey = u8aToHex(derived.slice(64));
|
||||
|
||||
console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
|
||||
console.log('\tPUB', publicKey);
|
||||
|
||||
assert(publicKey === '0x40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a', 'Unmatched resulting public keys');
|
||||
}
|
||||
|
||||
function sr25519DeriveSoftPubkey (wasm) {
|
||||
const derived = u8aToHex(wasm.sr25519DerivePublicSoft(hexToU8a('0x46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'), hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000')));
|
||||
|
||||
console.log('\tPUB', derived);
|
||||
|
||||
assert(derived === '0x40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a', 'Unmatched resulting public keys');
|
||||
}
|
||||
|
||||
function sr25519KeyAgreement (wasm) {
|
||||
const pair1 = wasm.sr25519KeypairFromSeed(hexToU8a('0x3b44c558f9a8f3dc9690d53088558c1ba2529b677e316c6054d1852595b004af'));
|
||||
const pair2 = wasm.sr25519KeypairFromSeed(hexToU8a('0x923b80f79c6981fe756272128ec236eb510ae016dd20bdccbd77a9416b7ab94e'));
|
||||
const [, pk1, sk1] = extractKeys(pair1);
|
||||
const [, pk2, sk2] = extractKeys(pair2);
|
||||
|
||||
assert(u8aToHex(wasm.sr25519Agree(pk1, sk2)) === '0xfa7b90001b790fe42ff78b8cd86f6cf7a7c0a70b72f6b4c771b5d67536450222', 'Unmatched agreement keys');
|
||||
assert(u8aToHex(wasm.sr25519Agree(pk2, sk1)) === '0xfa7b90001b790fe42ff78b8cd86f6cf7a7c0a70b72f6b4c771b5d67536450222', 'Unmatched agreement keys');
|
||||
|
||||
for (let i = 0; i < 256; i++) {
|
||||
const [, pk1, sk1] = randomPair(wasm);
|
||||
const [, pk2, sk2] = randomPair(wasm);
|
||||
|
||||
assert(u8aToHex(wasm.sr25519Agree(pk1, sk2)) === u8aToHex(wasm.sr25519Agree(pk2, sk1)), 'Unmatched agreement keys');
|
||||
}
|
||||
}
|
||||
|
||||
function sr25519Benchmark (wasm) {
|
||||
const MESSAGE = stringToU8a('this is a message');
|
||||
|
||||
for (let i = 0; i < 256; i++) {
|
||||
export function sr25519SignDeterministic (wasm) {
|
||||
it('creates non-deterministic signatures', () => {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
const sig1 = u8aToHex(wasm.sr25519Sign(pk, sk, stringToU8a('this is a message')));
|
||||
const sig2 = u8aToHex(wasm.sr25519Sign(pk, sk, stringToU8a('this is a message')));
|
||||
|
||||
assert(wasm.sr25519Verify(wasm.sr25519Sign(pk, sk, MESSAGE), MESSAGE, pk), 'ERROR: Unable to verify signature');
|
||||
}
|
||||
// console.log('\tSG1', sig1);
|
||||
// console.log('\tSG2', sig2);
|
||||
|
||||
assert(sig1 !== sig2, 'ERROR: Signatures are deterministic');
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
sr25519Benchmark,
|
||||
sr25519DeriveHard,
|
||||
sr25519DeriveHardKnown,
|
||||
sr25519DeriveSoft,
|
||||
sr25519DeriveSoftKnown,
|
||||
sr25519DeriveSoftPubkey,
|
||||
sr25519DevFromSeed,
|
||||
sr25519KeyAgreement,
|
||||
sr25519PairFromSeed,
|
||||
sr25519SignAndVerify,
|
||||
sr25519SignDeterministic,
|
||||
sr25519VerifyExisting
|
||||
};
|
||||
export function sr25519SignAndVerify (wasm) {
|
||||
it('verifies a created signature', () => {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
const signature = wasm.sr25519Sign(pk, sk, stringToU8a('this is a message'));
|
||||
const isValid = wasm.sr25519Verify(signature, stringToU8a('this is a message'), pk);
|
||||
|
||||
// console.log('\tSIG', u8aToHex(signature));
|
||||
// console.log('\tRES', isValid);
|
||||
|
||||
assert(isValid, 'ERROR: Unable to verify signature');
|
||||
});
|
||||
}
|
||||
|
||||
export function sr25519DeriveHard (wasm) {
|
||||
it('derives using a hard path', () => {
|
||||
const [pair] = randomPair(wasm);
|
||||
const derived = wasm.sr25519DeriveKeypairHard(pair, hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000'));
|
||||
|
||||
// console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
|
||||
// console.log('\tPUB', u8aToHex(derived.slice(64)));
|
||||
|
||||
assert(derived.length === 96);
|
||||
});
|
||||
}
|
||||
|
||||
export function sr25519DeriveHardKnown (wasm) {
|
||||
it('derives a known hard key', () => {
|
||||
const derived = wasm.sr25519DeriveKeypairHard(hexToU8a('0x28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca3446ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'), hexToU8a('0x14416c6963650000000000000000000000000000000000000000000000000000'));
|
||||
const publicKey = u8aToHex(derived.slice(64));
|
||||
|
||||
// console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
|
||||
// console.log('\tPUB', publicKey);
|
||||
|
||||
assert(publicKey === '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d', 'Unmatched resulting public keys');
|
||||
});
|
||||
}
|
||||
|
||||
export function sr25519DeriveSoft (wasm) {
|
||||
it('derives using a soft path', () => {
|
||||
const [pair] = randomPair(wasm);
|
||||
const derived = wasm.sr25519DeriveKeypairSoft(pair, hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000'));
|
||||
|
||||
// console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
|
||||
// console.log('\tPUB', u8aToHex(derived.slice(64)));
|
||||
|
||||
assert(derived.length === 96);
|
||||
});
|
||||
}
|
||||
|
||||
export function sr25519DeriveSoftKnown (wasm) {
|
||||
it('derives a known soft key', () => {
|
||||
const derived = wasm.sr25519DeriveKeypairSoft(hexToU8a('0x28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca3446ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'), hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000'));
|
||||
const publicKey = u8aToHex(derived.slice(64));
|
||||
|
||||
// console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
|
||||
// console.log('\tPUB', publicKey);
|
||||
|
||||
assert(publicKey === '0x40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a', 'Unmatched resulting public keys');
|
||||
});
|
||||
}
|
||||
|
||||
export function sr25519DeriveSoftPubkey (wasm) {
|
||||
it('derives a known soft publicKey', () => {
|
||||
const derived = u8aToHex(wasm.sr25519DerivePublicSoft(hexToU8a('0x46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'), hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000')));
|
||||
|
||||
// console.log('\tPUB', derived);
|
||||
|
||||
assert(derived === '0x40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a', 'Unmatched resulting public keys');
|
||||
});
|
||||
}
|
||||
|
||||
export function sr25519KeyAgreement (wasm) {
|
||||
it('allows for agreements', () => {
|
||||
const pair1 = wasm.sr25519KeypairFromSeed(hexToU8a('0x3b44c558f9a8f3dc9690d53088558c1ba2529b677e316c6054d1852595b004af'));
|
||||
const pair2 = wasm.sr25519KeypairFromSeed(hexToU8a('0x923b80f79c6981fe756272128ec236eb510ae016dd20bdccbd77a9416b7ab94e'));
|
||||
const [, pk1, sk1] = extractKeys(pair1);
|
||||
const [, pk2, sk2] = extractKeys(pair2);
|
||||
|
||||
assert(u8aToHex(wasm.sr25519Agree(pk1, sk2)) === '0xfa7b90001b790fe42ff78b8cd86f6cf7a7c0a70b72f6b4c771b5d67536450222', 'Unmatched agreement keys');
|
||||
assert(u8aToHex(wasm.sr25519Agree(pk2, sk1)) === '0xfa7b90001b790fe42ff78b8cd86f6cf7a7c0a70b72f6b4c771b5d67536450222', 'Unmatched agreement keys');
|
||||
|
||||
for (let i = 0; i < 256; i++) {
|
||||
const [, pk1, sk1] = randomPair(wasm);
|
||||
const [, pk2, sk2] = randomPair(wasm);
|
||||
|
||||
assert(u8aToHex(wasm.sr25519Agree(pk1, sk2)) === u8aToHex(wasm.sr25519Agree(pk2, sk1)), 'Unmatched agreement keys');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function sr25519Benchmark (wasm) {
|
||||
it('runs a verification benchmark', () => {
|
||||
const MESSAGE = stringToU8a('this is a message');
|
||||
|
||||
for (let i = 0; i < 256; i++) {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
|
||||
assert(wasm.sr25519Verify(wasm.sr25519Sign(pk, sk, MESSAGE), MESSAGE, pk), 'ERROR: Unable to verify signature');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const crypto = require('crypto');
|
||||
const { assert, stringToU8a, u8aToHex } = require('@polkadot/util');
|
||||
import crypto from 'crypto';
|
||||
|
||||
import { assert, stringToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
function extractKeys (pair) {
|
||||
return [pair, pair.slice(64), pair.slice(0, 64)];
|
||||
@@ -12,43 +13,43 @@ function randomPair (wasm) {
|
||||
return extractKeys(wasm.sr25519KeypairFromSeed(crypto.randomBytes(32)));
|
||||
}
|
||||
|
||||
function vrfSignAndVerifyCompat (wasm) {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
const outAndProof = wasm.vrfSign(sk, stringToU8a('my VRF context'), stringToU8a('this is a message'), new Uint8Array());
|
||||
const isValid = wasm.vrfVerify(pk, stringToU8a('my VRF context'), stringToU8a('this is a message'), new Uint8Array(), outAndProof);
|
||||
export function vrfSignAndVerifyCompat (wasm) {
|
||||
it('can sign and verify (1)', () => {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
const outAndProof = wasm.vrfSign(sk, stringToU8a('my VRF context'), stringToU8a('this is a message'), new Uint8Array());
|
||||
const isValid = wasm.vrfVerify(pk, stringToU8a('my VRF context'), stringToU8a('this is a message'), new Uint8Array(), outAndProof);
|
||||
|
||||
console.log('\tVRF', u8aToHex(outAndProof));
|
||||
console.log('\tRES', isValid);
|
||||
// console.log('\tVRF', u8aToHex(outAndProof));
|
||||
// console.log('\tRES', isValid);
|
||||
|
||||
assert(isValid, 'ERROR: Unable to verify VRF output & proof');
|
||||
assert(isValid, 'ERROR: Unable to verify VRF output & proof');
|
||||
});
|
||||
}
|
||||
|
||||
function vrfSignAndVerify (wasm) {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
const outAndProof = wasm.vrfSign(sk, stringToU8a('my VRF context'), stringToU8a('this is a message'), stringToU8a('extra param'));
|
||||
const isValid = wasm.vrfVerify(pk, stringToU8a('my VRF context'), stringToU8a('this is a message'), stringToU8a('extra param'), outAndProof);
|
||||
export function vrfSignAndVerify (wasm) {
|
||||
it('can sign and verify (2)', () => {
|
||||
const [, pk, sk] = randomPair(wasm);
|
||||
const outAndProof = wasm.vrfSign(sk, stringToU8a('my VRF context'), stringToU8a('this is a message'), stringToU8a('extra param'));
|
||||
const isValid = wasm.vrfVerify(pk, stringToU8a('my VRF context'), stringToU8a('this is a message'), stringToU8a('extra param'), outAndProof);
|
||||
|
||||
console.log('\tVRF', u8aToHex(outAndProof));
|
||||
console.log('\tRES', isValid);
|
||||
// console.log('\tVRF', u8aToHex(outAndProof));
|
||||
// console.log('\tRES', isValid);
|
||||
|
||||
assert(isValid, 'ERROR: Unable to verify VRF extra output & proof');
|
||||
assert(isValid, 'ERROR: Unable to verify VRF extra output & proof');
|
||||
});
|
||||
}
|
||||
|
||||
function vrfSignAndVerifyDeterministic (wasm) {
|
||||
const [,, sk] = randomPair(wasm);
|
||||
const outAndProof1 = wasm.vrfSign(sk, stringToU8a('my VRF context'), stringToU8a('this is a message'), stringToU8a('extra param'));
|
||||
const outAndProof2 = wasm.vrfSign(sk, stringToU8a('my VRF context'), stringToU8a('this is a message'), stringToU8a('extra param'));
|
||||
const sig1 = u8aToHex(outAndProof1.slice(0, 32));
|
||||
const sig2 = u8aToHex(outAndProof2.slice(0, 32));
|
||||
export function vrfSignAndVerifyDeterministic (wasm) {
|
||||
it('has non-deterministic outputs', () => {
|
||||
const [,, sk] = randomPair(wasm);
|
||||
const outAndProof1 = wasm.vrfSign(sk, stringToU8a('my VRF context'), stringToU8a('this is a message'), stringToU8a('extra param'));
|
||||
const outAndProof2 = wasm.vrfSign(sk, stringToU8a('my VRF context'), stringToU8a('this is a message'), stringToU8a('extra param'));
|
||||
const sig1 = u8aToHex(outAndProof1.slice(0, 32));
|
||||
const sig2 = u8aToHex(outAndProof2.slice(0, 32));
|
||||
|
||||
console.log('\tSG1', sig1);
|
||||
console.log('\tSG2', sig2);
|
||||
// console.log('\tSG1', sig1);
|
||||
// console.log('\tSG2', sig2);
|
||||
|
||||
assert(sig1 === sig2, 'ERROR: VRF extra outputs are non-deterministic');
|
||||
assert(sig1 === sig2, 'ERROR: VRF extra outputs are non-deterministic');
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
vrfSignAndVerify,
|
||||
vrfSignAndVerifyCompat,
|
||||
vrfSignAndVerifyDeterministic
|
||||
};
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
require('./alias-imports.cjs');
|
||||
require('@polkadot/wasm-crypto/initOnlyAsm');
|
||||
|
||||
const wasm = require('../build');
|
||||
const { runUnassisted } = require('./all/index.js');
|
||||
|
||||
runUnassisted('ASM', wasm);
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import '@polkadot/wasm-crypto/initOnlyAsm';
|
||||
|
||||
import * as wasm from '@polkadot/wasm-crypto';
|
||||
|
||||
import { runUnassisted } from './all/index.js';
|
||||
|
||||
runUnassisted('ASM', wasm);
|
||||
@@ -1,23 +1,25 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { createRequire } from 'https://deno.land/std@0.107.0/node/module.ts';
|
||||
|
||||
import * as wasm from '../build-deno/mod.ts';
|
||||
import { initRun, tests } from './all/index.js';
|
||||
|
||||
declare const globalThis: Record<string, unknown>;
|
||||
declare const globalThis;
|
||||
declare const Deno: {
|
||||
test: (name: string, test: () => unknown) => unknown;
|
||||
}
|
||||
|
||||
// ensure we set require on globalThis, it is used is all/*.js
|
||||
const require = globalThis.require = createRequire(import.meta.url);
|
||||
const { beforeAll, tests } = require('./all/index.js');
|
||||
await initRun('wasm', wasm);
|
||||
|
||||
await beforeAll('wasm', wasm);
|
||||
// We use it to denote the tests
|
||||
globalThis.it = (name: string, fn: () => void) => Deno.test(name, () => fn());
|
||||
|
||||
Object
|
||||
.entries<(wasm: unknown) => void>(tests)
|
||||
.forEach(([name, test]) => {
|
||||
Deno.test(name, () => test(wasm));
|
||||
.entries<{ [key: string]: (wasm: unknown) => void }>(tests)
|
||||
.forEach(([describeName, tests]) => {
|
||||
console.log('***', describeName);
|
||||
|
||||
Object
|
||||
.values(tests)
|
||||
.forEach((test) => test(wasm));
|
||||
});
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
import * as wasm from '../build';
|
||||
import { beforeAll as beforeAllFn, tests } from './all/index.js';
|
||||
|
||||
describe('wasm-crypto', () => {
|
||||
beforeAll(async () => {
|
||||
await beforeAllFn('wasm', wasm);
|
||||
});
|
||||
|
||||
it.each(Object.keys(tests))('%s', (name) =>
|
||||
tests[name](wasm)
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import * as wasm from '../build/index.js';
|
||||
import { initRun, tests } from './all/index.js';
|
||||
|
||||
describe('wasm-crypto', (): void => {
|
||||
beforeAll(() => initRun('wasm', wasm));
|
||||
|
||||
for (const name of Object.keys(tests)) {
|
||||
describe(name, (): void => {
|
||||
Object
|
||||
.values<(wasm: unknown) => void>(tests[name])
|
||||
.forEach((fn) => fn(wasm));
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
// Adjusts the resolver to point to the build output
|
||||
export function resolve (specifier, context, nextResolve) {
|
||||
if (/^@polkadot\/wasm-/.test(specifier)) {
|
||||
const parts = specifier.split(/[\\/]/);
|
||||
|
||||
return {
|
||||
format: 'module',
|
||||
shortCircuit: true,
|
||||
url: pathToFileURL(
|
||||
path.join(
|
||||
process.cwd(),
|
||||
['packages', parts[1], 'build', ...parts.slice(2)]
|
||||
.join('/')
|
||||
.replace(/\/wasm-crypto-init\/build$/, '/wasm-crypto-init/build/wasm.js')
|
||||
.replace(/\/wasm-crypto-init\/build\/asm$/, '/wasm-crypto-init/build/asm.js')
|
||||
.replace(/\/wasm-crypto\/build\/initOnlyAsm$/, '/wasm-crypto/build/initOnlyAsm.js')
|
||||
.replace(/\/build\/packageInfo$/, '/build/packageInfo.js')
|
||||
.replace(/\/build$/, '/build/index.js')
|
||||
)
|
||||
).href
|
||||
};
|
||||
}
|
||||
|
||||
return nextResolve(specifier, context);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
require('./alias-imports.cjs');
|
||||
|
||||
const wasm = require('../build');
|
||||
const { runUnassisted } = require('./all/index.js');
|
||||
|
||||
runUnassisted('WASM', wasm);
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import * as wasm from '@polkadot/wasm-crypto';
|
||||
|
||||
import { runUnassisted } from './all/index.js';
|
||||
|
||||
runUnassisted('WASM', wasm);
|
||||
@@ -20,13 +20,13 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "6.4.1",
|
||||
"version": "7.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.6"
|
||||
"tslib": "^2.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^10.1.14"
|
||||
"@polkadot/util": "^10.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019-2022 @polkadot/wasm-util authors & contributors
|
||||
// Copyright 2019-2023 @polkadot/wasm-util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Use an array for our indexer - this is faster than using map access. In
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user