From d0a742419468e6c42b7e2b9a463ce21f0f5363b4 Mon Sep 17 00:00:00 2001 From: lightsing Date: Thu, 22 Aug 2024 17:37:42 +0800 Subject: [PATCH] some fix --- src/bn256/fr.rs | 3 +-- src/bn256/fr_sp1.rs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/bn256/fr.rs b/src/bn256/fr.rs index ac90d403..821c37d0 100644 --- a/src/bn256/fr.rs +++ b/src/bn256/fr.rs @@ -325,9 +325,8 @@ impl<'a> MulAddAssign<&'a Fr, Fr> for Fr { impl<'a, 'b> MulAddAssign<&'a Fr, &'b Fr> for Fr { fn mul_add_assign(&mut self, a: &'a Self, b: &'b Self) { - *self = *self + *a + *b; + *self = *self + a * b; } - } #[cfg(test)] diff --git a/src/bn256/fr_sp1.rs b/src/bn256/fr_sp1.rs index 39b8497f..28da3656 100644 --- a/src/bn256/fr_sp1.rs +++ b/src/bn256/fr_sp1.rs @@ -106,7 +106,7 @@ impl Fr { Fr([1, 0, 0, 0, 0, 0, 0, 0]) } - pub fn from_bytes(bytes: &[u8; 32]) -> CtOption { + pub const fn from_bytes(bytes: &[u8; 32]) -> CtOption { let mut tmp = [0, 0, 0, 0, 0, 0, 0, 0]; tmp[0] = u32::from_le_bytes(bytes[0..4].try_into().unwrap()); @@ -132,7 +132,7 @@ impl Fr { CtOption::new(Fr(tmp), Choice::from(is_some)) } - pub fn from_raw(limbs: [u64; 4]) -> Fr { + pub const fn from_raw(limbs: [u64; 4]) -> Fr { // FIXME: handle limbs that are larger than modulus. let mut tmp = [0, 0, 0, 0, 0, 0, 0, 0];