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
Copy file name to clipboardExpand all lines: README.md
+96-67Lines changed: 96 additions & 67 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,17 @@ JavaScript Elliptic curve cryptography library for both browserify and node.
10
10
11
11
## Motivation
12
12
13
-
There is currently no any isomorphic ECC library which provides ECDSA, ECDH and ECIES for both Node.js and Browser and uses the fastest implementation available (e.g. [secp256k1-node](https://github.com/wanderer/secp256k1-node) is much faster than other libraries but can be used only on Node.js). So `eccrypto` is an attempt to create one.
13
+
- ECDSA (sign/verify)
14
+
- ECDH (key agreement)
15
+
- ECIES (encrypt/decrypt)
16
+
- secp256k1 curve support
17
+
- Compressed and uncompressed public key support
18
+
- Works in both Node.js and browsers
19
+
- Uses `Uint8Array` for all binary data
14
20
15
21
## Implementation details
16
22
17
-
With the help of browserify `eccrypto` provides different implementations for Browser and Node.js with the same API. Because WebCryptoAPI defines asynchronous promise-driven API, implementation for Node needs to use promises too.
23
+
This library uses [`@noble/curves`](https://github.com/paulmillr/noble-curves)for elliptic curve operations, which provides:
18
24
19
25
- Use Node.js crypto module/library bindings where possible
20
26
- Use WebCryptoAPI where possible
@@ -26,92 +32,115 @@ With the help of browserify `eccrypto` provides different implementations for Br
26
32
27
33
#### crypto
28
34
29
-
ECDH only works in Node 0.11+ (see https://github.com/joyent/node/pull/5854), ECDSA only supports keys in PEM format (see https://github.com/joyent/node/issues/6904) and ECIES is not supported at all.
35
+
```bash
36
+
npm install @toruslabs/eccrypto
37
+
```
30
38
31
39
#### WebCryptoAPI
32
40
33
41
ECDSA and ECDH are supported in Chrome [only on Windows](https://sites.google.com/a/chromium.org/dev/blink/webcrypto#TOC-Supported-algorithms-as-of-Chrome-41-) (see also [bug 338883](https://code.google.com/p/chromium/issues/detail?id=338883)), aren't supported by Firefox (fixed only in 36.0+, see [bug 1034854](https://bugzilla.mozilla.org/show_bug.cgi?id=1034854); see also [feature matrix](https://docs.google.com/spreadsheet/ccc?key=0AiAcidBZRLxndE9LWEs2R1oxZ0xidUVoU3FQbFFobkE#gid=1)) and ECIES is not defined at all in WebCryptoAPI draft. Also WebCryptoAPI [currently defines](http://www.w3.org/TR/WebCryptoAPI/#EcKeyGenParams-dictionary) only curves recommended by NIST meaning that secp256k1 (K-256) curve is not supported (see also: [[1]](http://lists.w3.org/Archives/Public/public-webcrypto-comments/2013Dec/0001.html), [[2]](https://bugzilla.mozilla.org/show_bug.cgi?id=1051509)).
34
42
35
-
So we use [seck256k1](https://www.npmjs.com/package/secp256k1) library in Node for ECDSA, [elliptic](https://www.npmjs.com/package/elliptic) in Browser for ECDSA and ECDH and implement ECIES manually with the help of native crypto API.
43
+
```ts
44
+
import*aseccryptofrom"@toruslabs/eccrypto";
36
45
37
-
## Possible future goals
46
+
// Generate a new random 32-byte private key
47
+
const privateKey =eccrypto.generatePrivate();
38
48
39
-
- Support other curves/KDF/MAC/symmetric encryption schemes
49
+
// Get the corresponding public key (65 bytes uncompressed)
0 commit comments