Skip to content

Commit

Permalink
Implement UtilitiesInstructions, CondSwapInstructions for MerkleChip
Browse files Browse the repository at this point in the history
  • Loading branch information
therealyingtong committed Jun 3, 2021
1 parent 5ca5770 commit 1e1185d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/circuit/gadget/orchard_action/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,37 @@ impl<C: CurveAffine, const PATH_LENGTH: usize, const K: usize, const MAX_WORDS:
SinsemillaChip::<C, K, MAX_WORDS>::extract(point)
}
}

impl<C: CurveAffine, const PATH_LENGTH: usize, const K: usize, const MAX_WORDS: usize>
UtilitiesInstructions<C::Base> for MerkleChip<C, PATH_LENGTH, K, MAX_WORDS>
{
type Var = CellValue<C::Base>;
}

impl<C: CurveAffine, const PATH_LENGTH: usize, const K: usize, const MAX_WORDS: usize>
CondSwapInstructions<C::Base> for MerkleChip<C, PATH_LENGTH, K, MAX_WORDS>
{
type Var = CellValue<C::Base>;
type Swap = Swap;

#[allow(clippy::type_complexity)]
fn swap(
&self,
layouter: impl Layouter<C::Base>,
pair: (
<Self as CondSwapInstructions<C::Base>>::Var,
<Self as CondSwapInstructions<C::Base>>::Var,
),
swap: Self::Swap,
) -> Result<
(
<Self as CondSwapInstructions<C::Base>>::Var,
<Self as CondSwapInstructions<C::Base>>::Var,
),
Error,
> {
let config = self.config().cond_swap_config.clone();
let chip = CondSwapChip::<C::Base>::construct(config);
chip.swap(layouter, pair, swap)
}
}

0 comments on commit 1e1185d

Please sign in to comment.