Skip to content

Commit 1e1185d

Browse files
Implement UtilitiesInstructions, CondSwapInstructions for MerkleChip
1 parent 5ca5770 commit 1e1185d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/circuit/gadget/orchard_action/merkle.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,37 @@ impl<C: CurveAffine, const PATH_LENGTH: usize, const K: usize, const MAX_WORDS:
165165
SinsemillaChip::<C, K, MAX_WORDS>::extract(point)
166166
}
167167
}
168+
169+
impl<C: CurveAffine, const PATH_LENGTH: usize, const K: usize, const MAX_WORDS: usize>
170+
UtilitiesInstructions<C::Base> for MerkleChip<C, PATH_LENGTH, K, MAX_WORDS>
171+
{
172+
type Var = CellValue<C::Base>;
173+
}
174+
175+
impl<C: CurveAffine, const PATH_LENGTH: usize, const K: usize, const MAX_WORDS: usize>
176+
CondSwapInstructions<C::Base> for MerkleChip<C, PATH_LENGTH, K, MAX_WORDS>
177+
{
178+
type Var = CellValue<C::Base>;
179+
type Swap = Swap;
180+
181+
#[allow(clippy::type_complexity)]
182+
fn swap(
183+
&self,
184+
layouter: impl Layouter<C::Base>,
185+
pair: (
186+
<Self as CondSwapInstructions<C::Base>>::Var,
187+
<Self as CondSwapInstructions<C::Base>>::Var,
188+
),
189+
swap: Self::Swap,
190+
) -> Result<
191+
(
192+
<Self as CondSwapInstructions<C::Base>>::Var,
193+
<Self as CondSwapInstructions<C::Base>>::Var,
194+
),
195+
Error,
196+
> {
197+
let config = self.config().cond_swap_config.clone();
198+
let chip = CondSwapChip::<C::Base>::construct(config);
199+
chip.swap(layouter, pair, swap)
200+
}
201+
}

0 commit comments

Comments
 (0)