PrimeFieldRepr::divn() should accept u32.
This commit is contained in:
parent
1a481bc741
commit
9af0c7dd30
@ -10,7 +10,7 @@ const MODULUS_BITS: u32 = 381;
|
|||||||
|
|
||||||
// The number of bits that must be shaved from the beginning of
|
// The number of bits that must be shaved from the beginning of
|
||||||
// the representation when randomly sampling.
|
// the representation when randomly sampling.
|
||||||
const REPR_SHAVE_BITS: usize = 3;
|
const REPR_SHAVE_BITS: u32 = 3;
|
||||||
|
|
||||||
// R = 2**384 % q
|
// R = 2**384 % q
|
||||||
const R: FqRepr = FqRepr([0x760900000002fffd, 0xebf4000bc40c0002, 0x5f48985753c758ba, 0x77ce585370525745, 0x5c071a97a256ec6d, 0x15f65ec3fa80e493]);
|
const R: FqRepr = FqRepr([0x760900000002fffd, 0xebf4000bc40c0002, 0x5f48985753c758ba, 0x77ce585370525745, 0x5c071a97a256ec6d, 0x15f65ec3fa80e493]);
|
||||||
@ -278,7 +278,7 @@ impl PrimeFieldRepr for FqRepr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn divn(&mut self, mut n: usize) {
|
fn divn(&mut self, mut n: u32) {
|
||||||
if n >= 64 * 6 {
|
if n >= 64 * 6 {
|
||||||
*self = Self::from(0);
|
*self = Self::from(0);
|
||||||
return;
|
return;
|
||||||
|
@ -8,7 +8,7 @@ const MODULUS_BITS: u32 = 255;
|
|||||||
|
|
||||||
// The number of bits that must be shaved from the beginning of
|
// The number of bits that must be shaved from the beginning of
|
||||||
// the representation when randomly sampling.
|
// the representation when randomly sampling.
|
||||||
const REPR_SHAVE_BITS: usize = 1;
|
const REPR_SHAVE_BITS: u32 = 1;
|
||||||
|
|
||||||
// R = 2**256 % r
|
// R = 2**256 % r
|
||||||
const R: FrRepr = FrRepr([0x1fffffffe, 0x5884b7fa00034802, 0x998c4fefecbc4ff5, 0x1824b159acc5056f]);
|
const R: FrRepr = FrRepr([0x1fffffffe, 0x5884b7fa00034802, 0x998c4fefecbc4ff5, 0x1824b159acc5056f]);
|
||||||
@ -114,7 +114,7 @@ impl PrimeFieldRepr for FrRepr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn divn(&mut self, mut n: usize) {
|
fn divn(&mut self, mut n: u32) {
|
||||||
if n >= 64 * 4 {
|
if n >= 64 * 4 {
|
||||||
*self = Self::from(0);
|
*self = Self::from(0);
|
||||||
return;
|
return;
|
||||||
|
@ -369,7 +369,7 @@ pub trait PrimeFieldRepr: Sized +
|
|||||||
fn div2(&mut self);
|
fn div2(&mut self);
|
||||||
|
|
||||||
/// Performs a rightwise bitshift of this number by some amount.
|
/// Performs a rightwise bitshift of this number by some amount.
|
||||||
fn divn(&mut self, amt: usize);
|
fn divn(&mut self, amt: u32);
|
||||||
|
|
||||||
/// Performs a leftwise bitshift of this number, effectively multiplying
|
/// Performs a leftwise bitshift of this number, effectively multiplying
|
||||||
/// it by 2. Overflow is ignored.
|
/// it by 2. Overflow is ignored.
|
||||||
|
Loading…
Reference in New Issue
Block a user