-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Blake2s example with smaller range example
- Loading branch information
Showing
2 changed files
with
27 additions
and
233 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Any value 0 <= x < 32 such that the last two bits 1, 0 is valid. For example | ||
10 is valid since its bit string is ...1010. Run as follows: | ||
vamp-ir setup -o params.pp | ||
vamp-ir compile -u params.pp -s tests/range.pir -o circuit.plonk | ||
vamp-ir prove -u params.pp -c circuit.plonk -o proof.plonk | ||
vamp-ir verify -u params.pp -c circuit.plonk -p proof.plonk | ||
*/ | ||
|
||
pub x; | ||
|
||
// Ensure that the given argument is 1 or 0, and returns it | ||
|
||
def bool x = { x*(x-1) = 0; x }; | ||
|
||
// Extract 5 bits from a number argument | ||
|
||
def bits5 a = { | ||
def a0 = bool (fresh ((a\1) % 2)); | ||
def a1 = bool (fresh ((a\2) % 2)); | ||
def a2 = bool (fresh ((a\4) % 2)); | ||
def a3 = bool (fresh ((a\8) % 2)); | ||
def a4 = bool (fresh ((a\16) % 2)); | ||
a = a0 + 2*a1 + 4*a2 + 8*a3 + 16*a4; | ||
(a0, a1, a2, a3, a4, ()) | ||
}; | ||
|
||
def x_bits = bits5 x; |