Make NUM_BITS an argument for the field macro

This commit is contained in:
Luke Parker
2024-07-23 19:22:43 -04:00
parent b8472963c9
commit b6e688076f
3 changed files with 5 additions and 3 deletions

View File

@@ -74,6 +74,7 @@ macro_rules! field {
$MODULUS: ident,
$WIDE_MODULUS: ident,
$NUM_BITS: literal,
$MULTIPLICATIVE_GENERATOR: literal,
$S: literal,
$ROOT_OF_UNITY: literal,
@@ -212,8 +213,8 @@ macro_rules! field {
const MODULUS: &'static str = $MODULUS_STR;
const NUM_BITS: u32 = 256;
const CAPACITY: u32 = 255;
const NUM_BITS: u32 = $NUM_BITS;
const CAPACITY: u32 = $NUM_BITS - 1;
const TWO_INV: Self = $FieldName($ResidueType::new(&U256::from_u8(2)).invert().0);

View File

@@ -229,7 +229,7 @@ impl Group for Point {
let RR = R * R;
let B = X1 + R;
let B = (B * B) - XX - RR;
let h = (w * w) - B.double();
let h = (w * w) - B.double();
let X3 = h * s;
let Y3 = w * (B - h) - RR.double();
let Z3 = sss;

View File

@@ -32,6 +32,7 @@ field!(
MODULUS_STR,
MODULUS,
WIDE_MODULUS,
256,
3,
1,
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2e",