Skip to content

Commit

Permalink
fix: change assert to debug_assert in read_raw_unchecked functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpwang committed Dec 22, 2022
1 parent 1c61d24 commit 63127f6
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/bn256/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ macro_rules! assembly_field {

impl $crate::serde::SerdeObject for $field {
fn from_raw_bytes_unchecked(bytes: &[u8]) -> Self {
assert_eq!(bytes.len(), 32);
debug_assert_eq!(bytes.len(), 32);
let inner =
[0, 8, 16, 24].map(|i| u64::from_le_bytes(bytes[i..i + 8].try_into().unwrap()));
Self(inner)
Expand Down
1 change: 0 additions & 1 deletion src/bn256/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ mod tests {
#[test]
fn test_endo_consistency() {
let g = G1::generator();
dbg!(-ENDO_BETA);
assert_eq!(g * (-ENDO_BETA), g.endo());
}

Expand Down
3 changes: 1 addition & 2 deletions src/bn256/engine.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::suspicious_arithmetic_impl)]
use crate::bn256::curve::*;
use crate::bn256::fq::*;
use crate::bn256::fq12::*;
Expand Down Expand Up @@ -122,7 +123,6 @@ impl<'a, 'b> Add<&'b Gt> for &'a Gt {
type Output = Gt;

#[inline]
#[allow(clippy::suspicious_arithmetic_impl)]
fn add(self, rhs: &'b Gt) -> Gt {
Gt(self.0 * rhs.0)
}
Expand All @@ -140,7 +140,6 @@ impl<'a, 'b> Sub<&'b Gt> for &'a Gt {
impl<'a, 'b> Mul<&'b Fr> for &'a Gt {
type Output = Gt;

#[allow(clippy::suspicious_arithmetic_impl)]
fn mul(self, other: &'b Fr) -> Self::Output {
let mut acc = Gt::identity();

Expand Down
2 changes: 1 addition & 1 deletion src/bn256/fq2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ impl ff::PrimeField for Fq2 {

impl crate::serde::SerdeObject for Fq2 {
fn from_raw_bytes_unchecked(bytes: &[u8]) -> Self {
assert_eq!(bytes.len(), 64);
debug_assert_eq!(bytes.len(), 64);
let [c0, c1] = [0, 32].map(|i| Fq::from_raw_bytes_unchecked(&bytes[i..i + 32]));
Self { c0, c1 }
}
Expand Down
4 changes: 2 additions & 2 deletions src/derive/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ macro_rules! new_curve_impl {

impl $crate::serde::SerdeObject for $name {
fn from_raw_bytes_unchecked(bytes: &[u8]) -> Self {
assert_eq!(bytes.len(), 3 * $base::size());
debug_assert_eq!(bytes.len(), 3 * $base::size());
let [x, y, z] = [0, 1, 2]
.map(|i| $base::from_raw_bytes_unchecked(&bytes[i * $base::size()..(i + 1) * $base::size()]));
Self { x, y, z }
Expand Down Expand Up @@ -649,7 +649,7 @@ macro_rules! new_curve_impl {

impl $crate::serde::SerdeObject for $name_affine {
fn from_raw_bytes_unchecked(bytes: &[u8]) -> Self {
assert_eq!(bytes.len(), 2 * $base::size());
debug_assert_eq!(bytes.len(), 2 * $base::size());
let [x, y] =
[0, $base::size()].map(|i| $base::from_raw_bytes_unchecked(&bytes[i..i + $base::size()]));
Self { x, y }
Expand Down
2 changes: 1 addition & 1 deletion src/derive/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ macro_rules! field_common {

impl $crate::serde::SerdeObject for $field {
fn from_raw_bytes_unchecked(bytes: &[u8]) -> Self {
assert_eq!(bytes.len(), 32);
debug_assert_eq!(bytes.len(), 32);
let inner =
[0, 8, 16, 24].map(|i| u64::from_le_bytes(bytes[i..i + 8].try_into().unwrap()));
Self(inner)
Expand Down

0 comments on commit 63127f6

Please sign in to comment.