Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(circom): fully constrain is_valid_merkle_branch_out. #172

Merged
merged 3 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ pragma circom 2.1.5;

include "hash_two.circom";
include "../../../node_modules/circomlib/circuits/comparators.circom";
include "../../../node_modules/circomlib/circuits/bitify.circom";

include "utils/arrays.circom";
include "utils/numerical.circom";

template IsValidMerkleBranchOut(N) {
signal input branch[N][256];
Expand All @@ -14,12 +17,14 @@ template IsValidMerkleBranchOut(N) {

component hashers[N];
component isZero[N];

component idx2Bits;
idx2Bits = Num2Bits(N+1);
idx2Bits.in <== index;
for(var i = 0; i < N; i++) {
hashers[i] = HashTwo();
isZero[i] = IsZero();

isZero[i].in <-- (index \ (2**i)) % 2;
isZero[i].in <== idx2Bits.out[i];

var current[256];

Expand Down
4 changes: 4 additions & 0 deletions beacon-light-client/circom/test/pow/data/case05/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"base": "10",
"power": "0"
}
3 changes: 3 additions & 0 deletions beacon-light-client/circom/test/pow/data/case05/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"out": "1"
}