Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01dfe6e35c | ||
|
|
a5d4c4b43c | ||
|
|
9a5107534d | ||
|
|
d50d04318e | ||
|
|
a0afa3cef6 | ||
|
|
cf20e027af | ||
|
|
b68ab94939 | ||
|
|
af94bc472d | ||
|
|
289b102b38 | ||
|
|
ba6cbc2247 | ||
|
|
379b574b84 | ||
|
|
f1c44a65b1 | ||
|
|
7ddb5ebbe5 | ||
|
|
afd2fe3228 | ||
|
|
292197a3a2 | ||
|
|
8fac7feabd | ||
|
|
ca69955332 | ||
|
|
eacb24a133 | ||
|
|
21b3dbbb94 | ||
|
|
57ff683121 | ||
|
|
8b7e35ad0b | ||
|
|
0732f053b8 | ||
|
|
831a72b519 | ||
|
|
a5dad40521 | ||
|
|
e8263b2597 | ||
|
|
9d6c0afc8e | ||
|
|
6393d078e8 | ||
|
|
c62f6493d9 | ||
|
|
e8737c403e | ||
|
|
f279a89dc7 | ||
|
|
30463cfe75 | ||
|
|
c1405bbe2e | ||
|
|
7d9dafd9e1 | ||
|
|
e0e3634714 | ||
|
|
a5818af5fe | ||
|
|
6ebec52ffc | ||
|
|
ebd96dea49 | ||
|
|
d692383d80 | ||
|
|
cefc8c97ec | ||
|
|
8ce18ff065 | ||
|
|
40a97d2206 | ||
|
|
e111d9e91d | ||
|
|
faf407d62d | ||
|
|
cf5759a324 | ||
|
|
d220a69ab1 | ||
|
|
4d8dde58dc | ||
|
|
c5b98fcd5b | ||
|
|
482576be81 | ||
|
|
fdea2aa4dc | ||
|
|
e4dbdc570d | ||
|
|
7f3146ce64 | ||
|
|
1bf001b2f3 | ||
|
|
2a99496e9a | ||
|
|
59ba89a032 | ||
|
|
be9786fc4c | ||
|
|
629140e6c3 | ||
|
|
5f46f9e698 | ||
|
|
d4daf14c77 | ||
|
|
cfdaab8f86 | ||
|
|
70ca570a66 | ||
|
|
ab7e12a30d | ||
|
|
87a95b9ab2 | ||
|
|
9aff03c5b6 | ||
|
|
adfa4fb099 | ||
|
|
5e8b3c1c24 | ||
|
|
714b9ebf48 | ||
|
|
c93dbd2d2e | ||
|
|
7139f1fe42 | ||
|
|
7e490f1f96 | ||
|
|
b6aa432b26 | ||
|
|
547e31ffef | ||
|
|
092ee15603 | ||
|
|
dd52d5158e | ||
|
|
88d8f79e3c | ||
|
|
3a1a75f99f | ||
|
|
422c23dbbd | ||
|
|
13fd02d455 | ||
|
|
b75e2e4778 | ||
|
|
43222700be | ||
|
|
05abb02b64 | ||
|
|
bf1590ab70 |
+3
-3
@@ -1,7 +1,7 @@
|
||||
4
|
||||
|
||||
5
|
||||
3.2.2
|
||||
3.2.3
|
||||
3.2.4
|
||||
4.0.2
|
||||
|
||||
4.0.2
|
||||
4.1.2
|
||||
@@ -0,0 +1,23 @@
|
||||
name: 'Lock Threads'
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '30 1/2 * * *'
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: dessant/lock-threads@v2
|
||||
with:
|
||||
github-token: ${{ secrets.GH_PAT_BOT }}
|
||||
issue-lock-inactive-days: '7'
|
||||
issue-lock-comment: >
|
||||
This thread has been automatically locked since there has not been
|
||||
any recent activity after it was closed. Please open a new issue
|
||||
if you think you have a related problem or query.
|
||||
pr-lock-inactive-days: '2'
|
||||
pr-lock-comment: >
|
||||
This pull request has been automatically locked since there
|
||||
has not been any recent activity after it was closed.
|
||||
Please open a new issue for related bugs.
|
||||
@@ -6,11 +6,11 @@ on:
|
||||
|
||||
jobs:
|
||||
master:
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]')"
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['build:release']
|
||||
name: ${{ matrix.step }}
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/wasm'"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -26,10 +26,3 @@ jobs:
|
||||
yarn install --immutable | grep -v 'YN0013'
|
||||
./scripts/install-build-deps.sh
|
||||
yarn ${{ matrix.step }}
|
||||
|
||||
dummy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: dummy
|
||||
run: |
|
||||
echo "Dummy skip step"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
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
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: returntocorp/semgrep-action@v1
|
||||
with:
|
||||
auditOn: push
|
||||
publishToken: ${{ secrets.SEMGREP_APP_TOKEN }}
|
||||
publishDeployment: 1395
|
||||
@@ -0,0 +1,17 @@
|
||||
name: 'Close stale issues and PRs'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '30 2/2 * * *'
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
with:
|
||||
repo-token: ${{ secrets.GH_PAT_BOT }}
|
||||
stale-issue-message: 'This issue has been open for 21 days with no activity and is not labelled as an enhancement. It will be closed in 7 days.'
|
||||
stale-issue-label: 'stale'
|
||||
exempt-issue-labels: '-size-l,-size-m,-size-s,-size-xl,-size-xs,[bug]'
|
||||
days-before-stale: 21
|
||||
days-before-close: 7
|
||||
@@ -0,0 +1,4 @@
|
||||
build
|
||||
coverage
|
||||
packages
|
||||
scripts
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = require('@polkadot/dev/config/prettier.cjs');
|
||||
+7
-9
File diff suppressed because one or more lines are too long
+7
-9
File diff suppressed because one or more lines are too long
Vendored
-55
File diff suppressed because one or more lines are too long
+591
File diff suppressed because one or more lines are too long
+1
-1
@@ -10,4 +10,4 @@ plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-2.4.1.cjs
|
||||
yarnPath: .yarn/releases/yarn-3.0.0-rc.2.cjs
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 4.1.2 Jul 9, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Bump `@polkadot/dev` to allow for bundles with new-format
|
||||
|
||||
|
||||
## 4.1.1 Jul 7, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Add an explicit `engines` field to `package.json`
|
||||
- Allow building as a completely stand-alone browser bundle (experimental)
|
||||
|
||||
|
||||
## 4.0.2 Mar 5, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
+6
-5
@@ -7,11 +7,12 @@
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"typescript": "^4.2.2"
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:wasm",
|
||||
"build:release": "polkadot-ci-ghact-build",
|
||||
"build:rollup": "polkadot-exec-rollup --config",
|
||||
"build:wasm": "./scripts/build.sh",
|
||||
"lint": "polkadot-dev-run-lint",
|
||||
"clean": "./scripts/clean.sh",
|
||||
@@ -23,10 +24,10 @@
|
||||
"test:wasm:rust": "cd packages/wasm-crypto && RUST_BACKTRACE=full cargo test --release -- --nocapture"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.13.8",
|
||||
"@polkadot/dev": "^0.62.5",
|
||||
"fflate": "^0.6.7",
|
||||
"@babel/core": "^7.14.6",
|
||||
"@polkadot/dev": "^0.62.55",
|
||||
"fflate": "^0.7.1",
|
||||
"override-require": "^1.1.1"
|
||||
},
|
||||
"version": "4.0.2"
|
||||
"version": "4.1.2"
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
{
|
||||
"name": "@polkadot/wasm-crypto-asmjs",
|
||||
"version": "4.0.2",
|
||||
"version": "4.1.2",
|
||||
"type": "module",
|
||||
"description": "Asm.js content for wasm-crypto",
|
||||
"browser": "empty.js",
|
||||
"main": "empty.js",
|
||||
"react-native": "data.js",
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -14,6 +17,6 @@
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"homepage": "https://github.com/polkadot-js/wasm",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.9"
|
||||
"@babel/runtime": "^7.14.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', version: '4.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', version: '4.1.2' };
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
{
|
||||
"name": "@polkadot/wasm-crypto-wasm",
|
||||
"version": "4.0.2",
|
||||
"version": "4.1.2",
|
||||
"type": "module",
|
||||
"description": "Wasm content for wasm-crypto",
|
||||
"browser": "data.js",
|
||||
"main": "data.js",
|
||||
"react-native": "data.js",
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
@@ -14,6 +17,6 @@
|
||||
"bugs": "https://github.com/polkadot-js/wasm/issues",
|
||||
"homepage": "https://github.com/polkadot-js/wasm",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.9"
|
||||
"@babel/runtime": "^7.14.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ const inflt = (dat: Uint8Array, buf?: Uint8Array, st?: InflateState) => {
|
||||
// length tree distance tree
|
||||
const lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
|
||||
// max length bits
|
||||
lbt = max(lt)
|
||||
lbt = max(lt);
|
||||
// max dist bits
|
||||
dbt = max(dt);
|
||||
lm = hMap(lt, lbt, 1);
|
||||
@@ -321,7 +321,7 @@ const inflt = (dat: Uint8Array, buf?: Uint8Array, st?: InflateState) => {
|
||||
}
|
||||
st.l = lm, st.p = pos, st.b = bt;
|
||||
if (lm) final = 1, st.m = lbt, st.d = dm, st.n = dbt;
|
||||
} while (!final)
|
||||
} while (!final);
|
||||
return bt == buf.length ? buf : slc(buf, 0, bt);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', version: '4.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', version: '4.1.2' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/wasm-crypto",
|
||||
"version": "4.0.2",
|
||||
"version": "4.1.2",
|
||||
"type": "module",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"main": "index.js",
|
||||
@@ -8,14 +8,17 @@
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/wasm-crypto-asmjs": "^4.0.2",
|
||||
"@polkadot/wasm-crypto-wasm": "^4.0.2"
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/wasm-crypto-asmjs": "^4.1.2",
|
||||
"@polkadot/wasm-crypto-wasm": "^4.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^6.0.1-6",
|
||||
"@polkadot/x-randomvalues": "^6.0.1-6"
|
||||
"@polkadot/util": "^6.11.1",
|
||||
"@polkadot/x-randomvalues": "^6.11.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*",
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
// Copyright 2019-2021 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { asmJsInit } from '@polkadot/wasm-crypto-asmjs';
|
||||
import { wasmBytes } from '@polkadot/wasm-crypto-wasm';
|
||||
|
||||
import { allocString, allocU8a, getWasm, initWasm, resultString, resultU8a, withWasm } from './bridge';
|
||||
import * as imports from './imports';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
const wasmPromise = initWasm(wasmBytes, asmJsInit, imports).catch(() => null);
|
||||
|
||||
export const bip39Generate = withWasm((wasm) =>
|
||||
(words: 12 | 15 | 18 | 21 | 24): string => {
|
||||
wasm.ext_bip39_generate(8, words);
|
||||
|
||||
return resultString();
|
||||
}
|
||||
);
|
||||
|
||||
export const bip39ToEntropy = withWasm((wasm) =>
|
||||
(phrase: string): Uint8Array => {
|
||||
const [ptr0, len0] = allocString(phrase);
|
||||
|
||||
wasm.ext_bip39_to_entropy(8, ptr0, len0);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const bip39ToMiniSecret = withWasm((wasm) =>
|
||||
(phrase: string, password: string): Uint8Array => {
|
||||
const [ptr0, len0] = allocString(phrase);
|
||||
const [ptr1, len1] = allocString(password);
|
||||
|
||||
wasm.ext_bip39_to_mini_secret(8, ptr0, len0, ptr1, len1);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const bip39ToSeed = withWasm((wasm) =>
|
||||
(phrase: string, password: string): Uint8Array => {
|
||||
const [ptr0, len0] = allocString(phrase);
|
||||
const [ptr1, len1] = allocString(password);
|
||||
|
||||
wasm.ext_bip39_to_seed(8, ptr0, len0, ptr1, len1);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const bip39Validate = withWasm((wasm) =>
|
||||
(phrase: string): boolean => {
|
||||
const [ptr0, len0] = allocString(phrase);
|
||||
const ret = wasm.ext_bip39_validate(ptr0, len0);
|
||||
|
||||
return ret !== 0;
|
||||
}
|
||||
);
|
||||
|
||||
export const ed25519KeypairFromSeed = withWasm((wasm) =>
|
||||
(seed: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(seed);
|
||||
|
||||
wasm.ext_ed_from_seed(8, ptr0, len0);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const ed25519Sign = withWasm((wasm) =>
|
||||
(pubkey: Uint8Array, seckey: Uint8Array, message: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(pubkey);
|
||||
const [ptr1, len1] = allocU8a(seckey);
|
||||
const [ptr2, len2] = allocU8a(message);
|
||||
|
||||
wasm.ext_ed_sign(8, ptr0, len0, ptr1, len1, ptr2, len2);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const ed25519Verify = withWasm((wasm) =>
|
||||
(signature: Uint8Array, message: Uint8Array, pubkey: Uint8Array): boolean => {
|
||||
const [ptr0, len0] = allocU8a(signature);
|
||||
const [ptr1, len1] = allocU8a(message);
|
||||
const [ptr2, len2] = allocU8a(pubkey);
|
||||
const ret = wasm.ext_ed_verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
||||
|
||||
return ret !== 0;
|
||||
}
|
||||
);
|
||||
|
||||
export const sr25519DeriveKeypairHard = withWasm((wasm) =>
|
||||
(pair: Uint8Array, cc: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(pair);
|
||||
const [ptr1, len1] = allocU8a(cc);
|
||||
|
||||
wasm.ext_sr_derive_keypair_hard(8, ptr0, len0, ptr1, len1);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const sr25519DeriveKeypairSoft = withWasm((wasm) =>
|
||||
(pair: Uint8Array, cc: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(pair);
|
||||
const [ptr1, len1] = allocU8a(cc);
|
||||
|
||||
wasm.ext_sr_derive_keypair_soft(8, ptr0, len0, ptr1, len1);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const sr25519DerivePublicSoft = withWasm((wasm) =>
|
||||
(pubkey: Uint8Array, cc: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(pubkey);
|
||||
const [ptr1, len1] = allocU8a(cc);
|
||||
|
||||
wasm.ext_sr_derive_public_soft(8, ptr0, len0, ptr1, len1);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const sr25519KeypairFromSeed = withWasm((wasm) =>
|
||||
(seed: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(seed);
|
||||
|
||||
wasm.ext_sr_from_seed(8, ptr0, len0);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const sr25519Sign = withWasm((wasm) =>
|
||||
(pubkey: Uint8Array, secret: Uint8Array, message: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(pubkey);
|
||||
const [ptr1, len1] = allocU8a(secret);
|
||||
const [ptr2, len2] = allocU8a(message);
|
||||
|
||||
wasm.ext_sr_sign(8, ptr0, len0, ptr1, len1, ptr2, len2);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const sr25519Verify = withWasm((wasm) =>
|
||||
(signature: Uint8Array, message: Uint8Array, pubkey: Uint8Array): boolean => {
|
||||
const [ptr0, len0] = allocU8a(signature);
|
||||
const [ptr1, len1] = allocU8a(message);
|
||||
const [ptr2, len2] = allocU8a(pubkey);
|
||||
const ret = wasm.ext_sr_verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
||||
|
||||
return ret !== 0;
|
||||
}
|
||||
);
|
||||
|
||||
export const vrfSign = withWasm((wasm) =>
|
||||
(secret: Uint8Array, context: Uint8Array, message: Uint8Array, extra: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(secret);
|
||||
const [ptr1, len1] = allocU8a(context);
|
||||
const [ptr2, len2] = allocU8a(message);
|
||||
const [ptr3, len3] = allocU8a(extra);
|
||||
|
||||
wasm.ext_vrf_sign(8, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const vrfVerify = withWasm((wasm) =>
|
||||
(pubkey: Uint8Array, context: Uint8Array, message: Uint8Array, extra: Uint8Array, outAndProof: Uint8Array): boolean => {
|
||||
const [ptr0, len0] = allocU8a(pubkey);
|
||||
const [ptr1, len1] = allocU8a(context);
|
||||
const [ptr2, len2] = allocU8a(message);
|
||||
const [ptr3, len3] = allocU8a(extra);
|
||||
const [ptr4, len4] = allocU8a(outAndProof);
|
||||
const ret = wasm.ext_vrf_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
||||
|
||||
return ret !== 0;
|
||||
}
|
||||
);
|
||||
|
||||
export const blake2b = withWasm((wasm) =>
|
||||
(data: Uint8Array, key: Uint8Array, size: number): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(data);
|
||||
const [ptr1, len1] = allocU8a(key);
|
||||
|
||||
wasm.ext_blake2b(8, ptr0, len0, ptr1, len1, size);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const keccak256 = withWasm((wasm) =>
|
||||
(data: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(data);
|
||||
|
||||
wasm.ext_keccak256(8, ptr0, len0);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const pbkdf2 = withWasm((wasm) =>
|
||||
(data: Uint8Array, salt: Uint8Array, rounds: number): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(data);
|
||||
const [ptr1, len1] = allocU8a(salt);
|
||||
|
||||
wasm.ext_pbkdf2(8, ptr0, len0, ptr1, len1, rounds);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const scrypt = withWasm((wasm) =>
|
||||
(password: Uint8Array, salt: Uint8Array, log2n: number, r: number, p: number): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(password);
|
||||
const [ptr1, len1] = allocU8a(salt);
|
||||
|
||||
wasm.ext_scrypt(8, ptr0, len0, ptr1, len1, log2n, r, p);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const sha512 = withWasm((wasm) =>
|
||||
(data: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(data);
|
||||
|
||||
wasm.ext_sha512(8, ptr0, len0);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const twox = withWasm((wasm) =>
|
||||
(data: Uint8Array, rounds: number) => {
|
||||
const [ptr0, len0] = allocU8a(data);
|
||||
|
||||
wasm.ext_twox(8, ptr0, len0, rounds);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export function isReady (): boolean {
|
||||
return !!getWasm();
|
||||
}
|
||||
|
||||
export function waitReady (): Promise<boolean> {
|
||||
return wasmPromise.then(() => isReady());
|
||||
}
|
||||
@@ -3,257 +3,4 @@
|
||||
|
||||
import './detectPackage';
|
||||
|
||||
import { asmJsInit } from '@polkadot/wasm-crypto-asmjs';
|
||||
import { wasmBytes } from '@polkadot/wasm-crypto-wasm';
|
||||
|
||||
import { allocString, allocU8a, getWasm, initWasm, resultString, resultU8a, withWasm } from './bridge';
|
||||
import * as imports from './imports';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
const wasmPromise = initWasm(wasmBytes, asmJsInit, imports).catch(() => null);
|
||||
|
||||
export const bip39Generate = withWasm((wasm) =>
|
||||
(words: 12 | 15 | 18 | 21 | 24): string => {
|
||||
wasm.ext_bip39_generate(8, words);
|
||||
|
||||
return resultString();
|
||||
}
|
||||
);
|
||||
|
||||
export const bip39ToEntropy = withWasm((wasm) =>
|
||||
(phrase: string): Uint8Array => {
|
||||
const [ptr0, len0] = allocString(phrase);
|
||||
|
||||
wasm.ext_bip39_to_entropy(8, ptr0, len0);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const bip39ToMiniSecret = withWasm((wasm) =>
|
||||
(phrase: string, password: string): Uint8Array => {
|
||||
const [ptr0, len0] = allocString(phrase);
|
||||
const [ptr1, len1] = allocString(password);
|
||||
|
||||
wasm.ext_bip39_to_mini_secret(8, ptr0, len0, ptr1, len1);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const bip39ToSeed = withWasm((wasm) =>
|
||||
(phrase: string, password: string): Uint8Array => {
|
||||
const [ptr0, len0] = allocString(phrase);
|
||||
const [ptr1, len1] = allocString(password);
|
||||
|
||||
wasm.ext_bip39_to_seed(8, ptr0, len0, ptr1, len1);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const bip39Validate = withWasm((wasm) =>
|
||||
(phrase: string): boolean => {
|
||||
const [ptr0, len0] = allocString(phrase);
|
||||
const ret = wasm.ext_bip39_validate(ptr0, len0);
|
||||
|
||||
return ret !== 0;
|
||||
}
|
||||
);
|
||||
|
||||
export const ed25519KeypairFromSeed = withWasm((wasm) =>
|
||||
(seed: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(seed);
|
||||
|
||||
wasm.ext_ed_from_seed(8, ptr0, len0);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const ed25519Sign = withWasm((wasm) =>
|
||||
(pubkey: Uint8Array, seckey: Uint8Array, message: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(pubkey);
|
||||
const [ptr1, len1] = allocU8a(seckey);
|
||||
const [ptr2, len2] = allocU8a(message);
|
||||
|
||||
wasm.ext_ed_sign(8, ptr0, len0, ptr1, len1, ptr2, len2);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const ed25519Verify = withWasm((wasm) =>
|
||||
(signature: Uint8Array, message: Uint8Array, pubkey: Uint8Array): boolean => {
|
||||
const [ptr0, len0] = allocU8a(signature);
|
||||
const [ptr1, len1] = allocU8a(message);
|
||||
const [ptr2, len2] = allocU8a(pubkey);
|
||||
const ret = wasm.ext_ed_verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
||||
|
||||
return ret !== 0;
|
||||
}
|
||||
);
|
||||
|
||||
export const sr25519DeriveKeypairHard = withWasm((wasm) =>
|
||||
(pair: Uint8Array, cc: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(pair);
|
||||
const [ptr1, len1] = allocU8a(cc);
|
||||
|
||||
wasm.ext_sr_derive_keypair_hard(8, ptr0, len0, ptr1, len1);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const sr25519DeriveKeypairSoft = withWasm((wasm) =>
|
||||
(pair: Uint8Array, cc: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(pair);
|
||||
const [ptr1, len1] = allocU8a(cc);
|
||||
|
||||
wasm.ext_sr_derive_keypair_soft(8, ptr0, len0, ptr1, len1);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const sr25519DerivePublicSoft = withWasm((wasm) =>
|
||||
(pubkey: Uint8Array, cc: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(pubkey);
|
||||
const [ptr1, len1] = allocU8a(cc);
|
||||
|
||||
wasm.ext_sr_derive_public_soft(8, ptr0, len0, ptr1, len1);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const sr25519KeypairFromSeed = withWasm((wasm) =>
|
||||
(seed: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(seed);
|
||||
|
||||
wasm.ext_sr_from_seed(8, ptr0, len0);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const sr25519Sign = withWasm((wasm) =>
|
||||
(pubkey: Uint8Array, secret: Uint8Array, message: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(pubkey);
|
||||
const [ptr1, len1] = allocU8a(secret);
|
||||
const [ptr2, len2] = allocU8a(message);
|
||||
|
||||
wasm.ext_sr_sign(8, ptr0, len0, ptr1, len1, ptr2, len2);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const sr25519Verify = withWasm((wasm) =>
|
||||
(signature: Uint8Array, message: Uint8Array, pubkey: Uint8Array): boolean => {
|
||||
const [ptr0, len0] = allocU8a(signature);
|
||||
const [ptr1, len1] = allocU8a(message);
|
||||
const [ptr2, len2] = allocU8a(pubkey);
|
||||
const ret = wasm.ext_sr_verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
||||
|
||||
return ret !== 0;
|
||||
}
|
||||
);
|
||||
|
||||
export const vrfSign = withWasm((wasm) =>
|
||||
(secret: Uint8Array, context: Uint8Array, message: Uint8Array, extra: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(secret);
|
||||
const [ptr1, len1] = allocU8a(context);
|
||||
const [ptr2, len2] = allocU8a(message);
|
||||
const [ptr3, len3] = allocU8a(extra);
|
||||
|
||||
wasm.ext_vrf_sign(8, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const vrfVerify = withWasm((wasm) =>
|
||||
(pubkey: Uint8Array, context: Uint8Array, message: Uint8Array, extra: Uint8Array, outAndProof: Uint8Array): boolean => {
|
||||
const [ptr0, len0] = allocU8a(pubkey);
|
||||
const [ptr1, len1] = allocU8a(context);
|
||||
const [ptr2, len2] = allocU8a(message);
|
||||
const [ptr3, len3] = allocU8a(extra);
|
||||
const [ptr4, len4] = allocU8a(outAndProof);
|
||||
const ret = wasm.ext_vrf_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
||||
|
||||
return ret !== 0;
|
||||
}
|
||||
);
|
||||
|
||||
export const blake2b = withWasm((wasm) =>
|
||||
(data: Uint8Array, key: Uint8Array, size: number): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(data);
|
||||
const [ptr1, len1] = allocU8a(key);
|
||||
|
||||
wasm.ext_blake2b(8, ptr0, len0, ptr1, len1, size);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const keccak256 = withWasm((wasm) =>
|
||||
(data: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(data);
|
||||
|
||||
wasm.ext_keccak256(8, ptr0, len0);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const pbkdf2 = withWasm((wasm) =>
|
||||
(data: Uint8Array, salt: Uint8Array, rounds: number): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(data);
|
||||
const [ptr1, len1] = allocU8a(salt);
|
||||
|
||||
wasm.ext_pbkdf2(8, ptr0, len0, ptr1, len1, rounds);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const scrypt = withWasm((wasm) =>
|
||||
(password: Uint8Array, salt: Uint8Array, log2n: number, r: number, p: number): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(password);
|
||||
const [ptr1, len1] = allocU8a(salt);
|
||||
|
||||
wasm.ext_scrypt(8, ptr0, len0, ptr1, len1, log2n, r, p);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const sha512 = withWasm((wasm) =>
|
||||
(data: Uint8Array): Uint8Array => {
|
||||
const [ptr0, len0] = allocU8a(data);
|
||||
|
||||
wasm.ext_sha512(8, ptr0, len0);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export const twox = withWasm((wasm) =>
|
||||
(data: Uint8Array, rounds: number) => {
|
||||
const [ptr0, len0] = allocU8a(data);
|
||||
|
||||
wasm.ext_twox(8, ptr0, len0, rounds);
|
||||
|
||||
return resultU8a();
|
||||
}
|
||||
);
|
||||
|
||||
export function isReady (): boolean {
|
||||
return !!getWasm();
|
||||
}
|
||||
|
||||
export function waitReady (): Promise<boolean> {
|
||||
return wasmPromise.then(() => isReady());
|
||||
}
|
||||
export * from './bundle';
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto', version: '4.0.2' };
|
||||
export const packageInfo = { name: '@polkadot/wasm-crypto', version: '4.1.2' };
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2019-2021 @polkadot/wasm-crypto authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { createBundle } from '@polkadot/dev/config/rollup';
|
||||
|
||||
const pkgs = [
|
||||
'@polkadot/wasm-crypto'
|
||||
];
|
||||
|
||||
const external = [
|
||||
...pkgs,
|
||||
'@polkadot/util'
|
||||
];
|
||||
|
||||
const overrides = {
|
||||
'@polkadot/wasm-crypto': {
|
||||
entries: ['asmjs', 'wasm'].map((p) => `wasm-crypto-${p}`).reduce((all, p) => ({
|
||||
...all,
|
||||
[`@polkadot/${p}`]: `../../${p}/build`
|
||||
}), {})
|
||||
}
|
||||
};
|
||||
|
||||
export default pkgs.map((pkg) =>
|
||||
createBundle({
|
||||
external,
|
||||
pkg,
|
||||
...(overrides[pkg] || {})
|
||||
})
|
||||
);
|
||||
@@ -26,3 +26,5 @@ echo "*** wasm-crypto-wasm"
|
||||
ls -alR wasm-crypto-wasm/build
|
||||
|
||||
cd ..
|
||||
|
||||
yarn build:rollup
|
||||
|
||||
Reference in New Issue
Block a user