-
Notifications
You must be signed in to change notification settings - Fork 613
feat!: Removes normalize() calls on pairing points #14285
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 3 commits
1600053
8fea826
4c8e4e1
dd99736
dd6fd77
fc591f8
13f55b8
931c29e
cb4c5a8
3fb7adc
eaf091c
a96c1c4
4a23614
a4cb309
bbcf1a4
6f6e493
badfefc
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 |
|---|---|---|
|
|
@@ -151,35 +151,67 @@ template <typename Builder_> struct PairingPoints { | |
| Group P1 = Group::reconstruct_from_public(P1_limbs); | ||
| return { P0, P1 }; | ||
| } | ||
|
|
||
| static std::array<fr, PUBLIC_INPUTS_SIZE> construct_dummy_pairing_points() | ||
|
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. probably needs to some cleanup because this is largely duplicated, but we want this to set the dummy pairing points inputs (for the write_vk case). |
||
| { | ||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/911): These are pairing points extracted | ||
| // from a valid proof. This is a workaround because we can't represent the point at infinity in biggroup yet. | ||
| fq x0("0x031e97a575e9d05a107acb64952ecab75c020998797da7842ab5d6d1986846cf"); | ||
| fq y0("0x178cbf4206471d722669117f9758a4c410db10a01750aebb5666547acf8bd5a4"); | ||
| fq x1("0x0f94656a2ca489889939f81e9c74027fd51009034b3357f0e91b8a11e7842c38"); | ||
| fq y1("0x1b52c2020d7464a0c80c0da527a08193fe27776f50224bd6fb128b46c1ddb67f"); | ||
|
|
||
| // We just biggroup here instead of Group (which is either biggroup or biggroup_goblin) because this is the most | ||
| // efficient way of setting the default pairing points. If we use biggroup_goblin elements, we have to convert | ||
| // them back to biggroup elements anyway to add them to the public inputs... | ||
| using BigGroup = element_default:: | ||
| element<Builder, bigfield<Builder, bb::Bn254FqParams>, field_t<Builder>, curve::BN254::Group>; | ||
| BigGroup P0(x0, y0); | ||
| BigGroup P1(x1, y1); | ||
| std::array<fr, PUBLIC_INPUTS_SIZE> dummy_pairing_points_values; | ||
| size_t idx = 0; | ||
| std::array<bigfield<Builder, bb::Bn254FqParams>, 4> elements = { P0.x, P0.y, P1.x, P1.y }; | ||
| for (auto& element : elements) { | ||
| for (auto& limb : element.binary_basis_limbs) { | ||
| dummy_pairing_points_values[idx++] = limb.element.get_value(); | ||
| } | ||
| } | ||
| return dummy_pairing_points_values; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Constructs an arbitrary but valid aggregation state from a valid set of pairing inputs. | ||
| * @brief Adds default public inputs to the builder. | ||
| * @details This should cost exactly 20 gates because there's 4 bigfield elements and each have 5 total | ||
| * witnesses including the prime limb. | ||
| * | ||
| * @param builder | ||
| * @return PairingPoints<Builder> | ||
| */ | ||
| static PairingPoints<Builder> construct_default(typename Curve::Builder& builder) | ||
| { | ||
| using BaseField = typename Curve::BaseField; | ||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/911): These are pairing points extracted from a | ||
| // valid proof. This is a workaround because we can't represent the point at infinity in biggroup yet. | ||
| uint256_t x0_val("0x031e97a575e9d05a107acb64952ecab75c020998797da7842ab5d6d1986846cf"); | ||
| uint256_t y0_val("0x178cbf4206471d722669117f9758a4c410db10a01750aebb5666547acf8bd5a4"); | ||
| uint256_t x1_val("0x0f94656a2ca489889939f81e9c74027fd51009034b3357f0e91b8a11e7842c38"); | ||
| uint256_t y1_val("0x1b52c2020d7464a0c80c0da527a08193fe27776f50224bd6fb128b46c1ddb67f"); | ||
| BaseField x0 = BaseField::from_witness(&builder, x0_val); | ||
| BaseField y0 = BaseField::from_witness(&builder, y0_val); | ||
| BaseField x1 = BaseField::from_witness(&builder, x1_val); | ||
| BaseField y1 = BaseField::from_witness(&builder, y1_val); | ||
| // PairingPoints<Builder> points_accumulator{ Group(x0, y0), Group(x1, y1) }; | ||
| return { Group(x0, y0), Group(x1, y1) }; | ||
| } | ||
|
|
||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/984): Check how many gates this costs and if they're | ||
| // necessary. | ||
| static void add_default_to_public_inputs(Builder& builder) | ||
| { | ||
| PairingPoints<Builder> points_accumulator = construct_default(builder); | ||
| points_accumulator.set_public(); | ||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/911): These are pairing points extracted | ||
| // from a valid proof. This is a workaround because we can't represent the point at infinity in biggroup yet. | ||
| fq x0("0x031e97a575e9d05a107acb64952ecab75c020998797da7842ab5d6d1986846cf"); | ||
| fq y0("0x178cbf4206471d722669117f9758a4c410db10a01750aebb5666547acf8bd5a4"); | ||
| fq x1("0x0f94656a2ca489889939f81e9c74027fd51009034b3357f0e91b8a11e7842c38"); | ||
| fq y1("0x1b52c2020d7464a0c80c0da527a08193fe27776f50224bd6fb128b46c1ddb67f"); | ||
|
|
||
| // We just biggroup here instead of Group (which is either biggroup or biggroup_goblin) because this is the most | ||
| // efficient way of setting the default pairing points. If we use biggroup_goblin elements, we have to convert | ||
| // them back to biggroup elements anyway to add them to the public inputs... | ||
| using BigGroup = element_default:: | ||
| element<Builder, bigfield<Builder, bb::Bn254FqParams>, field_t<Builder>, curve::BN254::Group>; | ||
| BigGroup P0(x0, y0); | ||
| BigGroup P1(x1, y1); | ||
| P0.convert_constant_to_fixed_witness(&builder); | ||
| P1.convert_constant_to_fixed_witness(&builder); | ||
| if (builder.pairing_inputs_public_input_key.is_set()) { | ||
| throw_or_abort("Error: trying to set PairingPoints as public inputs when it already contains one."); | ||
| } | ||
| uint32_t start_idx = P0.set_public(); | ||
| P1.set_public(); | ||
|
|
||
| builder.pairing_inputs_public_input_key.start_idx = start_idx; | ||
| info("Num gates after set_public: ", builder.num_gates); | ||
| } | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #include "barretenberg/stdlib/plonk_recursion/pairing_points.hpp" | ||
| #include "barretenberg/srs/global_crs.hpp" | ||
| #include <gtest/gtest.h> | ||
|
|
||
| namespace bb::stdlib::recursion { | ||
|
|
||
| template <typename Builder> class PairingPointsTests : public testing::Test { | ||
| public: | ||
| static void SetUpTestSuite() { bb::srs::init_file_crs_factory(bb::srs::bb_crs_path()); } | ||
| }; | ||
|
|
||
| using Builders = testing::Types<UltraCircuitBuilder, MegaCircuitBuilder>; | ||
| TYPED_TEST_SUITE(PairingPointsTests, Builders); | ||
|
|
||
| TYPED_TEST(PairingPointsTests, ConstructDefault) | ||
| { | ||
| TypeParam builder; | ||
| info("Num gates: ", builder.num_gates); | ||
| PairingPoints<TypeParam>::add_default_to_public_inputs(builder); | ||
| info("Num gates after add_default_to_public_inputs: ", builder.num_gates); | ||
| builder.finalize_circuit(/*ensure_nonzero=*/true); | ||
| info("Num gates: ", builder.num_gates); | ||
| } | ||
| } // namespace bb::stdlib::recursion |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,6 +75,14 @@ template <typename Flavor> bool UltraVerifier_<Flavor>::verify_proof(const HonkP | |
|
|
||
| DeciderVerifier decider_verifier{ verification_key, transcript }; | ||
| auto decider_output = decider_verifier.verify(); | ||
| if (!decider_output.sumcheck_verified) { | ||
|
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. because I added an assert to aggregate() that checks that the points are initialized with some real points (and not the points at infinity), we need to return early here, otherwise I would've had to change a bunch of tests from ASSERT_FALSE to ASSERT_DEATH, and I was too lazy to do that |
||
| info("Sumcheck failed!"); | ||
| return false; | ||
| } | ||
| if (!decider_output.libra_evals_verified) { | ||
| info("Libra evals failed!"); | ||
| return false; | ||
| } | ||
|
|
||
| // Extract nested pairing points from the proof | ||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/1094): Handle pairing points in keccak flavors. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -155,10 +155,6 @@ AvmRecursiveVerifier_<Flavor>::PairingPoints AvmRecursiveVerifier_<Flavor>::veri | |
| padding_indicator_array, claim_batcher, output.challenge, Commitment::one(&builder), transcript); | ||
|
|
||
| auto pairing_points = PCS::reduce_verify_batch_opening_claim(opening_claim, transcript); | ||
|
|
||
| // TODO(https://github.com/AztecProtocol/barretenberg/issues/1352): Investigate if normalize() calls are needed. | ||
| pairing_points[0] = pairing_points[0].normalize(); | ||
|
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, we won't hit random maximum_value failures in bigfield now that we set the dummy pairing points to be actual points and not arbitrary values |
||
| pairing_points[1] = pairing_points[1].normalize(); | ||
| return pairing_points; | ||
| } | ||
|
|
||
|
|
||
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.
drop because we removed normalize() calls