mirror of
https://github.com/pezkuwichain/bizinikiwi-bn.git
synced 2026-06-22 01:01:08 +00:00
Ensure divrem always returns remainder.
This commit is contained in:
+3
-3
@@ -30,8 +30,8 @@ pub struct Fq2 {
|
||||
|
||||
impl Encodable for Fq2 {
|
||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
let c1: U256 = self.c1.into();
|
||||
let c0: U256 = self.c0.into();
|
||||
let c1: U256 = self.c1.into();
|
||||
|
||||
U512::from(&c1, &c0, &Fq::modulus()).encode(s)
|
||||
}
|
||||
@@ -42,10 +42,10 @@ impl Decodable for Fq2 {
|
||||
let combined = try!(U512::decode(s));
|
||||
|
||||
match combined.divrem(&Fq::modulus()) {
|
||||
Some((c1, c0)) => {
|
||||
(Some(c1), c0) => {
|
||||
Ok(Fq2::new(Fq::new(c0).unwrap(), Fq::new(c1).unwrap()))
|
||||
},
|
||||
None => {
|
||||
_ => {
|
||||
Err(s.error("integer not less than modulus squared"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user