Skip to content

Commit

Permalink
[book] Update swap and multiplexer
Browse files Browse the repository at this point in the history
  • Loading branch information
ConstanceBeguier committed Dec 5, 2024
1 parent 7954bd4 commit 4765549
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions book/src/design/gadgets/swap_multiplexer.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# Swap and Multiplexer

Swap gates are used to check the Merkle path of a commitment note.
Multiplixer are used in ZSA Orchard circuit to evaluate note and value commitments
according to the transaction type (ZSA or native transaction).
Swap gates are utilized to verify the Merkle path of commitment notes.
Multiplixer are utilized in OrchardZSA to evaluate note and value commitments
based on the transaction type (ZSA or native transaction).

## Swap

Given an input pair of field elements $(a,b)$ and a boolean value $swap$,
we would like to return
- $(a, b)$ is $swap = 0$, and
- $(a, b)$ if $swap = 0$, and
- $(b, a)$ if $swap = 1$.

### Layout

Let $(a_s, b_s) = SWAP(a, b, swap)$.
Let $(a_s, b_s) = SWAP(a, b, swap) = \begin{cases}
(a, b) \text{ if } swap = 0 \\
(b, a) \text{ if } swap = 1
\end{cases}$.

We set all values $a_s$, $b_s$, $a$, $b$ and $swap$ on the same row in the layout.

$$
Expand Down

0 comments on commit 4765549

Please sign in to comment.