Skip to content

Commit

Permalink
Enable strings as steps based on descriptive-gate feature.
Browse files Browse the repository at this point in the history
Usually !debug_assertions => compact-gate, but that is not the case when
profiling.
  • Loading branch information
andyleiserson committed Mar 6, 2024
1 parent 951bff3 commit 0ad08e1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ members = ["ipa-core", "ipa-macros"]
incremental = true
lto = "thin"

[profile.bench]
debug-assertions = true

[profile.bench-dhat]
inherits = "bench"
debug-assertions = false
incremental = true
lto = "thin"
debug = 1
9 changes: 4 additions & 5 deletions ipa-core/src/ff/curve_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,7 @@ mod test {
use typenum::U32;

use crate::{
ff::{
curve_points::{NonCanonicalEncoding, RP25519},
ec_prime_field::Fp25519,
Serializable,
},
ff::{curve_points::RP25519, ec_prime_field::Fp25519, Serializable},
secret_sharing::SharedValue,
};

Expand Down Expand Up @@ -258,7 +254,10 @@ mod test {
}

#[test]
#[cfg(debug_assertions)]
fn non_canonical() {
use crate::ff::curve_points::NonCanonicalEncoding;

const ZERO: u128 = 0;
// 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF is not a valid Ristretto point
let buf: [u8; 32] = unsafe { std::mem::transmute([!ZERO, !ZERO]) };
Expand Down
6 changes: 6 additions & 0 deletions ipa-core/src/ff/galois_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,14 @@ macro_rules! bit_array_impl {
}

#[test]
#[cfg(debug_assertions)]
#[should_panic(expected = "index < usize::try_from")]
pub fn out_of_count_index() {
// With debug assertions enabled, this test will panic on any out-of-bounds
// access. Without debug assertions, it will not panic on access to the unused
// bits for non-multiple-of-8 bitwidths. Enable the test only with debug
// assertions, rather than try to do something conditioned on the bit width.

let s = $name::try_from(1_u128).unwrap();
// Below assert doesn't matter. The indexing should panic
assert_eq!(s[<$name>::BITS as usize], false);
Expand Down
4 changes: 2 additions & 2 deletions ipa-core/src/protocol/step/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ pub trait StepNarrow<S: Step + ?Sized> {
pub trait Step: AsRef<str> {}

// In test code, allow a string (or string reference) to be used as a `Step`.
#[cfg(any(feature = "test-fixture", debug_assertions))]
#[cfg(feature = "descriptive-gate")]
impl Step for String {}

#[cfg(any(feature = "test-fixture", debug_assertions))]
#[cfg(feature = "descriptive-gate")]
impl Step for str {}

/// A step generator for bitwise secure operations.
Expand Down

0 comments on commit 0ad08e1

Please sign in to comment.