Skip to content

Commit

Permalink
make feature additive
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardkulms committed Apr 15, 2024
1 parent a6f2ae4 commit 6e2e23c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion zk-token-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ zeroize = { workspace = true, features = ["zeroize_derive"] }
crate-type = ["cdylib", "rlib"]

[features]
single-threaded = []
default = ["enable-threaded"]
enable-threaded = []
8 changes: 4 additions & 4 deletions zk-token-sdk/src/encryption/discrete_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl DiscreteLog {
/// Solves the discrete log problem under the assumption that the solution
/// is a positive 32-bit number.
pub fn decode_u32(self) -> Option<u64> {
#[cfg(feature = "single_thread")]
#[cfg(not(feature = "enable-threaded"))]
{
let ristretto_iterator =
RistrettoIterator::new((self.target, 0_u64), (-(&self.step_point), 1_u64));
Expand All @@ -151,7 +151,7 @@ impl DiscreteLog {
)
}

#[cfg(not(feature = "single_thread"))]
#[cfg(feature = "enable-threaded")]
{
let mut starting_point = self.target;
let handles = (0..self.num_threads)
Expand Down Expand Up @@ -270,7 +270,7 @@ mod tests {
}

#[test]
#[cfg(not(feature = "single-threaded"))]
#[cfg(feature = "enable-threaded")]
fn test_decode_correctness() {
// general case
let amount: u64 = 4294967295;
Expand Down Expand Up @@ -306,7 +306,7 @@ mod tests {
}

#[test]
#[cfg(not(feature = "single-threaded"))]
#[cfg(feature = "enable-threaded")]
fn test_decode_correctness_threaded() {
// general case
let amount: u64 = 55;
Expand Down

0 comments on commit 6e2e23c

Please sign in to comment.