fix: make from_noncanonical_biguint work for zero (#1427)

This commit is contained in:
Ayush Shukla 2023-12-15 15:49:34 +01:00 committed by GitHub
parent 71dff6e982
commit fdd7ee46fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ use core::hash::{Hash, Hasher};
use core::iter::{Product, Sum};
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use num::{BigUint, Integer};
use num::{BigUint, Integer, ToPrimitive};
use plonky2_util::{assume, branch_hint};
use serde::{Deserialize, Serialize};
@ -147,7 +147,7 @@ impl Field for GoldilocksField {
}
fn from_noncanonical_biguint(n: BigUint) -> Self {
Self(n.mod_floor(&Self::order()).to_u64_digits()[0])
Self(n.mod_floor(&Self::order()).to_u64().unwrap())
}
#[inline(always)]