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: multiple plaintext authentication #91

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

lonerapier
Copy link
Collaborator

@lonerapier lonerapier commented Jan 15, 2025

closes #89
closes #80

@lonerapier lonerapier changed the title Feat/multiple plaintext authentication feat: multiple plaintext authentication Jan 15, 2025
@lonerapier lonerapier marked this pull request as ready for review January 16, 2025 16:46
package.json Outdated Show resolved Hide resolved
@Autoparallel
Copy link
Contributor

Can you make an updated diagram for this version?

Copy link
Contributor

@Autoparallel Autoparallel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Given tests are all passing and this is being integrated into web prover, we will know with certainty this all works.

Please see my comments, especially about versioning. Let me know if you want to meet!

circuits/http/verification.circom Outdated Show resolved Hide resolved
signal part_ciphertext_digest <== DataHasher(DATA_BYTES)(bigEndianCiphertext);
signal plaintext_digest <== PolynomialDigestWithCounter(DATA_BYTES)(zeroed_plaintext, ciphertext_digest, plaintext_index_counter);

step_out[0] <== step_in[0] - part_ciphertext_digest + plaintext_digest;
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Collaborator Author

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?

Copy link
Contributor

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.

Copy link
Collaborator Author

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.

circuits/utils/hash.circom Show resolved Hide resolved
@@ -0,0 +1,13 @@
pragma circom 2.1.9;

function log2Ceil(a) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be used in the JSON parser/machine. I have a comment about it in there actually.

circuits/test/utils/hash.test.ts Show resolved Hide resolved
@lonerapier lonerapier force-pushed the feat/multiple-plaintext-authentication branch from 5b1ac19 to 53d33e1 Compare January 17, 2025 14:12
Copy link
Contributor

@Autoparallel Autoparallel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more comments

@@ -1,7 +1,7 @@
{
"name": "web-prover-circuits",
"description": "ZK Circuits for WebProofs",
"version": "0.7.3",
"version": "0.7.4",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API for these circuits is changing. I still think this should be 0.8.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

signal part_ciphertext_digest <== DataHasher(DATA_BYTES)(bigEndianCiphertext);
signal plaintext_digest <== PolynomialDigestWithCounter(DATA_BYTES)(zeroed_plaintext, ciphertext_digest, plaintext_index_counter);

step_out[0] <== step_in[0] - part_ciphertext_digest + plaintext_digest;
Copy link
Contributor

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.

@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to hash pt_digest?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The 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..

@devloper
Copy link
Contributor

high level review lgtm, I'll defer to colin for deeper comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: support multiple ciphertext matching ci: release artifacts circuit assert
3 participants