Skip to content

Commit

Permalink
Merge pull request #76 from paulmillr/micro
Browse files Browse the repository at this point in the history
v2.0: massively reduce library size, remove features
  • Loading branch information
paulmillr authored Mar 16, 2023
2 parents 7e4f9da + ff27719 commit 641a346
Show file tree
Hide file tree
Showing 21 changed files with 6,341 additions and 1,915 deletions.
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
356 changes: 112 additions & 244 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"
}
}
75 changes: 75 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
export declare const CURVE: {
a: bigint;
d: bigint;
P: bigint;
l: bigint;
n: bigint;
h: number;
Gx: bigint;
Gy: bigint;
};
declare type Bytes = Uint8Array;
declare type Hex = Bytes | string;
declare type PubKey = Hex | Point;
interface AffinePoint {
x: bigint;
y: bigint;
}
declare class Point {
readonly ex: bigint;
readonly ey: bigint;
readonly ez: bigint;
readonly et: bigint;
constructor(ex: bigint, ey: bigint, ez: bigint, et: bigint);
static readonly BASE: Point;
static readonly ZERO: Point;
static fromAffine(p: AffinePoint): Point;
get x(): bigint;
get y(): bigint;
eql(other: Point): boolean;
neg(): Point;
dbl(): Point;
add(other: Point): Point;
sub(p: Point): Point;
mul(n: bigint, safe?: boolean): Point;
multiply(scalar: bigint): Point;
clearCofactor(): Point;
isSmallOrder(): boolean;
isTorsionFree(): boolean;
aff(): AffinePoint;
static fromHex(hex: Hex, strict?: boolean): Point;
toRawBytes(): Bytes;
toHex(): string;
}
export declare const ExtendedPoint: typeof Point;
declare type Sha512FnSync = undefined | ((...messages: Bytes[]) => Bytes);
declare type ExtK = {
head: Bytes;
prefix: Bytes;
scalar: bigint;
point: Point;
pointBytes: Bytes;
};
export declare const getPublicKeyAsync: (priv: Hex) => Promise<Bytes>;
export declare const getPublicKey: (priv: Hex) => Bytes;
export declare const signAsync: (msg: Hex, privKey: Hex) => Promise<Bytes>;
export declare const sign: (msg: Hex, privKey: Hex) => Bytes;
export declare const verifyAsync: (sig: Hex, msg: Hex, pubKey: PubKey) => Promise<boolean>;
export declare const verify: (sig: Hex, msg: Hex, pubKey: PubKey) => boolean;
export declare const etc: {
bytesToHex: (b: Bytes) => string;
hexToBytes: (hex: string) => Bytes;
concatBytes: (...arrs: Bytes[]) => Uint8Array;
mod: (a: bigint, b?: bigint) => bigint;
invert: (num: bigint, md?: bigint) => bigint;
randomBytes: (len: number) => Bytes;
sha512Async: (...messages: Bytes[]) => Promise<Bytes>;
sha512Sync: Sha512FnSync;
};
export declare const utils: {
getExtendedPublicKeyAsync: (priv: Hex) => Promise<ExtK>;
getExtendedPublicKey: (priv: Hex) => ExtK;
precompute(p: Point, w?: number): Point;
randomPrivateKey: () => Bytes;
};
export {};
Loading

0 comments on commit 641a346

Please sign in to comment.