make naming more consistent

This commit is contained in:
Dmitriy Ryajov 2023-04-10 14:23:26 -06:00
parent ddace087f7
commit cd40a6e39d
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
2 changed files with 10 additions and 10 deletions

View File

@ -13,24 +13,24 @@ function roundUpDiv(x, n) {
return div;
}
template parallel PoseidonDigest(BLOCK_SIZE, CHUNK_SIZE) {
template parallel PoseidonDigest(BLOCK_SIZE, DIGEST_CHUNK) {
// BLOCK_SIZE - size of the input block array
// CHUNK_SIZE - number of elements to hash at once
// DIGEST_CHUNK - number of elements to hash at once
signal input block[BLOCK_SIZE]; // Input block array
signal output hash; // Output hash
// Split array into chunks of size CHUNK_SIZE, usually 2
var NUM_CHUNKS = roundUpDiv(BLOCK_SIZE, CHUNK_SIZE);
// Split array into chunks of size DIGEST_CHUNK, usually 2
var NUM_CHUNKS = roundUpDiv(BLOCK_SIZE, DIGEST_CHUNK);
// Initialize an array to store hashes of each block
component hashes[NUM_CHUNKS];
// Loop over chunks and hash them using Poseidon()
for (var i = 0; i < NUM_CHUNKS; i++) {
hashes[i] = Poseidon(CHUNK_SIZE);
hashes[i] = Poseidon(DIGEST_CHUNK);
var start = i * CHUNK_SIZE;
var end = start + CHUNK_SIZE;
var start = i * DIGEST_CHUNK;
var end = start + DIGEST_CHUNK;
for (var j = start; j < end; j++) {
if (j >= BLOCK_SIZE) {
hashes[i].inputs[j - start] <== 0;

View File

@ -34,11 +34,11 @@ template parallel MerkleProof(LEVELS) {
root <== hasher[LEVELS - 1].out;
}
template StorageProver(BLOCK_SIZE, QUERY_LEN, LEVELS, CHUNK_SIZE) {
template StorageProver(BLOCK_SIZE, QUERY_LEN, LEVELS, DIGEST_CHUNK) {
// BLOCK_SIZE: size of block in symbols
// QUERY_LEN: query length, i.e. number if indices to be proven
// LEVELS: size of Merkle Tree in the manifest
// CHUNK_SIZE: number of symbols to hash in one go
// DIGEST_CHUNK: number of symbols to hash in one go
signal input chunks[QUERY_LEN][BLOCK_SIZE]; // chunks to be proven
signal input siblings[QUERY_LEN][LEVELS]; // siblings hashes of chunks to be proven
signal input path[QUERY_LEN]; // path of chunks to be proven
@ -50,7 +50,7 @@ template StorageProver(BLOCK_SIZE, QUERY_LEN, LEVELS, CHUNK_SIZE) {
component hashers[QUERY_LEN];
for (var i = 0; i < QUERY_LEN; i++) {
hashers[i] = PoseidonDigest(BLOCK_SIZE, CHUNK_SIZE);
hashers[i] = PoseidonDigest(BLOCK_SIZE, DIGEST_CHUNK);
hashers[i].block <== chunks[i];
hashers[i].hash === hashes[i];
}