From 895ee3a1a4349c976f3114664b6ac358e17d6708 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Sun, 23 Apr 2023 18:29:03 +0000 Subject: [PATCH] bls: refactor slightly --- src/bls12-381.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/bls12-381.ts b/src/bls12-381.ts index 3889fe6..5f6fdc2 100644 --- a/src/bls12-381.ts +++ b/src/bls12-381.ts @@ -60,11 +60,10 @@ const _8n = BigInt(8), _16n = BigInt(16); // CURVE FIELDS // Finite field over p. -const Fp = mod.Field( - BigInt( - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab' - ) +const Fp_raw = BigInt( + '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab' ); +const Fp = mod.Field(Fp_raw); type Fp = bigint; // Finite field over r. // This particular field is not used anywhere in bls12-381, but it is still useful. @@ -110,10 +109,7 @@ type Fp2Utils = { // G² - 1 // h2q // NOTE: ORDER was wrong! -const FP2_ORDER = - BigInt( - '0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab' - ) ** _2n; +const FP2_ORDER = Fp_raw * Fp_raw; const Fp2: mod.IField & Fp2Utils = { ORDER: FP2_ORDER,