arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
Update the documentation of BN254's field parameters (#59)

Weikeng Chen w.k@berkeley.edu
Thu, 06 May 2021 08:22:07 -0700
commit

8c795ec0cfaed3abe0c1e4a8d3e0c5614af363a2

parent

9d232a7dcd254679c07e70019a8dd3d9e0de5ca0

2 files changed, 11 insertions(+), 6 deletions(-)

jump to
M bn254/src/fields/fq.rs → bn254/src/fields/fq.rs

@@ -19,7 +19,7 @@ 0x2259d6b14729c0fa,

]); } impl FpParameters for FqParameters { - /// MODULUS = 258664426012969094010652733694893533536393512754914660539884262666720468348340822774968888139573360124440321458177 + /// MODULUS = 21888242871839275222246405745257275088696311157297823662689037894645226208583 #[rustfmt::skip] const MODULUS: BigInteger = BigInteger([ 0x3c208c16d87cfd47,

@@ -82,7 +82,7 @@ 0x183227397098d014,

]); // (T - 1) // 2 = - // 1837921289030710838195067919506396475074392872918698035817074744121558668640693829665401097909504529 + // 5472060717959818805561601436314318772174077789324455915672259473661306552145 #[rustfmt::skip] const T_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([ 0x4f082305b61f3f51,
M bn254/src/fields/fr.rs → bn254/src/fields/fr.rs

@@ -34,6 +34,8 @@ const CAPACITY: u32 = Self::MODULUS_BITS - 1;

const REPR_SHAVE_BITS: u32 = 2; + /// R = pow(2, 320) % MODULUS + /// = 6350874878119819312338956282401532410528162663560392320966563075034087161851 #[rustfmt::skip] const R: BigInteger = BigInteger([ 12436184717236109307u64,

@@ -42,6 +44,8 @@ 7381016538464732718u64,

1011752739694698287u64, ]); + /// R2 = R * R % MODULUS + /// = 944936681149208446651664254269745548490766851729442924617792859073125903783 #[rustfmt::skip] const R2: BigInteger = BigInteger([ 1997599621687373223u64,

@@ -50,9 +54,10 @@ 10108755138030829701u64,

150537098327114917u64, ]); + /// INV = (-MODULUS) ^ {-1} % pow(2, 64) = 14042775128853446655 const INV: u64 = 14042775128853446655u64; - // GENERATOR = 5 + /// GENERATOR = 5 #[rustfmt::skip] const GENERATOR: BigInteger = BigInteger([ 1949230679015292902u64,

@@ -61,7 +66,7 @@ 5177146667339417225u64,

1571765431670520771u64, ]); - /// (r - 1)/2 = + /// (MODULUS - 1)/2 = /// 10944121435919637611123202872628637544274182200208017171849102093287904247808 #[rustfmt::skip] const MODULUS_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([

@@ -73,7 +78,7 @@ ]);

// T and T_MINUS_ONE_DIV_TWO, where r - 1 = 2^s * t - /// t = (r - 1) / 2^s = + /// T = (MODULUS - 1) / 2^s = /// 81540058820840996586704275553141814055101440848469862132140264610111 #[rustfmt::skip] const T: BigInteger = BigInteger([

@@ -83,7 +88,7 @@ 0x131a029b85045b68,

0x30644e72e, ]); - /// (t - 1) / 2 = + /// (T - 1) / 2 = /// 40770029410420498293352137776570907027550720424234931066070132305055 #[rustfmt::skip] const T_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([