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

fix: aes-gctr-nivc #43

Merged
merged 4 commits into from
Nov 13, 2024
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
2 changes: 1 addition & 1 deletion builds/target_512b/json_extract_value_512b.circom
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pragma circom 2.1.9;

include "../../circuits/json/nivc/extractor.circom";

component main { public [step_in] } = MaskExtractFinal(512, 50);
component main { public [step_in] } = MaskExtractFinal(512, 48);
8 changes: 7 additions & 1 deletion circuits/aes-gcm/nivc/aes-gctr-nivc.circom
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ template AESGCTRFOLD() {
aes.plainText <== plainText;
aes.lastCounter <== ctr;

aes.cipherText === cipherText;
signal ciphertext_equal_check[16];
for(var i = 0 ; i < 16 ; i++) {
ciphertext_equal_check[i] <== IsEqual()([aes.cipherText[i], cipherText[i]]);
ciphertext_equal_check[i] === 1;
}


var packedPlaintext = 0;
for(var i = 0 ; i < 16 ; i++) {
packedPlaintext += plainText[i] * 2**(8*i);
Expand Down
12 changes: 9 additions & 3 deletions circuits/http/nivc/http_nivc.circom
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ template HttpNIVC(DATA_BYTES, MAX_NUMBER_OF_HEADERS) {
start_line[i] <== data[i] * (1 - not_start_line_mask[i]);
}
signal inner_start_line_hash <== DataHasher(DATA_BYTES)(start_line);
inner_start_line_hash === start_line_hash;
signal start_line_hash_equal_check <== IsEqual()([inner_start_line_hash, start_line_hash]);
start_line_hash_equal_check === 1;

// Get the header shit
signal header[MAX_NUMBER_OF_HEADERS][DATA_BYTES];
Expand All @@ -60,10 +61,12 @@ template HttpNIVC(DATA_BYTES, MAX_NUMBER_OF_HEADERS) {
}
signal inner_header_hashes[MAX_NUMBER_OF_HEADERS];
signal header_is_unused[MAX_NUMBER_OF_HEADERS]; // If a header hash is passed in as 0, it is not used (no way to compute preimage of 0)
signal header_hashes_equal_check[MAX_NUMBER_OF_HEADERS];
for(var i = 0 ; i < MAX_NUMBER_OF_HEADERS ; i++) {
header_is_unused[i] <== IsZero()(header_hashes[i]);
inner_header_hashes[i] <== DataHasher(DATA_BYTES)(header[i]);
(1 - header_is_unused[i]) * inner_header_hashes[i] === header_hashes[i];
header_hashes_equal_check[i] <== IsEqual()([(1 - header_is_unused[i]) * inner_header_hashes[i], header_hashes[i]]);
header_hashes_equal_check[i] === 1;
}

// Get the body shit
Expand All @@ -72,6 +75,9 @@ template HttpNIVC(DATA_BYTES, MAX_NUMBER_OF_HEADERS) {
body[i] <== data[i] * State[i].parsing_body;
}
signal inner_body_hash <== DataHasher(DATA_BYTES)(body);
inner_body_hash === body_hash;
signal body_hash_equal_check <== IsEqual()([inner_body_hash, body_hash]);
body_hash_equal_check === 1;


step_out[0] <== inner_body_hash;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "web-prover-circuits",
"description": "ZK Circuits for WebProofs",
"version": "0.5.1",
"version": "0.5.2",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand Down