@noble/bls12-381
Advanced tools
Comparing version 1.0.0 to 1.0.1
31
index.js
@@ -16,5 +16,4 @@ "use strict"; | ||
const SHA256_DIGEST_SIZE = 32; | ||
let DST_LABEL = 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_'; | ||
const htfDefaults = { | ||
DST: DST_LABEL, | ||
DST: 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_', | ||
p: math_1.CURVE.P, | ||
@@ -74,3 +73,3 @@ m: 2, | ||
getDSTLabel() { | ||
return DST_LABEL; | ||
return htfDefaults.DST; | ||
}, | ||
@@ -81,3 +80,3 @@ setDSTLabel(newLabel) { | ||
} | ||
DST_LABEL = newLabel; | ||
htfDefaults.DST = newLabel; | ||
}, | ||
@@ -207,3 +206,3 @@ }; | ||
const tv = pseudo_random_bytes.slice(elm_offset, elm_offset + L); | ||
e[j] = math_1.mod(os2ip(tv), htfOptions.p); | ||
e[j] = (0, math_1.mod)(os2ip(tv), htfOptions.p); | ||
} | ||
@@ -226,3 +225,3 @@ u[i] = e; | ||
throw new TypeError('Expected valid private key'); | ||
int = math_1.mod(int, math_1.CURVE.r); | ||
int = (0, math_1.mod)(int, math_1.CURVE.r); | ||
if (!isWithinCurveOrder(int)) | ||
@@ -249,7 +248,7 @@ throw new Error('Private key must be 0 < key < CURVE.r'); | ||
const compressedValue = bytesToNumberBE(bytes); | ||
const bflag = math_1.mod(compressedValue, POW_2_383) / POW_2_382; | ||
const bflag = (0, math_1.mod)(compressedValue, POW_2_383) / POW_2_382; | ||
if (bflag === 1n) { | ||
return this.ZERO; | ||
} | ||
const x = new math_1.Fp(math_1.mod(compressedValue, POW_2_381)); | ||
const x = new math_1.Fp((0, math_1.mod)(compressedValue, POW_2_381)); | ||
const right = x.pow(3n).add(new math_1.Fp(math_1.CURVE.b)); | ||
@@ -259,3 +258,3 @@ let y = right.sqrt(); | ||
throw new Error('Invalid compressed G1 point'); | ||
const aflag = math_1.mod(compressedValue, POW_2_382) / POW_2_381; | ||
const aflag = (0, math_1.mod)(compressedValue, POW_2_382) / POW_2_381; | ||
if ((y.value * 2n) / P !== aflag) | ||
@@ -322,3 +321,3 @@ y = y.negate(); | ||
millerLoop(P) { | ||
return math_1.millerLoop(P.pairingPrecomputes(), this.toAffine()); | ||
return (0, math_1.millerLoop)(P.pairingPrecomputes(), this.toAffine()); | ||
} | ||
@@ -364,4 +363,4 @@ clearCofactor() { | ||
const u = await hash_to_field(msg, 2); | ||
const Q0 = new PointG2(...math_1.isogenyMapG2(math_1.map_to_curve_simple_swu_9mod16(u[0]))); | ||
const Q1 = new PointG2(...math_1.isogenyMapG2(math_1.map_to_curve_simple_swu_9mod16(u[1]))); | ||
const Q0 = new PointG2(...(0, math_1.isogenyMapG2)((0, math_1.map_to_curve_simple_swu_9mod16)(u[0]))); | ||
const Q1 = new PointG2(...(0, math_1.isogenyMapG2)((0, math_1.map_to_curve_simple_swu_9mod16)(u[1]))); | ||
const R = Q0.add(Q1); | ||
@@ -379,3 +378,3 @@ const P = R.clearCofactor(); | ||
const z2 = bytesToNumberBE(hex.slice(half)); | ||
const bflag1 = math_1.mod(z1, POW_2_383) / POW_2_382; | ||
const bflag1 = (0, math_1.mod)(z1, POW_2_383) / POW_2_382; | ||
if (bflag1 === 1n) | ||
@@ -466,6 +465,6 @@ return this.ZERO; | ||
psi() { | ||
return this.fromAffineTuple(math_1.psi(...this.toAffine())); | ||
return this.fromAffineTuple((0, math_1.psi)(...this.toAffine())); | ||
} | ||
psi2() { | ||
return this.fromAffineTuple(math_1.psi2(...this.toAffine())); | ||
return this.fromAffineTuple((0, math_1.psi2)(...this.toAffine())); | ||
} | ||
@@ -512,3 +511,3 @@ mulNegX() { | ||
return this._PPRECOMPUTES; | ||
this._PPRECOMPUTES = math_1.calcPairingPrecomputes(...this.toAffine()); | ||
this._PPRECOMPUTES = (0, math_1.calcPairingPrecomputes)(...this.toAffine()); | ||
return this._PPRECOMPUTES; | ||
@@ -515,0 +514,0 @@ } |
{ | ||
"name": "@noble/bls12-381", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Fastest JS implementation of BLS12-381. Auditable, secure, 0-dependency aggregated signatures & pairings", | ||
@@ -40,3 +40,3 @@ "main": "index.js", | ||
"ts-jest": "^27", | ||
"typescript": "^4.3" | ||
"typescript": "^4.4" | ||
}, | ||
@@ -43,0 +43,0 @@ "keywords": [ |
@@ -34,6 +34,6 @@ # noble-bls12-381 ![Node CI](https://github.com/paulmillr/noble-secp256k1/workflows/Node%20CI/badge.svg) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) | ||
> npm install noble-bls12-381 | ||
> npm install @noble/bls12-381 | ||
```js | ||
const bls = require('noble-bls12-381'); | ||
const bls = require('@noble/bls12-381'); | ||
// if you're using single file, use global variable nobleBls12381 | ||
@@ -40,0 +40,0 @@ |
87220
2007