diff --git a/src/arithmetic/fields.rs b/src/arithmetic/fields.rs index c46ac81..c8f7916 100644 --- a/src/arithmetic/fields.rs +++ b/src/arithmetic/fields.rs @@ -160,10 +160,10 @@ impl SqrtHasher { pub struct SqrtTables { hasher: SqrtHasher, inv: Vec, - g0: [F; 256], - g1: [F; 256], - g2: [F; 256], - g3: [F; 129], + g0: Box<[F; 256]>, + g1: Box<[F; 256]>, + g2: Box<[F; 256]>, + g3: Box<[F; 129]>, } impl SqrtTables { @@ -202,10 +202,10 @@ impl SqrtTables { SqrtTables:: { hasher, inv, - g0: gtab[0][..].try_into().unwrap(), - g1: gtab[1][..].try_into().unwrap(), - g2: gtab[2][..].try_into().unwrap(), - g3: gtab[3][0..129].try_into().unwrap(), + g0: Box::new(gtab[0][..].try_into().unwrap()), + g1: Box::new(gtab[1][..].try_into().unwrap()), + g2: Box::new(gtab[2][..].try_into().unwrap()), + g3: Box::new(gtab[3][0..129].try_into().unwrap()), } } diff --git a/src/pasta/fields/fp.rs b/src/pasta/fields/fp.rs index f03eb3f..15fa46c 100644 --- a/src/pasta/fields/fp.rs +++ b/src/pasta/fields/fp.rs @@ -796,7 +796,6 @@ impl FieldExt for Fp { let rr = sqr(rq, 7) * r111; let rs = sqr(rr, 3) * r11; let rt = rs.square(); - //assert!(rt == ff::Field::pow_vartime(&self, &Fp::T_MINUS1_OVER2)); rt } } @@ -837,6 +836,13 @@ fn test_sqrt() { assert!(v == Fp::TWO_INV || (-v) == Fp::TWO_INV); } +#[test] +fn test_pow_by_t_minus1_over2() { + // NB: TWO_INV is standing in as a "random" field element + let v = (Fp::TWO_INV).pow_by_t_minus1_over2(); + assert!(v == ff::Field::pow_vartime(&Fp::TWO_INV, &Fp::T_MINUS1_OVER2)); +} + #[test] fn test_sqrt_ratio_and_alt() { // (true, sqrt(num/div)), if num and div are nonzero and num/div is a square in the field diff --git a/src/pasta/fields/fq.rs b/src/pasta/fields/fq.rs index 64dd760..1241561 100644 --- a/src/pasta/fields/fq.rs +++ b/src/pasta/fields/fq.rs @@ -796,7 +796,6 @@ impl FieldExt for Fq { let sr = sqr(sq, 5) * s1011; let ss = sqr(sr, 3) * self; let st = sqr(ss, 4); - //assert!(st == ff::Field::pow_vartime(&self, &Fq::T_MINUS1_OVER2)); st } } @@ -837,6 +836,13 @@ fn test_sqrt() { assert!(v == Fq::TWO_INV || (-v) == Fq::TWO_INV); } +#[test] +fn test_pow_by_t_minus1_over2() { + // NB: TWO_INV is standing in as a "random" field element + let v = (Fq::TWO_INV).pow_by_t_minus1_over2(); + assert!(v == ff::Field::pow_vartime(&Fq::TWO_INV, &Fq::T_MINUS1_OVER2)); +} + #[test] fn test_sqrt_ratio_and_alt() { // (true, sqrt(num/div)), if num and div are nonzero and num/div is a square in the field diff --git a/src/poly/commitment.rs b/src/poly/commitment.rs index a9b6c74..11e9d9e 100644 --- a/src/poly/commitment.rs +++ b/src/poly/commitment.rs @@ -38,8 +38,8 @@ impl Params { // This is usually a limitation on the curve, but we also want 32-bit // architectures to be supported. assert!(k < 32); - // No goofy hardware please. - assert!(core::mem::size_of::() >= 4); + + // In src/arithmetic/fields.rs we ensure that usize is at least 32 bits. let n: u64 = 1 << k;