Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
zac-williamson committed Jul 4, 2024
1 parent 9a39d6a commit 125e469
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ trait BigNumTrait where BigNumTrait: std::ops::Add + std::ops::Sub + std::ops::M
fn get_limb(self, idx: u64) -> Field;
fn set_limb(&mut self, idx: u64, value: Field);
fn modulus_bits() -> u64;
fn conditional_select(lhs: Self, rhs: Self, predicate: bool) -> Self;
}


Expand Down Expand Up @@ -104,6 +105,14 @@ impl<let N: u64, Params> BigNumTrait for BigNum<N, Params> where Params: BigNumP
is_equal_modulus | is_equal_zero
}

fn conditional_select(lhs: Self, rhs: Self, predicate: bool) -> Self {
let mut result: Self = BigNum::new();
for i in 0..N {
result.limbs[i] = (lhs.limbs[i] - rhs.limbs[i]) * predicate as Field + rhs.limbs[i];
}
result
}

// ####################################################################################################################
// ####################################################################################################################
// ### C O N S T R U C T O R S
Expand Down

0 comments on commit 125e469

Please sign in to comment.