forked from tornado-packages/noble-curves
weierstrass: remove most private utils
This commit is contained in:
parent
f250f355e8
commit
c46914f1bc
@ -641,12 +641,7 @@ export type CurveFn = {
|
||||
ProjectivePoint: ProjConstructor<bigint>;
|
||||
Signature: SignatureConstructor;
|
||||
utils: {
|
||||
_bigintToBytes: (num: bigint) => Uint8Array;
|
||||
_bigintToString: (num: bigint) => string;
|
||||
_normalizePrivateKey: (key: PrivKey) => bigint;
|
||||
_isWithinCurveOrder: (num: bigint) => boolean;
|
||||
_isValidFieldElement: (num: bigint) => boolean;
|
||||
_weierstrassEquation: (x: bigint) => bigint;
|
||||
isValidPrivateKey(privateKey: PrivKey): boolean;
|
||||
hashToPrivateKey: (hash: Hex) => Uint8Array;
|
||||
randomPrivateKey: () => Uint8Array;
|
||||
@ -884,12 +879,7 @@ export function weierstrass(curveDef: CurveType): CurveFn {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
_bigintToBytes: numToField,
|
||||
_bigintToString: numToFieldStr,
|
||||
_normalizePrivateKey: normalizePrivateKey,
|
||||
_isWithinCurveOrder: isWithinCurveOrder,
|
||||
_isValidFieldElement: isValidFieldElement,
|
||||
_weierstrassEquation: weierstrassEquation,
|
||||
|
||||
/**
|
||||
* Converts some bytes to a valid private key. Needs at least (nBitLength+64) bytes.
|
||||
|
@ -1,6 +1,7 @@
|
||||
import * as fc from 'fast-check';
|
||||
import { secp256k1, schnorr } from '../lib/esm/secp256k1.js';
|
||||
import { Fp } from '../lib/esm/abstract/modular.js';
|
||||
import { bytesToNumberBE, numberToBytesBE } from '../lib/esm/abstract/utils.js';
|
||||
import { readFileSync } from 'fs';
|
||||
import { default as ecdsa } from './vectors/ecdsa.json' assert { type: 'json' };
|
||||
import { default as ecdh } from './vectors/ecdh.json' assert { type: 'json' };
|
||||
@ -464,12 +465,11 @@ describe('secp256k1', () => {
|
||||
privateAdd: (privateKey, tweak) => {
|
||||
const p = normal(privateKey);
|
||||
const t = normal(tweak);
|
||||
return secp.utils._bigintToBytes(Fn.create(p + t));
|
||||
return numberToBytesBE(Fn.create(p + t), 32);
|
||||
},
|
||||
|
||||
privateNegate: (privateKey) => {
|
||||
const p = normal(privateKey);
|
||||
return secp.utils._bigintToBytes(Fn.negate(p));
|
||||
return numberToBytesBE(Fn.negate(normal(privateKey)), 32);
|
||||
},
|
||||
|
||||
pointAddScalar: (p, tweak, isCompressed) => {
|
||||
|
Loading…
Reference in New Issue
Block a user