Compare commits

..

No commits in common. "main" and "1.4.0" have entirely different histories.
main ... 1.4.0

13 changed files with 50 additions and 51 deletions

1
.github/funding.yml vendored
View File

@ -1 +1,2 @@
github: paulmillr
# custom: https://paulmillr.com/funding/

View File

@ -1,4 +1,4 @@
name: Run node.js tests
name: Node CI
on:
- push
- pull_request

View File

@ -1,4 +1,4 @@
name: Publish package to npm
name: Publish Package to npm
on:
release:
types: [created]

View File

@ -15,14 +15,13 @@ jobs:
node-version: 20
registry-url: 'https://registry.npmjs.org'
cache: npm
- run: npm install -g npm
- run: npm ci
- run: npm run build
- run: |
npm install -g npm
npm ci
npm run build
cd build
npm ci
npm run build:release
cd ..
- run: gh release upload ${{ github.event.release.tag_name }} build/`npx jsbt outfile`
npm run build
gh release upload ${{ github.event.release.tag_name }} noble-curves.js
env:
GH_TOKEN: ${{ github.token }}

View File

@ -555,7 +555,7 @@ import { Field } from '@noble/curves/abstract/modular';
const x25519 = montgomery({
a: 486662n,
Gu: 9n,
P: 2n ** 255n - 19n,
Fp: Field(2n ** 255n - 19n),
montgomeryBits: 255,
nByteLength: 32,
// Optional param

View File

@ -1,7 +1,7 @@
# build
The directory is used to build a single file which contains everything.
The directory is used to build a single file `noble-curves.js` which contains everything.
The single file uses iife wrapper and can be used in browsers as-is.
The output 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.

View File

@ -7,12 +7,14 @@
"": {
"name": "build",
"version": "1.0.0",
"license": "MIT",
"devDependencies": {
"@noble/curves": "file:..",
"esbuild": "0.20.1"
}
},
"..": {
"name": "@noble/curves",
"version": "1.4.0",
"dev": true,
"license": "MIT",
@ -20,7 +22,6 @@
"@noble/hashes": "1.4.0"
},
"devDependencies": {
"@paulmillr/jsbt": "0.1.0",
"fast-check": "3.0.0",
"micro-bmark": "0.3.1",
"micro-should": "0.4.0",

View File

@ -2,13 +2,17 @@
"name": "build",
"private": true,
"version": "1.0.0",
"description": "Used to build a single file",
"main": "input.js",
"keywords": [],
"type": "module",
"author": "",
"license": "MIT",
"devDependencies": {
"@noble/curves": "file:..",
"esbuild": "0.20.1"
},
"scripts": {
"build:release": "npx esbuild --bundle input.js --outfile=`npx jsbt outfile` --global-name=`npx jsbt global`"
"build": "npx esbuild --bundle input.js --outfile=noble-curves.js --global-name=nobleCurves"
}
}

18
package-lock.json generated
View File

@ -1,18 +1,17 @@
{
"name": "@tornado/noble-curves",
"version": "1.4.0",
"name": "@noble/curves",
"version": "1.3.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@tornado/noble-curves",
"version": "1.4.0",
"name": "@noble/curves",
"version": "1.3.0",
"license": "MIT",
"dependencies": {
"@noble/hashes": "1.4.0"
},
"devDependencies": {
"@paulmillr/jsbt": "0.1.0",
"fast-check": "3.0.0",
"micro-bmark": "0.3.1",
"micro-should": "0.4.0",
@ -34,15 +33,6 @@
"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": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/fast-check/-/fast-check-3.0.0.tgz",

View File

@ -1,5 +1,5 @@
{
"name": "@tornado/noble-curves",
"name": "@noble/curves",
"version": "1.4.0",
"description": "Audited & minimal JS implementation of elliptic curve cryptography",
"files": [
@ -24,14 +24,13 @@
"homepage": "https://paulmillr.com/noble/",
"repository": {
"type": "git",
"url": "https://git.tornado.ws/tornado-packages/noble-curvest"
"url": "git+https://github.com/paulmillr/noble-curves.git"
},
"license": "MIT",
"dependencies": {
"@noble/hashes": "1.4.0"
},
"devDependencies": {
"@paulmillr/jsbt": "0.1.0",
"fast-check": "3.0.0",
"micro-bmark": "0.3.1",
"micro-should": "0.4.0",

View File

@ -2,7 +2,7 @@ import { deepStrictEqual, throws } from 'assert';
import { should, describe } from 'micro-should';
import * as fc from 'fast-check';
import * as mod from '../esm/abstract/modular.js';
import { bytesToHex, isBytes, bytesToHex as toHex } from '../esm/abstract/utils.js';
import { bytesToHex as toHex } from '../esm/abstract/utils.js';
// Generic tests for all curves in package
import { secp192r1, secp224r1 } from './_more-curves.helpers.js';
import { secp256r1 } from '../esm/p256.js';
@ -595,18 +595,6 @@ for (const name in CURVES) {
{ 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', () => {
const msg = new Uint8Array([]);
const priv = C.utils.randomPrivateKey();

View File

@ -1,9 +1,25 @@
{
"extends": "@paulmillr/jsbt/tsconfigs/esm.json",
"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",
"target": "ES2015"
"moduleResolution": "Node16"
},
"include": ["index.ts", "src"],
"include": ["src"],
"exclude": ["node_modules", "lib"]
}

View File

@ -1,9 +1,10 @@
{
"extends": "@paulmillr/jsbt/tsconfigs/cjs.json",
"extends": "./tsconfig.esm.json",
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node10",
"outDir": ".",
"target": "ES2015"
},
"include": ["index.ts", "src"],
"exclude": ["node_modules", "lib"]
"declaration": true,
"declarationMap": true
}
}