Seed repo (#1)

* Seed repo

* Travis matrix for JS & Rust

* Update with cleaned latest schnorrkel

* Delete node-test.js

* Update .gitignore

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update build.sh

* Update .travis.yml

* Update .travis.yml

* Update build.sh

* Update build.sh

* Update build.sh

* Update .travis.yml

* Update build.sh

* Pull in latest schnorrkel-js fork

* Update schnorrkel README as per source

* Build via ./test.sh

* Move build to deps (only dep install)

* Adapt for header

* Show build output
This commit is contained in:
Jaco Greeff
2019-03-17 13:12:14 +01:00
committed by GitHub
parent f510e0cc43
commit 362f921d18
36 changed files with 13180 additions and 15 deletions
+1
View File
@@ -0,0 +1 @@
module.exports = require('./babel.config.js');
+4
View File
@@ -0,0 +1,4 @@
exclude_patterns:
- "**/*.spec.js"
- "**/*.spec.ts"
- "docs/**/*.js"
+10
View File
@@ -0,0 +1,10 @@
root = true
[*]
indent_style=space
indent_size=2
tab_width=2
end_of_line=lf
charset=utf-8
trim_trailing_whitespace=true
max_line_length=120
insert_final_newline=true
+20
View File
@@ -0,0 +1,20 @@
binaryen/
build/
build-docs/
coverage/
docs/.vuepress/dist/
node_modules/
pkg/
target/
tmp/
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.npmrc
lerna-debug.log*
npm-debug.log*
package-lock.json
yarn-debug.log*
yarn-error.log*
View File
+1
View File
@@ -0,0 +1 @@
10
+18 -15
View File
@@ -1,19 +1,22 @@
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$(yarn global bin):$PATH
language: node_js
node_js:
- "10"
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['cmake', 'g++-5']
cache:
cargo: true
yarn: true
directories:
- node_modules
matrix:
include:
- language: rust
script:
- ./build.sh
- ./test-rust.sh
include:
- language: node_js
node_js:
- "10"
script:
- ./test-js.sh
compiler:
- clang
before_install:
- curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly -y
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$HOME/.cargo/bin:$(yarn global bin):$PATH
install:
- yarn
script:
- yarn polkadot-dev-build-travis
+3
View File
@@ -0,0 +1,3 @@
# 0.1.1
- Initial release
+201
View File
@@ -0,0 +1,201 @@
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.
+23
View File
@@ -0,0 +1,23 @@
[![polkadotjs](https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square)](https://polkadot.js.org)
![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)
[![style](https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square)](https://github.com/Flet/semistandard)
[![travis](https://img.shields.io/travis/polkadot-js/wasm.svg?style=flat-square)](https://travis-ci.com/polkadot-js/wasm)
[![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/wasm.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/wasm/maintainability)
[![coverage](https://img.shields.io/coveralls/polkadot-js/wasm.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/wasm?branch=master)
[![greenkeeper](https://img.shields.io/badge/greenkeeper-enabled-brightgreen.svg?style=flat-square)](https://greenkeeper.io/)
# @polkadot/wasm
Various WASM wrappers around Rust crates
## overview
It is split up into a number of internal packages, namely utilities -
- [wasm-schnorrkel](packages/wasm-schnorrkel/) sr25519
## development
Contributions are welcome!
To start off, this repo (along with others in the [@polkadot](https://github.com/polkadot-js/) family) uses yarn workspaces to organise the code. As such, after cloning, its dependencies _should_ be installed via `yarn`, not via npm; the latter will result in broken dependencies.
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
extends: '@polkadot/dev/config/babel'
};
Executable
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -e
PACKAGES=( "schnorrkel" )
# install wasm-pack as required
if ! [ -x "$(command -v wasm-pack)" ]; then
echo "*** Installing wasm-pack"
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
fi
# install binaryen as required
if [ ! -d "binaryen" ]; then
echo "*** Installing binaryen"
git clone --recursive https://github.com/WebAssembly/binaryen.git
rm -rf binaryen/test
fi
# build wasm2js as required
# if [ ! -f "binaryen/bin/wasm2js" ]; then
# echo "*** Building wasm2js"
# cd binaryen
# cmake .
# make wasm2js
# cd ..
# fi
# build wasm-opt as required
if [ ! -f "binaryen/bin/wasm-opt" ]; then
echo "*** Building wasm-opt"
cd binaryen
cmake .
make wasm-opt
cd ..
fi
+10
View File
@@ -0,0 +1,10 @@
const config = require('@polkadot/dev/config/jest');
module.exports = Object.assign({}, config, {
moduleNameMapper: {
'@polkadot/wasm-(schnorrkel)(.*)$': '<rootDir>/packages/wasm-$1/src/$2',
},
modulePathIgnorePatterns: [
'<rootDir>/packages/wasm-schnorrkel/build'
]
});
+13
View File
@@ -0,0 +1,13 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
"publish": {
"allowBranch": "master"
}
},
"packages": [
"packages/*"
],
"version": "0.1.0-beta.0"
}
+27
View File
@@ -0,0 +1,27 @@
{
"version": "0.1.0-beta.0",
"private": true,
"engines": {
"node": "^10.13.0",
"yarn": "^1.10.1"
},
"workspaces": [
"packages/*"
],
"resolutions": {
"babel-core": "^7.0.0-bridge.0",
"typescript": "^3.3.3333"
},
"scripts": {
"build": "echo \"Build via ./test.sh\"",
"check": "tslint --project . && tsc --noEmit --pretty",
"clean": "polkadot-dev-clean-build",
"postinstall": "polkadot-dev-yarn-only",
"test": "./test.sh"
},
"devDependencies": {
"@polkadot/dev": "^0.27.1",
"@polkadot/util": "^0.38.0-beta.4",
"gh-pages": "^2.0.1"
}
}
+8
View File
@@ -0,0 +1,8 @@
# 0.2.0
- Add soft key derivation functions
- Rename exposed functions to camelCase
# 0.1.0
- Initial version
+561
View File
@@ -0,0 +1,561 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "autocfg"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bitflags"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "block-buffer"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"block-padding 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "block-padding"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bumpalo"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "byte-tools"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "byteorder"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cc"
version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cfg-if"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "clear_on_drop"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cloudabi"
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "curve25519-dalek"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "digest"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ed25519-dalek"
version = "1.0.0-pre.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "failure"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "fake-simd"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "generic-array"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "hex-literal"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"hex-literal-impl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "hex-literal-impl"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "keccak"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lazy_static"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "log"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "memory_units"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "merlin"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "opaque-debug"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "packed_simd"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro-hack"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro-hack-impl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro-hack-impl"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "proc-macro2"
version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quote"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
"packed_simd 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_chacha"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_core"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_core"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rand_hc"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_isaac"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_jitter"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_os"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_pcg"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_xorshift"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "schnorrkel"
version = "0.0.0"
source = "git+https://github.com/w3f/schnorrkel?rev=d3289df76b8ae6dfb68e733204c5c009df5343a9#d3289df76b8ae6dfb68e733204c5c009df5343a9"
dependencies = [
"clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "sha2"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "sha3"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "subtle"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "syn"
version = "0.15.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "typenum"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unreachable"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wasm-bindgen"
version = "0.2.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"wasm-bindgen-macro 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bumpalo 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-macro-support 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-backend 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wasm-schnorrkel"
version = "0.1.0"
dependencies = [
"hex-literal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel?rev=d3289df76b8ae6dfb68e733204c5c009df5343a9)",
"wasm-bindgen 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"wee_alloc 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wee_alloc"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
"memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum block-buffer 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49665c62e0e700857531fa5d3763e91b539ff1abeebd56808d378b495870d60d"
"checksum block-padding 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d75255892aeb580d3c566f213a2b6fdc1c66667839f45719ee1d30ebf2aea591"
"checksum bumpalo 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21ef2109240a377370f55ea3ef0b486b46d7b5c0f7455ab0ec676d73f875d58a"
"checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
"checksum cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ce8bb087aacff865633f0bd5aeaed910fe2fe55b55f4739527f2e023a2e53d"
"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4"
"checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1f8a6fc0376eb52dc18af94915cc04dfdf8353746c0e8c550ae683a0815e5c1"
"checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c"
"checksum ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81956bcf7ef761fb4e1d88de3fa181358a0d26cbcb9755b587a08f9119824b86"
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
"checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592"
"checksum hex-literal 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc2928beef125e519d69ae1baa8c37ea2e0d3848545217f6db0179c5eb1d639"
"checksum hex-literal-impl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "520870c3213943eb8d7803e80180d12a6c7ceb4ae74602544529d1643dc4ddda"
"checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
"checksum memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3"
"checksum merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "83c2dda19c01176e8e7148f7bdb88bbdf215a8db0641f89fc40e4b81736aeda5"
"checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409"
"checksum packed_simd 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a85ea9fc0d4ac0deb6fe7911d38786b32fc11119afd9e9d38b84ff691ce64220"
"checksum proc-macro-hack 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c725b36c99df7af7bf9324e9c999b9e37d92c8f8caf106d82e1d7953218d2d8"
"checksum proc-macro-hack-impl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b753ad9ed99dd8efeaa7d2fb8453c8f6bc3e54b97966d35f1bc77ca6865254a"
"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915"
"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1"
"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
"checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832"
"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
"checksum schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel?rev=d3289df76b8ae6dfb68e733204c5c009df5343a9)" = "<none>"
"checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d"
"checksum sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34a5e54083ce2b934bf059fdf38e7330a154177e029ab6c4e18638f2f624053a"
"checksum subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "702662512f3ddeb74a64ce2fbbf3707ee1b6bb663d28bb054e0779bbc720d926"
"checksum syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2"
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum wasm-bindgen 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)" = "06e36714cc3947a9c80ddc9715edb319e445e5ab0d0b083debec0dd52558580e"
"checksum wasm-bindgen-backend 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)" = "6764493f6eeb3f8632ffd418bf7db6a7e7aca98417c115833e4663976cd60a5e"
"checksum wasm-bindgen-macro 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a473501c40a2a4da83ae7176fead61f10d003554b701071a704dd0667397027a"
"checksum wasm-bindgen-macro-support 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)" = "72e5a249738c6315f65ce5527632e2a3a067cdf1765422d8ac1572dcee14f819"
"checksum wasm-bindgen-shared 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)" = "70f57643dac7decc3b53f0e4ffd027e225b79281648842eb46015e58a2400870"
"checksum wee_alloc 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e841fed992c6c70cf2af5dbcffb0d988b1a7ffc5177ae4fb714ed14944b39d0a"
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+20
View File
@@ -0,0 +1,20 @@
[package]
name = "wasm-schnorrkel"
version = "0.1.0"
authors = ["Jaco Greeff <jacogr@gmail.com>", "kianenigma <Kian.peymani@gmail.com>"]
edition = "2018"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
wasm-bindgen = { version = "0.2" }
wee_alloc = { version = "0.4.3" }
schnorrkel = { git = "https://github.com/w3f/schnorrkel", rev = "d3289df76b8ae6dfb68e733204c5c009df5343a9", features = ["nightly"] }
[dev-dependencies]
hex-literal = { version = "0.1.4" }
rand = { version = "0.6.5", features = ["wasm-bindgen"] }
[profile.release]
lto = true
+23
View File
@@ -0,0 +1,23 @@
# @polkadot/schnorrkel-js
A fork of [@parity/schnorrkel-js](https://github.com/polkadot-js/schnorrkel-js/tree/b1a1bf25be7397d3c21bba5ddde14286a58b269c) that allows proper operation against all the environments that the `@polkadot/api` supports. Changes from the base repo -
- WASM initialisation is done async, via Promise (this allows for clear operation in webpack environments without additional workers)
- WASM outputs are optimised via `wasm-opt` from the [binaryen](https://github.com/WebAssembly/binaryen) project
- Output bundle is wrapped with camelCase names (not including the `__***` internal functions)
- Full named functions and parameter TypeScript definitions
- Requires for crypto is wrapped, removing "on-demand-require" warnings in webpack environment
- WASM output is done via a base-64 encoded string, supporting both Node.js and browser environments
- Extensive code cleanups and addition of functions required for all sr25519 operations
- Extended tests to cover Rust, wasm (via Node) and wasm (via jest), remove (here unused) www interfaces
- TextDecoder is polyfilled by using the version from `@polkadot/util` (consistent support, alos on React Native)
- Polyfill for crypto functions that are not available in some environments (e.g. Jest & React Native)
## development
1. Build can be done via `./build.sh`
2. Tests can be done via `./test.sh`
## future work
Support asm.js for environments (like React Native) that doesn't have WASM support. Initial attempts made at this, but not active.
+6
View File
@@ -0,0 +1,6 @@
const fs = require('fs');
const buffer = fs.readFileSync('./build/wasm_schnorrkel_opt.wasm');
fs.writeFileSync('./build/wasm_schnorrkel_wasm.js', `
module.exports = Buffer.from('${buffer.toString('base64')}', 'base64');
`);
+121
View File
@@ -0,0 +1,121 @@
#!/usr/bin/env bash
set -e
# cleanup old
echo "*** Cleaning old builds"
rm -rf ./build ./pkg
# build new via nightly & wasm-pack
echo "*** Building WASM output"
rustup run nightly wasm-pack build --release --scope polkadot --target nodejs
mv pkg build
# optimise
echo "*** Optimising WASM output"
../../binaryen/bin/wasm-opt build/wasm_schnorrkel_bg.wasm -Os -o build/wasm_schnorrkel_opt.wasm
# build asmjs version from the input (optimised) WASM
# echo "*** Building asm.js version"
# ../../binaryen/bin/wasm2js --no-validation --output build/wasm_schnorrkel_temp.js build/wasm_schnorrkel_opt.wasm
# convert wasm to base64 structure
echo "*** Packing WASM into base64"
node ./build.js
# copy our package interfaces
echo "*** Copying package sources"
cp src/js/* build/
# shortcuts for files
echo "*** Adjusting output"
BGJ=build/wasm_schnorrkel_bg.js
SRC=build/wasm_schnorrkel.js
DEF=build/wasm_schnorrkel.d.ts
TMP=build/wasm_schnorrkel_temp.js
ASM=build/wasm_schnorrkel_asm.js
PKG=build/package.json
# update the files (new addition)
# excluded: "wasm_schnorrkel_asm\.js",
# sed -i -e 's/wasm_schnorrkel_bg\.wasm/wasm_schnorrkel_wasm\.js", "index\.js", "index\.d\.ts/g' $PKG
# sed -i -e 's/"main": "wasm_schnorrkel\.js"/"main": "index\.js"/g' $PKG
# sed -i -e 's/"types": "wasm_schnorrkel\.d\.ts"/"types": "index\.d\.ts"/g' $PKG
# cleanup asm
# sed -i -e 's/import {/\/\/ import {/g' $TMP
# sed -i -e 's/function asmFunc/var schnorrkel = require('\''\.\/wasm_schnorrkel'\''); function asmFunc/g' $TMP
# sed -i -e 's/export const /module\.exports\./g' $TMP
# sed -i -e 's/{abort.*},memasmFunc/schnorrkel, memasmFunc/g' $TMP
# we do not want the __ imports (used by WASM) to clutter up
sed -i -e 's/var wasm;/const crypto = require('\''crypto'\''); let wasm; const requires = { crypto };/g' $SRC
# this creates issues in both the browser and RN (@polkadot/util has a polyfill)
sed -i -e 's/const TextDecoder = require('\''util'\'')\.TextDecoder;/const { u8aToString } = require('\''@polkadot\/util'\'');/g' $SRC
# TextDecoder is not available on RN, so use the @polkadot/util replacement (with polyfill)
sed -i -e 's/let cachedTextDecoder = new /\/\/ let cachedTextDecoder = new /g' $SRC
sed -i -e 's/cachedTextDecoder\.decode/u8aToString/g' $SRC
# we are swapping to a async interface for webpack support (wasm limits)
sed -i -e 's/wasm = require/\/\/ wasm = require/g' $SRC
# pull the requires from the imports and the `requires` object
sed -i -e 's/return addHeapObject(require(varg0));/return addHeapObject(requires[varg0]);/g' $SRC
# sed -i -e 's/return addHeapObject(require(varg0));/throw new Error(`Invalid require from WASM for ${varg0}`);/g' $SRC
# construct our promise and add ready helpers
echo "
module.exports.abort = function () { throw new Error('abort'); };
const createPromise = require('./wasm_schnorrkel_bg');
const wasmPromise = createPromise().catch(() => null);
module.exports.isReady = function () { return !!wasm; }
module.exports.waitReady = function () { return wasmPromise.then(() => !!wasm); }
wasmPromise.then((_wasm) => { wasm = _wasm });
" >> $SRC
# add extra methods to type definitions
echo "
export function isReady(): boolean;
export function waitReady(): Promise<boolean>;
" >> $DEF
# create the init promise handler
echo "
const asm = null; // require('./wasm_schnorrkel_asm');
const bytes = require('./wasm_schnorrkel_wasm');
const schnorrkel = require('./wasm_schnorrkel');
module.exports = async function createExportPromise () {
const imports = {
'./wasm_schnorrkel': schnorrkel
};
if (!WebAssembly) {
return asm;
}
try {
const { instance } = await WebAssembly.instantiate(bytes, imports);
return instance.exports;
} catch (error) {
return asm;
}
}
" > $BGJ
# cleanup in-place sed files
echo "*** Cleaning up in-place edits"
rm -rf build/*-e
# pass through uglify to make the actual output smaller
# echo "*** Optimising asm.js output"
# yarn run uglifyjs $TMP --compress --mangle --timings --output $ASM
# mv $TMP $ASM
ls -al build
+28
View File
@@ -0,0 +1,28 @@
{
"name": "@polkadot/wasm-schnorrkel",
"collaborators": [
"Jaco Greeff <jacogr@gamil.com>",
"kianenigma <Kian.peymani@gmail.com>"
],
"files": [
"index.js",
"index.d.ts",
"crypto-polyfill.js",
"wasm_schnorrkel_wasm.js",
"wasm_schnorrkel.js",
"wasm_schnorrkel_bg.js",
"wasm_schnorrkel.d.ts"
],
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"test": "./test.sh"
},
"version": "0.1.0-beta.0",
"peerDependencies": {
"@polkadot/util": "*"
},
"devDependencies": {
"jest": "*"
}
}
@@ -0,0 +1,22 @@
// Copyright 2019 @polkadot/wasm-schnorrkel authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// @ts-check
const crypto = require('crypto');
if (!global.crypto) {
global.crypto = {};
}
if (!global.crypto.getRandomValues) {
global.crypto.getRandomValues = function (arr) {
const buffer = crypto.randomBytes(arr.length);
return buffer.reduce((arr, value, index) => {
arr[index] = value;
return arr;
}, arr);
}
}
+12
View File
@@ -0,0 +1,12 @@
// Copyright 2019 @polkadot/wasm-schnorrkel authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
export function deriveKeypairHard (pair: Uint8Array, chainCode: Uint8Array): Uint8Array;
export function deriveKeypairSoft (pair: Uint8Array, chainCode: Uint8Array): Uint8Array;
export function derivePublicSoft (publicKey: Uint8Array, chainCode: Uint8Array): Uint8Array;
export function isReady (): boolean;
export function keypairFromSeed (seed: Uint8Array): Uint8Array;
export function sign (publicKey: Uint8Array, secretKey: Uint8Array, message: Uint8Array): Uint8Array;
export function verify (signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): boolean;
export function waitReady (): Promise<boolean>;
+15
View File
@@ -0,0 +1,15 @@
// Copyright 2019 @polkadot/wasm-schnorrkel authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// @ts-check
const stubbed = require('./wasm_schnorrkel');
module.exports.deriveKeypairHard = stubbed.derive_keypair_hard;
module.exports.deriveKeypairSoft = stubbed.derive_keypair_soft;
module.exports.derivePublicSoft = stubbed.derive_public_soft;
module.exports.isReady = stubbed.isReady;
module.exports.keypairFromSeed = stubbed.keypair_from_seed;
module.exports.sign = stubbed.sign;
module.exports.verify = stubbed.verify;
module.exports.waitReady = stubbed.waitReady;
+239
View File
@@ -0,0 +1,239 @@
// Originally developed (as a fork) in https://github.com/polkadot-js/schnorrkel-js/
// which was adpated from the initial https://github.com/paritytech/schnorrkel-js/
// forked at commit eff430ddc3090f56317c80654208b8298ef7ab3f
extern crate wasm_bindgen;
extern crate wee_alloc;
extern crate schnorrkel;
use schnorrkel::{
Keypair, MiniSecretKey, PublicKey, SecretKey, Signature,
derive::{Derivation, ChainCode, CHAIN_CODE_LENGTH},
};
use wasm_bindgen::prelude::*;
// Use `wee_alloc` as the global allocator.
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
// We must make sure that this is the same as declared in the substrate source code.
const SIGNING_CTX: &'static [u8] = b"substrate";
/// ChainCode construction helper
fn create_cc(data: &[u8]) -> ChainCode {
let mut cc = [0u8; CHAIN_CODE_LENGTH];
cc.copy_from_slice(&data);
ChainCode(cc)
}
/// Keypair helper function.
fn create_from_seed(seed: &[u8]) -> Keypair {
match MiniSecretKey::from_bytes(seed) {
Ok(mini) => return mini.expand_to_keypair(),
Err(_) => panic!("Provided seed is invalid.")
}
}
/// Keypair helper function.
fn create_from_pair(pair: &[u8]) -> Keypair {
match Keypair::from_bytes(pair) {
Ok(pair) => return pair,
Err(_) => panic!("Provided pair is invalid.")
}
}
/// PublicKey helper
fn create_public(public: &[u8]) -> PublicKey {
match PublicKey::from_bytes(public) {
Ok(public) => return public,
Err(_) => panic!("Provided public key is invalid.")
}
}
/// SecretKey helper
fn create_secret(secret: &[u8]) -> SecretKey {
match SecretKey::from_bytes(secret) {
Ok(secret) => return secret,
Err(_) => panic!("Provided private key is invalid.")
}
}
/// Perform a derivation on a secret
///
/// * secret: UIntArray with 64 bytes
/// * cc: UIntArray with 32 bytes
///
/// returned vector the derived keypair as a array of 96 bytes
#[wasm_bindgen]
pub fn derive_keypair_hard(pair: &[u8], cc: &[u8]) -> Vec<u8> {
create_from_pair(pair).secret
.hard_derive_mini_secret_key(Some(create_cc(cc)), &[]).0
.expand_to_keypair()
.to_bytes()
.to_vec()
}
/// Perform a derivation on a secret
///
/// * secret: UIntArray with 64 bytes
/// * cc: UIntArray with 32 bytes
///
/// returned vector the derived keypair as a array of 96 bytes
#[wasm_bindgen]
pub fn derive_keypair_soft(pair: &[u8], cc: &[u8]) -> Vec<u8> {
create_from_pair(pair)
.derived_key_simple(create_cc(cc), &[]).0
.to_bytes()
.to_vec()
}
/// Perform a derivation on a publicKey
///
/// * pubkey: UIntArray with 32 bytes
/// * cc: UIntArray with 32 bytes
///
/// returned vector is the derived publicKey as a array of 32 bytes
#[wasm_bindgen]
pub fn derive_public_soft(public: &[u8], cc: &[u8]) -> Vec<u8> {
create_public(public)
.derived_key_simple(create_cc(cc), &[]).0
.to_bytes().to_vec()
}
/// Generate a key pair.
///
/// * seed: UIntArray with 32 element
///
/// returned vector is the concatenation of first the private key (64 bytes)
/// followed by the public key (32) bytes.
#[wasm_bindgen]
pub fn keypair_from_seed(seed: &[u8]) -> Vec<u8> {
create_from_seed(seed)
.to_bytes()
.to_vec()
}
/// Sign a message
///
/// The combination of both public and private key must be provided.
/// This is effectively equivalent to a keypair.
///
/// * public: UIntArray with 32 element
/// * private: UIntArray with 64 element
/// * message: Arbitrary length UIntArray
///
/// * returned vector is the signature consisting of 64 bytes.
#[wasm_bindgen]
pub fn sign(public: &[u8], secret: &[u8], message: &[u8]) -> Vec<u8> {
create_secret(secret)
.sign_simple(SIGNING_CTX, message, &create_public(public))
.to_bytes()
.to_vec()
}
/// Verify a message and its corresponding against a public key;
///
/// * signature: UIntArray with 64 element
/// * message: Arbitrary length UIntArray
/// * pubkey: UIntArray with 32 element
#[wasm_bindgen]
pub fn verify(signature: &[u8], message: &[u8], public: &[u8]) -> bool {
let signature = match Signature::from_bytes(signature) {
Ok(signature) => signature,
Err(_) => return false
};
create_public(public)
.verify_simple(SIGNING_CTX, message, &signature)
}
#[cfg(test)]
pub mod tests {
extern crate rand;
extern crate schnorrkel;
use hex_literal::{hex, hex_impl};
use super::*;
use schnorrkel::{SIGNATURE_LENGTH, KEYPAIR_LENGTH, SECRET_KEY_LENGTH};
fn generate_random_seed() -> Vec<u8> {
(0..32).map(|_| rand::random::<u8>() ).collect()
}
#[test]
fn can_create_keypair() {
let seed = generate_random_seed();
let keypair = keypair_from_seed(seed.as_slice());
assert!(keypair.len() == KEYPAIR_LENGTH);
}
#[test]
fn creates_pair_from_known() {
let seed = hex!("fac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e");
let expected = hex!("46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a");
let keypair = keypair_from_seed(&seed);
let public = &keypair[SECRET_KEY_LENGTH..KEYPAIR_LENGTH];
assert_eq!(public, expected);
}
#[test]
fn can_sign_message() {
let seed = generate_random_seed();
let keypair = keypair_from_seed(seed.as_slice());
let private = &keypair[0..SECRET_KEY_LENGTH];
let public = &keypair[SECRET_KEY_LENGTH..KEYPAIR_LENGTH];
let message = b"this is a message";
let signature = sign(public, private, message);
assert!(signature.len() == SIGNATURE_LENGTH);
}
#[test]
fn can_verify_message() {
let seed = generate_random_seed();
let keypair = keypair_from_seed(seed.as_slice());
let private = &keypair[0..SECRET_KEY_LENGTH];
let public = &keypair[SECRET_KEY_LENGTH..KEYPAIR_LENGTH];
let message = b"this is a message";
let signature = sign(public, private, message);
assert!(verify(&signature[..], message, public));
}
#[test]
fn soft_derives_pair() {
let cc = hex!("0c666f6f00000000000000000000000000000000000000000000000000000000"); // foo
let seed = hex!("fac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e");
let expected = hex!("40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a");
let keypair = keypair_from_seed(&seed);
let derived = derive_keypair_soft(&keypair, &cc);
let public = &derived[SECRET_KEY_LENGTH..KEYPAIR_LENGTH];
assert_eq!(public, expected);
}
#[test]
fn soft_derives_public() {
let cc = hex!("0c666f6f00000000000000000000000000000000000000000000000000000000"); // foo
let public = hex!("46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a");
let expected = hex!("40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a");
assert_eq!(derive_public_soft(&public, &cc), expected);
}
#[test]
fn hard_derives_pair() {
let cc = hex!("14416c6963650000000000000000000000000000000000000000000000000000"); // Alice
let seed = hex!("fac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e");
let expected = hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d");
let keypair = keypair_from_seed(&seed);
let derived = derive_keypair_hard(&keypair, &cc);
let public = &derived[SECRET_KEY_LENGTH..KEYPAIR_LENGTH];
assert_eq!(public, expected);
}
}
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e
./build.sh
echo "*** Running cargo tests"
cargo test --release -- --nocapture
echo "*** Running wasm tests"
node ./test/wasm.js
echo "*** Running jest tests"
yarn jest ./test/jest.spec.js
+202
View File
@@ -0,0 +1,202 @@
// Copyright 2019 @polkadot/wasm-schnorrkel authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// @ts-check
const crypto = require('crypto');
const { assert, hexToU8a, stringToU8a, u8aToHex } = require('@polkadot/util');
const schnorrkel = require('../build/index');
function extractKeys (pair) {
const pk = pair.slice(64);
const sk = pair.slice(0, 64);
return [pair, pk, sk];
}
function randomPair () {
const seed = crypto.randomBytes(32);
const pair = schnorrkel.keypairFromSeed(seed);
assert(pair.length === 96, 'ERROR: Invalid pair created');
return extractKeys(pair);
}
async function beforeAll () {
return schnorrkel.waitReady();
}
async function pairFromSeed () {
const SEED = stringToU8a('12345678901234567890123456789012');
const PAIR = hexToU8a(
'0x' +
'f0106660c3dda23f16daa9ac5b811b963077f5bc0af89f85804f0de8e424f050' +
'f98d66f39442506ff947fd911f18c7a7a5da639a63e8d3b4e233f74143d951c1' +
'741c08a06f41c596608f6774259bd9043304adfa5d3eea62760bd9be97634d63'
);
const pair = schnorrkel.keypairFromSeed(SEED);
console.log('\tSEC', u8aToHex(pair.slice(0, 64)));
console.log('\tPUB', u8aToHex(pair.slice(64)));
assert(u8aToHex(pair) === u8aToHex(PAIR), 'ERROR: pairFromSeed() does not match');
}
async function devFromSeed () {
const SEED = hexToU8a('0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e');
const PAIR = hexToU8a(
'0x' +
'28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51' +
'fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca34' +
'46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'
);
const pair = schnorrkel.keypairFromSeed(SEED);
console.log('\tSEC', u8aToHex(pair.slice(0, 64)));
console.log('\tPUB', u8aToHex(pair.slice(64)));
assert(u8aToHex(pair) === u8aToHex(PAIR), 'ERROR: devFromSeed() does not match');
}
async function verifyExisting () {
const PK = hexToU8a('0x741c08a06f41c596608f6774259bd9043304adfa5d3eea62760bd9be97634d63');
const MESSAGE = stringToU8a('this is a message');
const SIGNATURE = hexToU8a(
'0x' +
'decef12cf20443e7c7a9d406c237e90bcfcf145860722622f92ebfd5eb4b5b39' +
'90b6443934b5cba8f925a0ae75b3a77d35b8490cbb358dd850806e58eaf72904'
);
const isValid = schnorrkel.verify(SIGNATURE, MESSAGE, PK);
console.log('\tRES', isValid);
assert(isValid, 'ERROR: Unable to verify signature');
}
async function signAndVerify () {
const MESSAGE = stringToU8a('this is a message');
const [, pk, sk] = randomPair();
const signature = schnorrkel.sign(pk, sk, MESSAGE);
const isValid = schnorrkel.verify(signature, MESSAGE, pk);
console.log('\tSIG', u8aToHex(signature));
console.log('\tRES', isValid);
assert(isValid, 'ERROR: Unable to verify signature');
}
async function deriveHard () {
const CC = hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000');
const [pair] = randomPair();
const derived = schnorrkel.deriveKeypairHard(pair, CC);
console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
console.log('\tPUB', u8aToHex(derived.slice(64)));
}
async function deriveHardKnown () {
const CC = hexToU8a('0x14416c6963650000000000000000000000000000000000000000000000000000');
const PAIR = hexToU8a(
'0x' +
'28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51' +
'fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca34' +
'46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'
);
const PUBLIC = '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d';
const derived = schnorrkel.deriveKeypairHard(PAIR, CC);
const publicKey = u8aToHex(derived.slice(64));
console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
console.log('\tPUB', publicKey);
assert(publicKey === PUBLIC, 'Unmatched resulting public keys');
}
async function deriveSoft () {
const CC = hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000');
const [pair] = randomPair();
const derived = schnorrkel.deriveKeypairSoft(pair, CC);
console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
console.log('\tPUB', u8aToHex(derived.slice(64)));
}
async function deriveSoftKnown () {
const CC = hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000');
const PUBLIC = '0x40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a';
const PAIR = hexToU8a(
'0x' +
'28b0ae221c6bb06856b287f60d7ea0d98552ea5a16db16956849aa371db3eb51' +
'fd190cce74df356432b410bd64682309d6dedb27c76845daf388557cbac3ca34' +
'46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a'
);
const derived = schnorrkel.deriveKeypairSoft(PAIR, CC);
const publicKey = u8aToHex(derived.slice(64));
console.log('\tSEC', u8aToHex(derived.slice(0, 64)));
console.log('\tPUB', publicKey);
assert(publicKey === PUBLIC, 'Unmatched resulting public keys');
}
async function deriveSoftPubkey () {
const CC = hexToU8a('0x0c666f6f00000000000000000000000000000000000000000000000000000000');
const PUBLIC = hexToU8a('0x46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a');
const DERIVED = '0x40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a';
const derived = u8aToHex(schnorrkel.derivePublicSoft(PUBLIC, CC));
console.log('\tPUB', derived);
assert(derived === DERIVED, 'Unmatched resulting public keys');
}
async function benchmark () {
const MESSAGE = stringToU8a('this is a message');
for (let i = 0; i < 256; i++) {
const [, pk, sk] = randomPair();
const signature = schnorrkel.sign(pk, sk, MESSAGE);
const isValid = schnorrkel.verify(signature, MESSAGE, pk);
assert(isValid, 'ERROR: Unable to verify signature');
}
}
const tests = {
pairFromSeed,
devFromSeed,
deriveHard,
deriveHardKnown,
deriveSoft,
deriveSoftKnown,
deriveSoftPubkey,
signAndVerify,
verifyExisting,
benchmark
};
async function runAll () {
Object.keys(tests).forEach(async (name) => {
console.time(name);
console.log();
console.log(name);
await tests[name]();
console.timeEnd(name);
});
}
module.exports.beforeAll = beforeAll;
module.exports.runAll = runAll;
module.exports.tests = tests;
+9
View File
@@ -0,0 +1,9 @@
// Copyright 2019 @polkadot/wasm-schnorrkel authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// @ts-check
// @ts-ignore
global.WebAssembly = null;
require('./wasm');
@@ -0,0 +1,22 @@
// Copyright 2019 @polkadot/wasm-schnorrkel authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// @ts-check
require('../build/crypto-polyfill');
const { beforeAll, tests } = require('./all.js');
describe('schnorrkel-js', () => {
beforeEach(async () => {
await beforeAll();
});
Object.keys(tests).forEach((name) => {
const test = tests[name];
it(name, async () => {
await test();
});
});
});
+11
View File
@@ -0,0 +1,11 @@
// Copyright 2019 @polkadot/wasm-schnorrkel authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// @ts-check
const { beforeAll, runAll } = require('./all');
(async () => {
await beforeAll();
await runAll();
})();
Executable
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -e
./deps.sh
PACKAGES=( "schnorrkel" )
echo "*** Testing packages"
cd packages
for PKG in "${PACKAGES[@]}"; do
cd wasm-$PKG
./test.sh
cd ..
done
cd ..
+13
View File
@@ -0,0 +1,13 @@
{
"extends": "./node_modules/@polkadot/dev/config/tsconfig",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@polkadot/wasm-schnorrkel": [ "packages/wasm-schnorrkel/src" ]
},
"typeRoots": [
"./node_modules/@polkadot/ts",
"./node_modules/@types"
]
}
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "@polkadot/dev/config/tslint"
}
+16
View File
@@ -0,0 +1,16 @@
module.exports = {
name: 'Polkadot JS WASM',
exclude: '**/*+(index|e2e|spec).ts',
excludeExternals: true,
excludeNotExported: true,
excludeProtected: true,
excludePrivate: true,
hideGenerator: true,
includeDeclarations: false,
out: 'docs',
module: 'commonjs',
moduleResolution: 'node',
mdEngine: 'gitbook',
stripInternal: 'true',
theme: 'markdown'
};
+11445
View File
File diff suppressed because it is too large Load Diff