ufsecp 3.11.0 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # ultrafast-secp256k1
2
+
3
+ High-performance Node.js native addon for secp256k1 elliptic curve cryptography, powered by [UltrafastSecp256k1](https://github.com/shrec/UltrafastSecp256k1).
4
+
5
+ ## Features
6
+
7
+ - **ECDSA** — sign, verify, recover, DER serialization (RFC 6979)
8
+ - **Schnorr** — BIP-340 sign/verify
9
+ - **ECDH** — compressed, x-only, raw shared secret
10
+ - **BIP-32** — HD key derivation
11
+ - **Taproot** — output key tweaking (BIP-341)
12
+ - **Addresses** — P2PKH, P2WPKH, P2TR
13
+ - **WIF** — encode/decode
14
+ - **Hashing** — SHA-256 (hardware-accelerated), HASH160, tagged hash
15
+ - **Constant-time** — all secret-key operations use CT layer automatically
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ npm install ultrafast-secp256k1
21
+ ```
22
+
23
+ Requires a C++ compiler and `node-gyp` (the native addon is built on install).
24
+
25
+ ## Quick Start
26
+
27
+ ```js
28
+ const { Secp256k1 } = require('ultrafast-secp256k1');
29
+ const crypto = require('crypto');
30
+
31
+ const secp = new Secp256k1();
32
+
33
+ // Generate a random private key
34
+ const privkey = crypto.randomBytes(32);
35
+
36
+ // Derive compressed public key (33 bytes)
37
+ const pubkey = secp.ecPubkeyCreate(privkey);
38
+ console.log('pubkey:', pubkey.toString('hex'));
39
+ ```
40
+
41
+ ## ECDSA Sign & Verify
42
+
43
+ ```js
44
+ const msgHash = secp.sha256(Buffer.from('hello world'));
45
+
46
+ // Sign (RFC 6979 deterministic nonce, low-S)
47
+ const sig = secp.ecdsaSign(msgHash, privkey);
48
+
49
+ // Verify
50
+ const valid = secp.ecdsaVerify(msgHash, sig, pubkey);
51
+ console.log('ECDSA valid:', valid); // true
52
+
53
+ // DER-encode for transmission
54
+ const der = secp.ecdsaSerializeDer(sig);
55
+ ```
56
+
57
+ ## Schnorr (BIP-340)
58
+
59
+ ```js
60
+ const xOnlyPub = secp.schnorrPubkey(privkey);
61
+ const auxRand = crypto.randomBytes(32);
62
+ const msg = secp.sha256(Buffer.from('schnorr message'));
63
+
64
+ const schnorrSig = secp.schnorrSign(msg, privkey, auxRand);
65
+ const ok = secp.schnorrVerify(msg, schnorrSig, xOnlyPub);
66
+ console.log('Schnorr valid:', ok); // true
67
+ ```
68
+
69
+ ## ECDH
70
+
71
+ ```js
72
+ const otherPriv = crypto.randomBytes(32);
73
+ const otherPub = secp.ecPubkeyCreate(otherPriv);
74
+
75
+ const shared = secp.ecdh(privkey, otherPub); // SHA-256 of compressed point
76
+ const xonly = secp.ecdhXonly(privkey, otherPub); // SHA-256 of x-coordinate
77
+ const raw = secp.ecdhRaw(privkey, otherPub); // raw 32-byte x-coordinate
78
+ ```
79
+
80
+ ## Bitcoin Addresses
81
+
82
+ ```js
83
+ const { NETWORK_MAINNET, NETWORK_TESTNET } = require('ultrafast-secp256k1');
84
+
85
+ const p2pkh = secp.addressP2PKH(pubkey, NETWORK_MAINNET); // 1...
86
+ const p2wpkh = secp.addressP2WPKH(pubkey, NETWORK_MAINNET); // bc1q...
87
+ const p2tr = secp.addressP2TR(xOnlyPub, NETWORK_MAINNET); // bc1p...
88
+ ```
89
+
90
+ ## BIP-32 HD Derivation
91
+
92
+ ```js
93
+ const seed = crypto.randomBytes(64);
94
+ const master = secp.bip32MasterKey(seed);
95
+ const child = secp.bip32DerivePath(master, "m/44'/0'/0'/0/0");
96
+ const childPriv = secp.bip32GetPrivkey(child);
97
+ const childPub = secp.bip32GetPubkey(child);
98
+ ```
99
+
100
+ ## WIF
101
+
102
+ ```js
103
+ const wif = secp.wifEncode(privkey, true, NETWORK_MAINNET);
104
+ const { privkey: decoded, compressed, network } = secp.wifDecode(wif);
105
+ ```
106
+
107
+ ## Taproot
108
+
109
+ ```js
110
+ const { outputKeyX, parity } = secp.taprootOutputKey(xOnlyPub);
111
+ const tweakedPriv = secp.taprootTweakPrivkey(privkey);
112
+ ```
113
+
114
+ ## Performance
115
+
116
+ Built on hand-optimized C/C++ with platform-specific acceleration (AVX2, SHA-NI, BMI2 on x86; NEON on ARM). All secret-key operations use the constant-time layer — no opt-in required.
117
+
118
+ | Operation | x86-64 | ARM64 | RISC-V |
119
+ |-----------|--------|-------|--------|
120
+ | ECDSA Sign | 8 μs | 30 μs | — |
121
+ | kG (generator mul) | 5 μs | 14 μs | 33 μs |
122
+ | kP (arbitrary mul) | 25 μs | 131 μs | 154 μs |
123
+
124
+ ## License
125
+
126
+ MIT
127
+
128
+ ## Links
129
+
130
+ - [GitHub](https://github.com/shrec/UltrafastSecp256k1)
131
+ - [Benchmarks](https://github.com/shrec/UltrafastSecp256k1/blob/main/libs/UltrafastSecp256k1/docs/BENCHMARKS.md)
132
+ - [Changelog](https://github.com/shrec/UltrafastSecp256k1/blob/main/libs/UltrafastSecp256k1/CHANGELOG.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ufsecp",
3
- "version": "3.11.0",
3
+ "version": "3.12.0",
4
4
  "description": "Node.js bindings for UltrafastSecp256k1 — high-performance secp256k1 ECC (ufsecp C ABI v1)",
5
5
  "main": "lib/ufsecp.js",
6
6
  "files": ["lib/ufsecp.js", "prebuilds/", "README.md"],
@@ -18,10 +18,10 @@
18
18
  "license": "AGPL-3.0-only",
19
19
  "repository": {
20
20
  "type": "git",
21
- "url": "https://github.com/AvraSasmo/UltrafastSecp256k1"
21
+ "url": "https://github.com/shrec/UltrafastSecp256k1"
22
22
  },
23
23
  "engines": {
24
24
  "node": ">=16.0.0"
25
25
  },
26
- "homepage": "https://github.com/AvraSasmo/UltrafastSecp256k1"
26
+ "homepage": "https://github.com/shrec/UltrafastSecp256k1"
27
27
  }
Binary file
index 0f0ff53..0b87373 100755
Binary file
Binary file
Binary file
Binary file