Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a8ea9d757f | |||
|
|
efeca9f478 | ||
|
|
8ad2f9a185 | ||
|
|
be576b4c17 | ||
|
|
819514576c |
1
.github/funding.yml
vendored
1
.github/funding.yml
vendored
@ -1,2 +1 @@
|
|||||||
github: paulmillr
|
github: paulmillr
|
||||||
# custom: https://paulmillr.com/funding/
|
|
||||||
2
.github/workflows/nodejs.yml
vendored
2
.github/workflows/nodejs.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: Node CI
|
name: Run node.js tests
|
||||||
on:
|
on:
|
||||||
- push
|
- push
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|||||||
2
.github/workflows/publish-npm.yml
vendored
2
.github/workflows/publish-npm.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: Publish Package to npm
|
name: Publish package to npm
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|||||||
11
.github/workflows/upload-release.yml
vendored
11
.github/workflows/upload-release.yml
vendored
@ -15,13 +15,14 @@ jobs:
|
|||||||
node-version: 20
|
node-version: 20
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
cache: npm
|
cache: npm
|
||||||
|
- run: npm install -g npm
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run build
|
||||||
- run: |
|
- run: |
|
||||||
npm install -g npm
|
|
||||||
npm ci
|
|
||||||
npm run build
|
|
||||||
cd build
|
cd build
|
||||||
npm ci
|
npm ci
|
||||||
npm run build
|
npm run build:release
|
||||||
gh release upload ${{ github.event.release.tag_name }} noble-curves.js
|
cd ..
|
||||||
|
- run: gh release upload ${{ github.event.release.tag_name }} build/`npx jsbt outfile`
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
|||||||
@ -555,7 +555,7 @@ import { Field } from '@noble/curves/abstract/modular';
|
|||||||
const x25519 = montgomery({
|
const x25519 = montgomery({
|
||||||
a: 486662n,
|
a: 486662n,
|
||||||
Gu: 9n,
|
Gu: 9n,
|
||||||
Fp: Field(2n ** 255n - 19n),
|
P: 2n ** 255n - 19n,
|
||||||
montgomeryBits: 255,
|
montgomeryBits: 255,
|
||||||
nByteLength: 32,
|
nByteLength: 32,
|
||||||
// Optional param
|
// Optional param
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# build
|
# build
|
||||||
|
|
||||||
The directory is used to build a single file `noble-curves.js` which contains everything.
|
The directory is used to build a single file which contains everything.
|
||||||
|
|
||||||
The output file uses iife wrapper and can be used in browsers as-is.
|
The single file uses iife wrapper and can be used in browsers as-is.
|
||||||
|
|
||||||
Don't use it unless you can't use NPM/ESM, which support tree shaking.
|
Don't use it unless you can't use NPM/ESM, which support tree shaking.
|
||||||
|
|||||||
3
build/package-lock.json
generated
3
build/package-lock.json
generated
@ -7,14 +7,12 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "build",
|
"name": "build",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "MIT",
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@noble/curves": "file:..",
|
"@noble/curves": "file:..",
|
||||||
"esbuild": "0.20.1"
|
"esbuild": "0.20.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"..": {
|
"..": {
|
||||||
"name": "@noble/curves",
|
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -22,6 +20,7 @@
|
|||||||
"@noble/hashes": "1.4.0"
|
"@noble/hashes": "1.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@paulmillr/jsbt": "0.1.0",
|
||||||
"fast-check": "3.0.0",
|
"fast-check": "3.0.0",
|
||||||
"micro-bmark": "0.3.1",
|
"micro-bmark": "0.3.1",
|
||||||
"micro-should": "0.4.0",
|
"micro-should": "0.4.0",
|
||||||
|
|||||||
@ -2,17 +2,13 @@
|
|||||||
"name": "build",
|
"name": "build",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Used to build a single file",
|
|
||||||
"main": "input.js",
|
"main": "input.js",
|
||||||
"keywords": [],
|
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"author": "",
|
|
||||||
"license": "MIT",
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@noble/curves": "file:..",
|
"@noble/curves": "file:..",
|
||||||
"esbuild": "0.20.1"
|
"esbuild": "0.20.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npx esbuild --bundle input.js --outfile=noble-curves.js --global-name=nobleCurves"
|
"build:release": "npx esbuild --bundle input.js --outfile=`npx jsbt outfile` --global-name=`npx jsbt global`"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
package-lock.json
generated
18
package-lock.json
generated
@ -1,17 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "@noble/curves",
|
"name": "@tornado/noble-curves",
|
||||||
"version": "1.3.0",
|
"version": "1.4.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@noble/curves",
|
"name": "@tornado/noble-curves",
|
||||||
"version": "1.3.0",
|
"version": "1.4.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@noble/hashes": "1.4.0"
|
"@noble/hashes": "1.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@paulmillr/jsbt": "0.1.0",
|
||||||
"fast-check": "3.0.0",
|
"fast-check": "3.0.0",
|
||||||
"micro-bmark": "0.3.1",
|
"micro-bmark": "0.3.1",
|
||||||
"micro-should": "0.4.0",
|
"micro-should": "0.4.0",
|
||||||
@ -33,6 +34,15 @@
|
|||||||
"url": "https://paulmillr.com/funding/"
|
"url": "https://paulmillr.com/funding/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@paulmillr/jsbt": {
|
||||||
|
"version": "0.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@paulmillr/jsbt/-/jsbt-0.1.0.tgz",
|
||||||
|
"integrity": "sha512-TdowoHD36hkZARv6LW4jenkVTdK2vP0sy4ZM8E9MxaqAAIRdwmn3RlB+zWkEHi4hKTgLqMGkURfNkFtt0STX2Q==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"jsbt": "jsbt.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fast-check": {
|
"node_modules/fast-check": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/fast-check/-/fast-check-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/fast-check/-/fast-check-3.0.0.tgz",
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "@noble/curves",
|
"name": "@tornado/noble-curves",
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"description": "Audited & minimal JS implementation of elliptic curve cryptography",
|
"description": "Audited & minimal JS implementation of elliptic curve cryptography",
|
||||||
"files": [
|
"files": [
|
||||||
@ -24,13 +24,14 @@
|
|||||||
"homepage": "https://paulmillr.com/noble/",
|
"homepage": "https://paulmillr.com/noble/",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/paulmillr/noble-curves.git"
|
"url": "https://git.tornado.ws/tornado-packages/noble-curvest"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@noble/hashes": "1.4.0"
|
"@noble/hashes": "1.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@paulmillr/jsbt": "0.1.0",
|
||||||
"fast-check": "3.0.0",
|
"fast-check": "3.0.0",
|
||||||
"micro-bmark": "0.3.1",
|
"micro-bmark": "0.3.1",
|
||||||
"micro-should": "0.4.0",
|
"micro-should": "0.4.0",
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { deepStrictEqual, throws } from 'assert';
|
|||||||
import { should, describe } from 'micro-should';
|
import { should, describe } from 'micro-should';
|
||||||
import * as fc from 'fast-check';
|
import * as fc from 'fast-check';
|
||||||
import * as mod from '../esm/abstract/modular.js';
|
import * as mod from '../esm/abstract/modular.js';
|
||||||
import { bytesToHex as toHex } from '../esm/abstract/utils.js';
|
import { bytesToHex, isBytes, bytesToHex as toHex } from '../esm/abstract/utils.js';
|
||||||
// Generic tests for all curves in package
|
// Generic tests for all curves in package
|
||||||
import { secp192r1, secp224r1 } from './_more-curves.helpers.js';
|
import { secp192r1, secp224r1 } from './_more-curves.helpers.js';
|
||||||
import { secp256r1 } from '../esm/p256.js';
|
import { secp256r1 } from '../esm/p256.js';
|
||||||
@ -595,6 +595,18 @@ for (const name in CURVES) {
|
|||||||
{ numRuns: NUM_RUNS }
|
{ numRuns: NUM_RUNS }
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
should('.verify() should verify random signatures in hex', () =>
|
||||||
|
fc.assert(
|
||||||
|
fc.property(fc.hexaString({ minLength: 64, maxLength: 64 }), (msg) => {
|
||||||
|
const priv = toHex(C.utils.randomPrivateKey());
|
||||||
|
const pub = toHex(C.getPublicKey(priv));
|
||||||
|
const sig = C.sign(msg, priv);
|
||||||
|
let sighex = isBytes(sig) ? toHex(sig) : sig.toCompactHex();
|
||||||
|
deepStrictEqual(C.verify(sighex, msg, pub), true, `priv=${priv},pub=${pub},msg=${msg}`);
|
||||||
|
}),
|
||||||
|
{ numRuns: NUM_RUNS }
|
||||||
|
)
|
||||||
|
);
|
||||||
should('.verify() should verify empty signatures', () => {
|
should('.verify() should verify empty signatures', () => {
|
||||||
const msg = new Uint8Array([]);
|
const msg = new Uint8Array([]);
|
||||||
const priv = C.utils.randomPrivateKey();
|
const priv = C.utils.randomPrivateKey();
|
||||||
|
|||||||
@ -1,25 +1,9 @@
|
|||||||
{
|
{
|
||||||
|
"extends": "@paulmillr/jsbt/tsconfigs/esm.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es2020",
|
|
||||||
"lib": ["es2020"],
|
|
||||||
"strict": true,
|
|
||||||
"sourceMap": true,
|
|
||||||
"allowSyntheticDefaultImports": false,
|
|
||||||
"allowUnreachableCode": false,
|
|
||||||
"esModuleInterop": false,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"noImplicitReturns": true,
|
|
||||||
"noUncheckedIndexedAccess": false,
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"noUnusedParameters": true,
|
|
||||||
"baseUrl": ".",
|
|
||||||
"paths": {
|
|
||||||
"@noble/hashes/crypto": ["src/crypto.ts"]
|
|
||||||
},
|
|
||||||
"module": "Node16",
|
|
||||||
"outDir": "esm",
|
"outDir": "esm",
|
||||||
"moduleResolution": "Node16"
|
"target": "ES2015"
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["index.ts", "src"],
|
||||||
"exclude": ["node_modules", "lib"]
|
"exclude": ["node_modules", "lib"]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
{
|
{
|
||||||
"extends": "./tsconfig.esm.json",
|
"extends": "@paulmillr/jsbt/tsconfigs/cjs.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "commonjs",
|
|
||||||
"moduleResolution": "node10",
|
|
||||||
"outDir": ".",
|
"outDir": ".",
|
||||||
"declaration": true,
|
"target": "ES2015"
|
||||||
"declarationMap": true
|
},
|
||||||
}
|
"include": ["index.ts", "src"],
|
||||||
|
"exclude": ["node_modules", "lib"]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user