You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library is under development, and, like the [secp256k1](https://github.com/bitcoin-core/secp256k1) C library it depends on, this is a research effort to determine an optimal API for end-users of the bitcoinjs ecosystem.
5
+
This library is under development, and, like the [secp256k1](https://github.com/bitcoin-core/secp256k1) C library (through [secp256k1-sys](https://github.com/rust-bitcoin/rust-secp256k1/) Rust crate) it depends on, this is a research effort to determine an optimal API for end-users of the bitcoinjs ecosystem.
6
6
7
7
## Installation
8
8
@@ -18,6 +18,50 @@ npm install tiny-secp256k1
18
18
yarn add tiny-secp256k1
19
19
```
20
20
21
+
## WebAssembly and Node.js version
22
+
23
+
Previous version of `tiny-secp256k1` implement [C++ addon](https://nodejs.org/api/addons.html) through [NAN (Native Abstractions for Node.js)](https://github.com/nodejs/nan) and [elliptic](https://github.com/indutny/elliptic) as fallback when addon can not be built or in browser-like environement.
24
+
25
+
Current version use Rust crate (which use C library) compiled to [WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly). With Wasm same code executed in any environment. Wasm is faster than `elliptic` but slower than node bindings ([results in PR](https://github.com/bitcoinjs/tiny-secp256k1/pull/53#issuecomment-801844450) or you can run own benchmark in `benches` directory).
26
+
27
+
## Building
28
+
29
+
For building locally you need Rust nightly version and C/C++ toolchain.
30
+
31
+
[rustup](https://rustup.rs/) is a recommended way to install `Rust`. You also will need `wasm32-unknown-unknown` target.
After installing development dependencies with `npm` you can build Wasm:
38
+
39
+
```
40
+
make build-wasm
41
+
```
42
+
43
+
or run tests:
44
+
45
+
```
46
+
make test
47
+
```
48
+
49
+
Alternative way is to use [Docker](https://www.docker.com/):
50
+
51
+
```
52
+
% docker build -t tiny-secp256k1 .
53
+
% docker run -it --rm -v `pwd`:/tiny-secp256k1 -w /tiny-secp256k1 tiny-secp256k1
54
+
# npm install --unsafe-perm
55
+
# make test
56
+
# make clean
57
+
```
58
+
59
+
## Examples
60
+
61
+
`tiny-secp256k1` includes two examples. First is [simple script for Node.js](examples/random-in-node) which generate random data and print arguments and methods results. Second is [React app](examples/react-app).
62
+
63
+
React app is builded in GitHub Actions on each commit to master branch and uploaded to [gh-pages](https://github.com/bitcoinjs/tiny-secp256k1/tree/gh-pages) branch, which is always available online: https://bitcoinjs.github.io/tiny-secp256k1/
64
+
21
65
## Documentation
22
66
23
67
### isPoint (A)
@@ -170,25 +214,6 @@ If `strict` is `true`, valid signatures with any of (r, s) values greater than `
170
214
- `ExpectedSignature` if`signature` has any (r, s) values notin range `[0...order -1]`
171
215
- `ExpectedScalar` if`h` is not256-bit
172
216
173
-
---
174
-
175
-
## Docker Build / Development Environment
176
-
177
-
#### Build Docker image
178
-
179
-
```
180
-
docker build -t tiny-secp256k1 .
181
-
```
182
-
183
-
#### Run Docker container
184
-
185
-
```
186
-
docker run -it --rm -v `pwd`:/tiny-secp256k1 -w /tiny-secp256k1 tiny-secp256k1
187
-
# npm install --unsafe-perm
188
-
# make test
189
-
# make clean
190
-
```
191
-
192
217
## Credit
193
218
194
219
This library uses the native library [secp256k1](https://github.com/bitcoin-core/secp256k1) by the bitcoin-core developers through Rust crate [secp256k1-sys](https://crates.io/crates/secp256k1-sys), including derivatives of its tests and test vectors.
0 commit comments