-
Notifications
You must be signed in to change notification settings - Fork 598
feat: Make public inputs the start of the UH and MH proof #12266
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
Changes from all commits
712753e
ec4e6b8
e9e0dac
b93aee9
78fa4ec
a56d775
9f88bd8
d7eb28d
4c5c057
6c1ddd0
bb7b27a
997c694
08a3418
d501112
1d38474
c6c4818
6af9ec5
ab4d425
b019547
8871399
69789dd
92fa9ff
70e7b11
5ea2b5b
2450abb
0e3b766
7a91bb4
2c5b043
1b4b844
d9f43eb
0a40f16
29983e6
3be30b6
0a14531
3324da8
e9906f1
ed95505
a8beffd
842af48
40c0c06
bbf89fc
eec3a7c
e92fb0a
1a62e01
e7bd54f
9936983
06df40a
5c79f51
83f2ef3
f79bbca
cb89d02
1c73c92
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 |
|---|---|---|
|
|
@@ -183,11 +183,6 @@ TEST_F(ClientIVCTests, BadProofFailure) | |
| // Construct and accumulate a set of mocked private function execution circuits | ||
| size_t NUM_CIRCUITS = 4; | ||
| for (size_t idx = 0; idx < NUM_CIRCUITS; ++idx) { | ||
| if (idx == 3) { // At idx = 3, we've tampered with the one of the folding proofs so create the recursive | ||
|
Contributor
Author
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. update this test because we got rid of the throw_or_aborts that compare the metadata between the proof and vk, as the metadata only exists in the vk now. |
||
| // folding verifier will throw an error. | ||
| EXPECT_ANY_THROW(circuit_producer.create_next_circuit(ivc, /*log2_num_gates=*/5)); | ||
| break; | ||
| } | ||
| auto circuit = circuit_producer.create_next_circuit(ivc, /*log2_num_gates=*/5); | ||
| ivc.accumulate(circuit); | ||
|
|
||
|
|
@@ -196,6 +191,7 @@ TEST_F(ClientIVCTests, BadProofFailure) | |
| tamper_with_proof(ivc.verification_queue[0].proof); // tamper with first proof | ||
| } | ||
| } | ||
| EXPECT_FALSE(ivc.prove_and_verify()); | ||
| } | ||
|
|
||
| // The IVC fails if the SECOND fold proof is tampered with | ||
|
|
@@ -207,11 +203,6 @@ TEST_F(ClientIVCTests, BadProofFailure) | |
| // Construct and accumulate a set of mocked private function execution circuits | ||
| size_t NUM_CIRCUITS = 4; | ||
| for (size_t idx = 0; idx < NUM_CIRCUITS; ++idx) { | ||
| if (idx == 3) { // At idx = 3, we've tampered with the one of the folding proofs so create the recursive | ||
| // folding verifier will throw an error. | ||
| EXPECT_ANY_THROW(circuit_producer.create_next_circuit(ivc, /*log2_num_gates=*/5)); | ||
| break; | ||
| } | ||
| auto circuit = circuit_producer.create_next_circuit(ivc, /*log2_num_gates=*/5); | ||
| ivc.accumulate(circuit); | ||
|
|
||
|
|
@@ -220,6 +211,7 @@ TEST_F(ClientIVCTests, BadProofFailure) | |
| tamper_with_proof(ivc.verification_queue[1].proof); // tamper with second proof | ||
| } | ||
| } | ||
| EXPECT_FALSE(ivc.prove_and_verify()); | ||
| } | ||
|
|
||
| // The IVC fails if the 3rd/FINAL fold proof is tampered with | ||
|
|
@@ -239,7 +231,7 @@ TEST_F(ClientIVCTests, BadProofFailure) | |
| EXPECT_EQ(ivc.verification_queue.size(), 1); | ||
| tamper_with_proof(ivc.verification_queue[0].proof); // tamper with the final fold proof | ||
|
|
||
| EXPECT_ANY_THROW(ivc.prove_and_verify()); | ||
| EXPECT_FALSE(ivc.prove_and_verify()); | ||
| } | ||
|
|
||
| EXPECT_TRUE(true); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -268,9 +268,6 @@ library Honk { | |
|
|
||
|
|
||
| struct Proof { | ||
| uint256 circuitSize; | ||
| uint256 publicInputsSize; | ||
| uint256 publicInputsOffset; | ||
| // Free wires | ||
| Honk.G1ProofPoint w1; | ||
| Honk.G1ProofPoint w2; | ||
|
|
@@ -310,15 +307,14 @@ struct Transcript { | |
| } | ||
|
|
||
| library TranscriptLib { | ||
| function generateTranscript(Honk.Proof memory proof, bytes32[] calldata publicInputs, uint256 publicInputsSize) | ||
| function generateTranscript(Honk.Proof memory proof, bytes32[] calldata publicInputs, uint256 circuitSize, uint256 publicInputsSize, uint256 pubInputsOffset) | ||
|
Contributor
Author
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. hopefully all of these extra parameters in these functions don't add too much gas?
Member
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. will be minimal! |
||
| internal | ||
| pure | ||
| returns (Transcript memory t) | ||
| { | ||
| Fr previousChallenge; | ||
| (t.relationParameters, previousChallenge) = | ||
| generateRelationParametersChallenges(proof, publicInputs, publicInputsSize, previousChallenge); | ||
|
|
||
| generateRelationParametersChallenges(proof, publicInputs, circuitSize, publicInputsSize, pubInputsOffset, previousChallenge); | ||
|
|
||
| (t.alphas, previousChallenge) = generateAlphaChallenges(previousChallenge, proof); | ||
|
|
||
|
|
@@ -348,25 +344,27 @@ library TranscriptLib { | |
| function generateRelationParametersChallenges( | ||
| Honk.Proof memory proof, | ||
| bytes32[] calldata publicInputs, | ||
| uint256 circuitSize, | ||
| uint256 publicInputsSize, | ||
| uint256 pubInputsOffset, | ||
| Fr previousChallenge | ||
| ) internal pure returns (Honk.RelationParameters memory rp, Fr nextPreviousChallenge) { | ||
| (rp.eta, rp.etaTwo, rp.etaThree, previousChallenge) = | ||
| generateEtaChallenge(proof, publicInputs, publicInputsSize); | ||
| generateEtaChallenge(proof, publicInputs, circuitSize, publicInputsSize, pubInputsOffset); | ||
|
|
||
| (rp.beta, rp.gamma, nextPreviousChallenge) = generateBetaAndGammaChallenges(previousChallenge, proof); | ||
|
|
||
| } | ||
|
|
||
| function generateEtaChallenge(Honk.Proof memory proof, bytes32[] calldata publicInputs, uint256 publicInputsSize) | ||
| function generateEtaChallenge(Honk.Proof memory proof, bytes32[] calldata publicInputs, uint256 circuitSize, uint256 publicInputsSize, uint256 pubInputsOffset) | ||
| internal | ||
| pure | ||
| returns (Fr eta, Fr etaTwo, Fr etaThree, Fr previousChallenge) | ||
| { | ||
| bytes32[] memory round0 = new bytes32[](3 + publicInputsSize + 12); | ||
| round0[0] = bytes32(proof.circuitSize); | ||
| round0[1] = bytes32(proof.publicInputsSize); | ||
| round0[2] = bytes32(proof.publicInputsOffset); | ||
| round0[0] = bytes32(circuitSize); | ||
| round0[1] = bytes32(publicInputsSize); | ||
| round0[2] = bytes32(pubInputsOffset); | ||
| for (uint256 i = 0; i < publicInputsSize; i++) { | ||
| round0[3 + i] = bytes32(publicInputs[i]); | ||
| } | ||
|
|
@@ -554,24 +552,19 @@ library TranscriptLib { | |
| } | ||
|
|
||
| function loadProof(bytes calldata proof) internal pure returns (Honk.Proof memory p) { | ||
| // Metadata | ||
| p.circuitSize = uint256(bytes32(proof[0x00:0x20])); | ||
| p.publicInputsSize = uint256(bytes32(proof[0x20:0x40])); | ||
| p.publicInputsOffset = uint256(bytes32(proof[0x40:0x60])); | ||
|
|
||
| // Commitments | ||
| p.w1 = bytesToG1ProofPoint(proof[0x60:0xe0]); | ||
| p.w1 = bytesToG1ProofPoint(proof[0x0:0x80]); | ||
|
Contributor
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. thank god for GPT for things like this.. |
||
|
|
||
| p.w2 = bytesToG1ProofPoint(proof[0xe0:0x160]); | ||
| p.w3 = bytesToG1ProofPoint(proof[0x160:0x1e0]); | ||
| p.w2 = bytesToG1ProofPoint(proof[0x80:0x100]); | ||
| p.w3 = bytesToG1ProofPoint(proof[0x100:0x180]); | ||
|
|
||
| // Lookup / Permutation Helper Commitments | ||
| p.lookupReadCounts = bytesToG1ProofPoint(proof[0x1e0:0x260]); | ||
| p.lookupReadTags = bytesToG1ProofPoint(proof[0x260:0x2e0]); | ||
| p.w4 = bytesToG1ProofPoint(proof[0x2e0:0x360]); | ||
| p.lookupInverses = bytesToG1ProofPoint(proof[0x360:0x3e0]); | ||
| p.zPerm = bytesToG1ProofPoint(proof[0x3e0:0x460]); | ||
| uint256 boundary = 0x460; | ||
| p.lookupReadCounts = bytesToG1ProofPoint(proof[0x180:0x200]); | ||
| p.lookupReadTags = bytesToG1ProofPoint(proof[0x200:0x280]); | ||
| p.w4 = bytesToG1ProofPoint(proof[0x280:0x300]); | ||
| p.lookupInverses = bytesToG1ProofPoint(proof[0x300:0x380]); | ||
| p.zPerm = bytesToG1ProofPoint(proof[0x380:0x400]); | ||
| uint256 boundary = 0x400; | ||
|
|
||
| // Sumcheck univariates | ||
| for (uint256 i = 0; i < CONST_PROOF_SIZE_LOG_N; i++) { | ||
|
|
@@ -1436,7 +1429,7 @@ abstract contract BaseHonkVerifier is IVerifier { | |
| error ShpleminiFailed(); | ||
|
|
||
| // Number of field elements in a ultra honk zero knowledge proof | ||
| uint256 constant PROOF_SIZE = 443; | ||
| uint256 constant PROOF_SIZE = 440; | ||
|
|
||
| function loadVerificationKey() internal pure virtual returns (Honk.VerificationKey memory); | ||
|
|
||
|
|
@@ -1454,11 +1447,13 @@ abstract contract BaseHonkVerifier is IVerifier { | |
| } | ||
|
|
||
| // Generate the fiat shamir challenges for the whole protocol | ||
| Transcript memory t = TranscriptLib.generateTranscript(p, publicInputs, vk.publicInputsSize); | ||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/1281): Add pubInputsOffset to VK or remove entirely. | ||
Maddiaa0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Transcript memory t = TranscriptLib.generateTranscript(p, publicInputs, vk.circuitSize, vk.publicInputsSize, /*pubInputsOffset=*/1); | ||
|
|
||
| // Derive public input delta | ||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/1281): Add pubInputsOffset to VK or remove entirely. | ||
| t.relationParameters.publicInputsDelta = computePublicInputDelta( | ||
| publicInputs, t.relationParameters.beta, t.relationParameters.gamma, p.publicInputsOffset | ||
| publicInputs, t.relationParameters.beta, t.relationParameters.gamma, /*pubInputsOffset=*/1 | ||
| ); | ||
|
|
||
| // Sumcheck | ||
|
|
||
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.
parsing update