Add CURVE.p param

This commit is contained in:
Paul Miller 2023-03-21 02:06:06 +00:00
parent 1c6aa07ff7
commit a8b8192714
No known key found for this signature in database
GPG Key ID: 697079DA6878B89B
2 changed files with 9 additions and 1 deletions

@ -152,6 +152,13 @@ import { hashToCurve, encodeToCurve } from '@noble/curves/ed448';
ed448.getPublicKey(ed448.utils.randomPrivateKey());
```
Every curve has params:
```ts
import { secp256k1 } from '@noble/curves/secp256k1'; // ESM and Common.js
console.log(secp256k1.CURVE.p, secp256k1.CURVE.n, secp256k1.CURVE.a, secp256k1.CURVE.b);
```
BLS12-381 pairing-friendly Barreto-Lynn-Scott elliptic curve construction allows to
construct [zk-SNARKs](https://z.cash/technology/zksnarks/) at the 128-bit security
and use aggregated, batch-verifiable
@ -359,6 +366,7 @@ point.assertValidity(); // Checks for being on-curve
point.toAffine(); // Converts to 2d affine xy coordinates
secq256k1.CURVE.n;
secq256k1.CURVE.p;
secq256k1.CURVE.Fp.mod();
secq256k1.CURVE.hash();

@ -195,5 +195,5 @@ export function validateBasic<FP, T>(curve: BasicCurve<FP> & T) {
}
);
// Set defaults
return Object.freeze({ ...nLength(curve.n, curve.nBitLength), ...curve } as const);
return Object.freeze({ ...nLength(curve.n, curve.nBitLength), ...curve, ...{p: curve.Fp.ORDER} } as const);
}