-
Notifications
You must be signed in to change notification settings - Fork 0
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: multiple plaintext authentication #91
base: main
Are you sure you want to change the base?
Changes from all commits
d4b0930
81e88ee
f09a7ed
f9c9448
40bebe7
1a67a7c
eef7391
53d33e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
pragma circom 2.1.9; | ||
|
||
include "machine.circom"; | ||
// TODO: we don't need this if we do a poly digest of the plaintext in authentication circuit | ||
include "../utils/hash.circom"; | ||
|
||
template HTTPVerification(DATA_BYTES, MAX_NUMBER_OF_HEADERS) { | ||
|
@@ -17,9 +16,10 @@ template HTTPVerification(DATA_BYTES, MAX_NUMBER_OF_HEADERS) { | |
isPadding[i] <== IsEqual()([data[i], -1]); | ||
zeroed_data[i] <== (1 - isPadding[i]) * data[i]; | ||
} | ||
signal data_digest <== PolynomialDigest(DATA_BYTES)(zeroed_data, ciphertext_digest); | ||
signal pt_digest <== PolynomialDigest(DATA_BYTES)(zeroed_data, ciphertext_digest); | ||
|
||
signal input main_digests[MAX_NUMBER_OF_HEADERS + 1]; // Contains digests of start line and all intended headers (up to `MAX_NUMBER_OF_HEADERS`) | ||
// Contains digests of start line and all intended headers (up to `MAX_NUMBER_OF_HEADERS`) | ||
signal input main_digests[MAX_NUMBER_OF_HEADERS + 1]; | ||
signal not_contained[MAX_NUMBER_OF_HEADERS + 1]; | ||
var num_to_match = MAX_NUMBER_OF_HEADERS + 1; | ||
for(var i = 0 ; i < MAX_NUMBER_OF_HEADERS + 1 ; i++) { | ||
|
@@ -106,9 +106,8 @@ template HTTPVerification(DATA_BYTES, MAX_NUMBER_OF_HEADERS) { | |
State[DATA_BYTES - 1].next_parsing_body === 1; | ||
State[DATA_BYTES - 1].next_line_status === 0; | ||
|
||
// TODO: Need to subtract all the header digests here and also wrap them in poseidon. We can use the ones from the input to make this cheaper since they're verified in this circuit! | ||
// subtract all the header digests here and also wrap them in poseidon. | ||
signal body_digest_hashed <== Poseidon(1)([body_digest[DATA_BYTES - 1]]); | ||
signal data_digest_hashed <== Poseidon(1)([data_digest]); | ||
signal option_hash[MAX_NUMBER_OF_HEADERS + 1]; | ||
signal main_digests_hashed[MAX_NUMBER_OF_HEADERS + 1]; | ||
var accumulated_main_digests_hashed = 0; | ||
|
@@ -118,5 +117,5 @@ template HTTPVerification(DATA_BYTES, MAX_NUMBER_OF_HEADERS) { | |
accumulated_main_digests_hashed += main_digests_hashed[i]; | ||
} | ||
|
||
step_out[0] <== step_in[0] + body_digest_hashed - accumulated_main_digests_hashed - data_digest_hashed; // TODO: data_digest is really plaintext_digest from before, consider changing names | ||
step_out[0] <== step_in[0] + body_digest_hashed - accumulated_main_digests_hashed - pt_digest; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to hash There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, i had thought about that, but then how do we calculate pt_digest_hash in authentication circuit? my reasoning to just use digest and not hash was because all others were hashes, so you'd still have to find preimage of those to cancel these? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, because of the different components... Okay, I see. Can you please make some issues on some of these potential security problems like this we're introducing? Then I'm good to sign off on this.. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to write out the counter so that we use the correct counter in the next iteration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Furthermore, we also need to assert the first time around the counter is 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this is captured by the fact the whole PT digest needs to match? My only argument against this is without also verifying the counter, someone could be mischevious and clever with plaintext chunks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, you're right. should we add another public input?
also should i add it here in this PR, or create an issue and tackle with arbitrary data size proofs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this resolved now then? Seems like it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, it's not. have to add a
counter
hash.