Skip to content

Commit

Permalink
fix: HTTP formatting constraints (#78)
Browse files Browse the repository at this point in the history
* fix: http headers max

* fix: verify HTTP machine state at end
  • Loading branch information
Autoparallel authored Dec 5, 2024
1 parent 7eb6b39 commit 45d35ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions circuits/http/machine.circom
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ template StateChange() {
// enable parsing header on reading CRLF
signal enableParsingHeader <== readCRLF * isParsingStart;
// check if we are parsing header
// TODO: correct this 3 (it means we can parse max 2^3 headers)
signal isParsingHeader <== GreaterEqThan(3)([state[1], 1]);
// Allows for max headers to be 2^5 = 32
signal isParsingHeader <== GreaterEqThan(5)([state[1], 1]);
// increment parsing header counter on CRLF and parsing header
signal incrementParsingHeader <== readCRLF * isParsingHeader;
// disable parsing header on reading CRLF-CRLF
Expand Down
8 changes: 8 additions & 0 deletions circuits/http/verification.circom
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,12 @@ template HTTPVerification(DATA_BYTES, MAX_NUMBER_OF_HEADERS) {
body_hash_equal_check === 1;

step_out[0] <== inner_body_hash;

// Verify machine ends in a valid state
State[DATA_BYTES - 1].next_parsing_start === 0;
State[DATA_BYTES - 1].next_parsing_header === 0;
State[DATA_BYTES - 1].next_parsing_field_name === 0;
State[DATA_BYTES - 1].next_parsing_field_value === 0;
State[DATA_BYTES - 1].next_parsing_body === 1;
State[DATA_BYTES - 1].next_line_status === 0;
}

0 comments on commit 45d35ed

Please sign in to comment.