Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ConstanceBeguier committed Dec 18, 2023
1 parent dbcffa2 commit afff1ce
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions halo2_gadgets/src/utilities/cond_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ pub trait CondSwapInstructions<F: Field>: UtilitiesInstructions<F> {
swap: Value<bool>,
) -> Result<(Self::Var, Self::Var), Error>;

/// Given an input `(choice, left, right)`, returns `left` if choice=0 and `right` otherwise.
///
/// `choice` must be constrained to {0, 1} separately.
/// Given an input `(choice, left, right)` where `choice` is a boolean flag,
/// returns `left` if `choice` is not set and `right` if `choice` is set.
fn mux(
&self,
layouter: &mut impl Layouter<F>,
Expand Down Expand Up @@ -164,10 +163,10 @@ impl<F: PrimeField> CondSwapInstructions<F> for CondSwapChip<F> {
.zip(right.value())
.zip(choice.value())
.map(|((left, right), choice)| {
if *choice == F::from(1_u64) {
right
} else {
if *choice == F::from(0_u64) {
left
} else {
right
}
})
.cloned();
Expand All @@ -176,10 +175,10 @@ impl<F: PrimeField> CondSwapInstructions<F> for CondSwapChip<F> {
.zip(right.value())
.zip(choice.value())
.map(|((left, right), choice)| {
if *choice == F::from(1_u64) {
left
} else {
if *choice == F::from(0_u64) {
right
} else {
left
}
})
.cloned();
Expand All @@ -192,10 +191,8 @@ impl<F: PrimeField> CondSwapInstructions<F> for CondSwapChip<F> {
}

impl CondSwapChip<pallas::Base> {
/// Given an input `(choice, left, right)`, returns `left` if choice=0 and `right` otherwise.
///
/// `left` and `right` are `EccPoint`
/// `choice` must be constrained to {0, 1} separately.
/// Given an input `(choice, left, right)` where `choice` is a boolean flag and `left` and `right` are `EccPoint`,
/// returns `left` if `choice` is not set and `right` if `choice` is set.
pub fn mux_on_points(
&self,
mut layouter: impl Layouter<pallas::Base>,
Expand All @@ -211,10 +208,8 @@ impl CondSwapChip<pallas::Base> {
))
}

/// Given an input `(choice, left, right)`, returns `left` if choice=0 and `right` otherwise.
///
/// `left` and `right` are `NonIdentityEccPoint`
/// `choice` must be constrained to {0, 1} separately.
/// Given an input `(choice, left, right)` where `choice` is a boolean flag and `left` and `right` are
/// `NonIdentityEccPoint`, returns `left` if `choice` is not set and `right` if `choice` is set.
pub fn mux_on_non_identity_points(
&self,
mut layouter: impl Layouter<pallas::Base>,
Expand Down

0 comments on commit afff1ce

Please sign in to comment.