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: AES NIVC + build #24

Merged
merged 21 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 1 addition & 10 deletions circuits/aes-gcm/nivc/aes-gctr-nivc.circom
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ template AESGCTRFOLD(DATA_BYTES, MAX_STACK_HEIGHT) {
last_counter_num.in[i] <== last_counter_bits.out[31 - i];
}

counter <== last_counter_num.out - 1;
counter <== last_counter_num.out;

// TODO (Colin): We can't call this `WriteToIndex` array this many times, it is too expensive.
0xJepsen marked this conversation as resolved.
Show resolved Hide resolved
// write new plain text block.
Expand Down Expand Up @@ -85,13 +85,4 @@ template AESGCTRFOLD(DATA_BYTES, MAX_STACK_HEIGHT) {
step_out[i] <== aes.counter[i - (2 * DATA_BYTES)];
}
}

// get counter
// signal counterAccumulator[TOTAL_BYTES_ACROSS_NIVC];
// component writeCounter = WriteToIndex(TOTAL_BYTES_ACROSS_NIVC, 4);
// writeCounter.array_to_write_to <== cipherTextAccumulator;
// writeCounter.array_to_write_at_index <== aes.counter;
// writeCounter.index <== DATA_BYTES*2;
// writeCounter.out ==> step_out;

}
5 changes: 3 additions & 2 deletions circuits/test/full/full.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe("NIVC_FULL", async () => {
template: "AESGCTRFOLD",
params: [DATA_BYTES, MAX_STACK_HEIGHT],
});
// console.log("#constraints (AES-GCTR):", await aesCircuit.getConstraintCount()); // TODO (Colin): This is at 1.3M constraints...
console.log("#constraints (AES-GCTR):", await aesCircuit.getConstraintCount());
httpParseAndLockStartLineCircuit = await circomkit.WitnessTester(`ParseAndLockStartLine`, {
file: "http/nivc/parse_and_lock_start_line",
template: "ParseAndLockStartLine",
Expand Down Expand Up @@ -103,7 +103,8 @@ describe("NIVC_FULL", async () => {

// Run the 0th chunk of plaintext
const init_nivc_input = Array(TOTAL_BYTES_ACROSS_NIVC).fill(0); // Blank array to write chunks to and pass through NIVC chain
let pt = http_response_plaintext.slice(16, 16 + 16);
let pt = http_response_plaintext.slice(0, 16);
console.log("pt", pt);
aes_gcm = await aesCircuit.compute({ key: Array(16).fill(0), iv: Array(12).fill(0), plainText: pt, aad: Array(16).fill(0), step_in: init_nivc_input }, ["step_out"]);
for (let i = 1; i < (DATA_BYTES / 16); i++) {
// off by one here
Expand Down
Loading