use block indices directly to calculate treePathIndices

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2022-11-17 13:59:58 +01:00
parent 26d8f78c58
commit 56ca654ab9
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
1 changed files with 8 additions and 2 deletions

View File

@ -2,6 +2,8 @@ pragma circom 2.0.0;
include "../node_modules/circomlib/circuits/sha256/sha256.circom";
include "../node_modules/circomlib/circuits/poseidon.circom";
include "../node_modules/circomlib/circuits/bitify.circom";
include "tree.circom";
template HashCheck(blockSize) {
@ -26,7 +28,6 @@ template StorageProver(blockSize, qLen, nLevels) {
//signal input chunkHashes[qLen][256];
signal input chunkHashes[qLen];
signal input indices[qLen];
signal input treePathIndices[qLen][nLevels];
signal input treeSiblings[qLen][nLevels];
signal input root;
@ -44,14 +45,19 @@ template StorageProver(blockSize, qLen, nLevels) {
// - convert indices to treePathIndices
// - check chunkHash and treeSiblings according to treePathIndices against root
component num2Bits[qLen];
component inclusionProofs[qLen];
//component inclusionProofs[qLen] = MerkleTreeInclusionProof(nLevels);
for (var i = 0; i < qLen; i++) {
num2Bits[i] = Num2Bits(nLevels);
num2Bits[i].in <== indices[i];
inclusionProofs[i] = MerkleTreeInclusionProof(nLevels);
inclusionProofs[i].leaf <== chunkHashes[i];
for (var j = 0; j < nLevels; j++) {
inclusionProofs[i].siblings[j] <== treeSiblings[i][j];
inclusionProofs[i].pathIndices[j] <== treePathIndices[i][j];
inclusionProofs[i].pathIndices[j] <== num2Bits[i].out[j];
}
root === inclusionProofs[i].root;
}