Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0: massively reduce library size, remove features #92

Merged
merged 43 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a1a990d
Prepare tests for micro
paulmillr Jan 13, 2023
875d38c
micro-noble-secp. Iteration 1: 8115
paulmillr Jan 13, 2023
6d752c6
micro-noble-secp. Iteration 2: 8681
paulmillr Jan 13, 2023
bc87ff5
micro-noble-secp. Iteration 3: 7418
paulmillr Jan 13, 2023
01d014d
Add some comments. Iteration 4: 7071, 368LOC
paulmillr Jan 14, 2023
db19abb
Benchmark. Iteration 5: 6953, 350LOC
paulmillr Jan 14, 2023
ddcc56d
Speed-up verification. Iteration 6: 6967, 345LOC
paulmillr Jan 14, 2023
56332e6
wNAF precomputes, 10x faster sign. Iteration 7: 7458, 387LOC
paulmillr Jan 14, 2023
15d5482
Bring back wychenproof vectors and pubkey recovery tests
paulmillr Jan 14, 2023
96b70b0
Sync methods, extraEntropy, Point->JPoint, error map. Iteration 8: 80…
paulmillr Jan 17, 2023
5f9abe6
Make default points compressed. Ban DER. Iteration 9: 8111, 424LOC
paulmillr Jan 18, 2023
bf159a9
Update README
paulmillr Jan 18, 2023
a5f8d3a
README
paulmillr Jan 18, 2023
4e5facf
README
paulmillr Jan 18, 2023
0045f1d
Docs
paulmillr Jan 18, 2023
fc66eb3
README
paulmillr Jan 18, 2023
c540054
Docs
paulmillr Jan 18, 2023
b33c164
Docs
paulmillr Jan 18, 2023
f9a140d
Add error messages. bits2int, truncateHash match curves. 8454, 419LOC.
paulmillr Jan 23, 2023
ff5f081
Improve hmac-drbg logic and k generation
paulmillr Jan 24, 2023
99b5732
Rename sign => signAsync, signSync => sign for compat with curves. 85…
paulmillr Jan 24, 2023
d1283ab
Compat with curves. 8768, 439LOC
paulmillr Jan 31, 2023
d0ed59f
Fix hexToNum bug
paulmillr Jan 31, 2023
6c0d92e
Fix deno
paulmillr Jan 31, 2023
d9cfbb7
Merge branch 'main' into micro
paulmillr Feb 4, 2023
0dee9b0
Updates
paulmillr Feb 4, 2023
021893a
Adjustments
paulmillr Feb 7, 2023
91192ad
Remove rollup, terser
paulmillr Feb 9, 2023
d480436
Improve exports
paulmillr Feb 9, 2023
9011dba
README updates
paulmillr Feb 9, 2023
e68ba4b
Comments
paulmillr Feb 9, 2023
86e4d02
Drop jest. Reuse tests from curves
paulmillr Feb 9, 2023
12039c1
pkg.json
paulmillr Feb 9, 2023
7db987c
ci: use node 19
paulmillr Feb 9, 2023
61276e4
use node:crypto
paulmillr Feb 11, 2023
9247e05
Fix import
paulmillr Mar 15, 2023
49fa33d
Fix deno
paulmillr Mar 15, 2023
9c7d552
Line-up
paulmillr Mar 15, 2023
375b026
Pure-ESM package
paulmillr Mar 15, 2023
2d4cddb
README: 80-char limit
paulmillr Mar 16, 2023
0d7d540
Commit build output and lockfile to repo
paulmillr Mar 16, 2023
7a2bfec
Separate build directory for terser
paulmillr Mar 16, 2023
9aebbc9
Produce index.js with comments
paulmillr Mar 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: Node CI
on: [push, pull_request]
jobs:
test:
name: v18 @ ubuntu-latest
name: v19 @ ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 19
- run: npm install
- run: npm run build --if-present
- run: npm test
Expand Down
487 changes: 182 additions & 305 deletions README.md

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions build/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions build/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "build",
"private": true,
"version": "1.0.0",
"description": "Builds minified file",
"main": "noble-secp256k1.js",
"scripts": {
"terser": "terser --ecma 2020 -m -c < ../index.js"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"terser": "5.16.6"
}
}
92 changes: 92 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
export declare const CURVE: {
P: bigint;
n: bigint;
a: bigint;
b: bigint;
Gx: bigint;
Gy: bigint;
};
declare type Bytes = Uint8Array;
declare type Hex = Bytes | string;
declare type PrivKey = Hex | bigint;
interface AffinePoint {
x: bigint;
y: bigint;
}
declare class Point {
readonly px: bigint;
readonly py: bigint;
readonly pz: bigint;
constructor(px: bigint, py: bigint, pz: bigint);
static readonly BASE: Point;
static readonly ZERO: Point;
get x(): bigint;
get y(): bigint;
equals(other: Point): boolean;
neg(): Point;
dbl(): Point;
add(other: Point): Point;
mul(n: bigint, safe?: boolean): Point;
mulAddQUns(R: Point, u1: bigint, u2: bigint): Point;
aff(): AffinePoint;
ok(): Point;
multiply(n: bigint): Point;
negate(): Point;
toAffine(): AffinePoint;
assertValidity(): Point;
static fromHex(hex: Hex): Point;
toHex(isCompressed?: boolean): string;
toRawBytes(isCompressed?: boolean): Uint8Array;
static fromPrivateKey(n: PrivKey): Point;
}
export declare const getPublicKey: (privKey: PrivKey, isCompressed?: boolean) => Uint8Array;
export declare class Signature {
readonly r: bigint;
readonly s: bigint;
readonly recovery?: number | undefined;
constructor(r: bigint, s: bigint, recovery?: number | undefined);
ok(): Signature;
static fromCompact(hex: Hex): Signature;
hasHighS(): boolean;
recoverPublicKey(msgh: Hex): Point;
toCompactRawBytes(): Uint8Array;
toCompactHex(): string;
}
declare type HmacFnSync = undefined | ((key: Bytes, ...msgs: Bytes[]) => Bytes);
export declare const signAsync: (msgh: Hex, priv: Hex, opts?: {
lowS?: boolean | undefined;
extraEntropy?: boolean | Hex | undefined;
}) => Promise<Signature>;
export declare const sign: (msgh: Hex, priv: Hex, opts?: {
lowS?: boolean | undefined;
extraEntropy?: boolean | Hex | undefined;
}) => Signature;
declare type SigLike = {
r: bigint;
s: bigint;
};
export declare const verify: (sig: Hex | SigLike, msgh: Hex, pub: Hex, opts?: {
lowS: boolean;
}) => boolean;
export declare const getSharedSecret: (privA: Hex, pubB: Hex, isCompressed?: boolean) => Uint8Array;
export declare const etc: {
hexToBytes: (hex: string) => Bytes;
bytesToHex: (b: Bytes) => string;
concatBytes: (...arrs: Bytes[]) => Uint8Array;
bytesToNumberBE: (b: Bytes) => bigint;
numberToBytesBE: (num: bigint) => Bytes;
mod: (a: bigint, b?: bigint) => bigint;
invert: (num: bigint, md?: bigint) => bigint;
hmacSha256Async: (key: Bytes, ...msgs: Bytes[]) => Promise<Bytes>;
hmacSha256Sync: HmacFnSync;
hashToPrivateKey: (hash: Hex) => Bytes;
randomBytes: (len: number) => Bytes;
};
export declare const utils: {
normPrivateKeyToScalar: (p: PrivKey) => bigint;
randomPrivateKey: () => Bytes;
isValidPrivateKey: (key: Hex) => boolean;
precompute(p: Point, windowSize?: number): Point;
};
export declare const ProjectivePoint: typeof Point;
export {};
Loading