Skip to content

Commit

Permalink
fix FieldElement56::negate (fix mentioned by @pornin in #28)
Browse files Browse the repository at this point in the history
  • Loading branch information
conradoplg committed Jul 12, 2023
1 parent 30946a3 commit 4239660
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/field/fiat_u64/prime_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ impl FieldElement56 {
pub(crate) fn negate(&self) -> FieldElement56 {
let mut result = FieldElement56::zero();
fiat_p448_opp(&mut result.0, &self.0);
let cloned = result.clone();
fiat_p448_carry(&mut result.0, &cloned.0);
result
}

Expand All @@ -190,3 +192,16 @@ impl FieldElement56 {
result
}
}

#[cfg(test)]
mod tests {

use super::*;

#[test]
fn test_negate() {
let x = FieldElement56::zero();
let y = x.negate();
assert_eq!(y.to_bytes(), [0u8; 56]);
}
}

0 comments on commit 4239660

Please sign in to comment.