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: Complete ECCVM recursive verifier #6720

Merged
merged 113 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
f3571c6
exploooring
maramihali May 14, 2024
927b78b
start doing recursive work
maramihali May 14, 2024
8b3a8cd
start doing recursive work
maramihali May 14, 2024
1afccd1
Merge branch 'mm/eccvm-work' of github.com:AztecProtocol/aztec-packag…
maramihali May 20, 2024
0e368c1
stuff
maramihali May 20, 2024
e512732
stuff
maramihali May 20, 2024
1ea0798
AAAAAAAAA
maramihali May 21, 2024
d3a94e4
stuff
maramihali May 21, 2024
3a0d99f
stuff
maramihali May 22, 2024
79e448a
implementation and tests
maramihali May 22, 2024
0b8a833
Merge remote-tracking branch 'origin/master' into mm/stdlib-verifier-…
maramihali May 22, 2024
038ca2c
actuall add the code
maramihali May 22, 2024
c89511f
Merge branch 'master' into mm/stdlib-verifier-commitment-key
maramihali May 22, 2024
1b12784
fix typo
maramihali May 22, 2024
b5f4daf
Merge branch 'mm/stdlib-verifier-commitment-key' of github.com:AztecP…
maramihali May 22, 2024
76239b2
Merge branch 'mm/stdlib-verifier-commitment-key' into mm/eccvm-work
maramihali May 22, 2024
b685b09
another thingy
maramihali May 22, 2024
5105e9c
Merge branch 'mm/stdlib-verifier-commitment-key' into mm/eccvm-work
maramihali May 22, 2024
f923145
aaaa
maramihali May 22, 2024
c4a5d0a
more chaos
maramihali May 22, 2024
50bb183
hacking
maramihali May 23, 2024
db48cd7
instantiated relations
maramihali May 23, 2024
5b82114
yay
maramihali May 23, 2024
75cd6a3
something doesn't work...
maramihali May 23, 2024
5b59b40
Merge branch 'mm/ecc_relations_stdlib' into mm/eccvm-work
maramihali May 23, 2024
3204ef1
works
maramihali May 24, 2024
7bf7eae
Merge remote-tracking branch 'origin/master' into mm/ecc_relations_st…
maramihali May 24, 2024
038de13
cleanup
maramihali May 24, 2024
88affab
Merge branch 'mm/ecc_relations_stdlib' into mm/eccvm-work
maramihali May 24, 2024
955cad0
something doesn't work
maramihali May 24, 2024
3405b61
remove unnecessary changes
maramihali May 24, 2024
9ea8d2b
fun times
maramihali May 24, 2024
a2bcef8
yaaay
maramihali May 24, 2024
c776938
stuff is good
maramihali May 24, 2024
3f898b2
add test to ensure inversion is correct and change constructors
maramihali May 24, 2024
4710dd1
Merge remote-tracking branch 'origin/master' into mm/ecc_relations_st…
maramihali May 24, 2024
221afd4
Merge remote-tracking branch 'origin/mm/ecc_relations_stdlib' into mm…
maramihali May 24, 2024
0e507c0
cleanup
maramihali May 24, 2024
660074d
Merge branch 'master' into mm/eccvm-work
maramihali May 28, 2024
9388d5f
cleanup
maramihali May 28, 2024
bb424aa
Merge remote-tracking branch 'origin/master' into mm/eccvm-work
maramihali May 28, 2024
995bea2
delete unnecessary file
maramihali May 28, 2024
a176c23
cleanup
maramihali May 28, 2024
46aa627
get ready for review *fingers crossed*
maramihali May 28, 2024
f67297d
Merge branch 'master' into mm/eccvm-work
maramihali May 28, 2024
7ccaca1
documentation
maramihali May 28, 2024
8d855ab
Merge branch 'mm/eccvm-work' of github.com:AztecProtocol/aztec-packag…
maramihali May 28, 2024
82919be
more cleanup
maramihali May 28, 2024
083ce09
fix build
maramihali May 28, 2024
3c5413d
do self_reduce in sumcheck, don't modify assert_equal in bigfield
maramihali May 28, 2024
4da1bce
add separate grumpkin curve stdlib structure
maramihali May 28, 2024
dc0f0fc
Merge branch 'master' into mm/eccvm-work
maramihali May 28, 2024
0b68af5
fix typos
maramihali May 28, 2024
08f6c88
Merge branch 'mm/eccvm-work' of github.com:AztecProtocol/aztec-packag…
maramihali May 28, 2024
35e63ac
add issues
maramihali May 28, 2024
fea7c51
Merge branch 'master' into mm/eccvm-work
maramihali May 28, 2024
d53f8a8
bump wasm to 28 to fix CI
maramihali May 28, 2024
93a3fa9
Merge branch 'mm/eccvm-work' of github.com:AztecProtocol/aztec-packag…
maramihali May 28, 2024
9e53f60
stuff
maramihali May 28, 2024
4d7f5ec
Merge remote-tracking branch 'origin' into mm/eccvm-pcs-work
maramihali May 28, 2024
bc888c2
fix merge
maramihali May 28, 2024
d059bec
zeromorph change
maramihali May 28, 2024
bcd374a
add one, remove unnecessary stuff in zm
maramihali May 29, 2024
e520106
add one, remove unnecessary stuff in zm
maramihali May 29, 2024
3584b74
Test stubbed
codygunton May 28, 2024
924b086
Implement pow method
codygunton May 28, 2024
34ff7e8
i'm trying
maramihali May 29, 2024
76b4213
add from_bigfield method
maramihali May 29, 2024
8622d93
add from_bigfield method
maramihali May 29, 2024
e3d13aa
batch mul with bigfield fq in cycle_group
maramihali May 29, 2024
7d1defb
batch mul with bigfield fq in cycle_group
maramihali May 29, 2024
e17069f
this is a commit
maramihali May 29, 2024
e2c25bb
works
maramihali May 29, 2024
1c82a5e
operator*
maramihali May 29, 2024
d9c63d3
undo zeromorph changes
maramihali May 29, 2024
4bd4a56
Merge remote-tracking branch 'origin/master' into mm/cycle-scalar-gro…
codygunton May 30, 2024
4b14aa9
Some cleanup
codygunton May 30, 2024
a77b930
Merge branch 'mm/eccvm-pcs-work' of github.com:AztecProtocol/aztec-pa…
maramihali May 30, 2024
d07d278
Merge remote-tracking branch 'origin/master' into mm/cycle-scalar-gro…
maramihali May 30, 2024
9beadf1
conversion from bigfield to cycle_scalar adds constraints
maramihali May 30, 2024
4be213a
Merge branch 'mm/cycle-scalar-group-work' into mm/eccvm-pcs-work
maramihali May 30, 2024
d7e4b1a
conversion from bigfield to cycle_scalar adds constraints
maramihali May 30, 2024
985a929
i merged weirdly
maramihali May 30, 2024
c80a220
Merge remote-tracking branch 'origin/master' into mm/cycle-scalar-gro…
maramihali May 30, 2024
75ca364
add todo
maramihali May 30, 2024
f0425c0
cleanup
maramihali May 30, 2024
f8553f2
Merge branch 'mm/cycle-scalar-group-work' into mm/eccvm-pcs-work
maramihali May 30, 2024
3832c40
almost summer cleaning
maramihali May 30, 2024
957e774
cleanup
maramihali May 30, 2024
829872b
Update bb vs code settings
codygunton May 30, 2024
c33824a
cleanup
maramihali May 30, 2024
91603e2
remove unnecessary constructor
maramihali May 30, 2024
136edd0
remove unnecessary constructor
maramihali May 30, 2024
21c815f
Merge branch 'mm/cycle-scalar-group-work' of github.com:AztecProtocol…
maramihali May 30, 2024
05ac2dd
Merge branch 'mm/cycle-scalar-group-work' into mm/eccvm-pcs-work
maramihali May 30, 2024
c9e376d
Fix typo
codygunton May 30, 2024
eb46957
Merge remote-tracking branch 'origin/master' into mm/cycle-scalar-gro…
codygunton May 30, 2024
4e8d195
Make tests use witnesses
codygunton May 30, 2024
2f9256f
Merge branch 'master' into mm/cycle-scalar-group-work
codygunton May 30, 2024
5ae1df1
Merge remote-tracking branch 'origin/master' into mm/cycle-scalar-gro…
maramihali May 31, 2024
8eec3c9
Merge branch 'mm/cycle-scalar-group-work' into mm/eccvm-pcs-work
maramihali May 31, 2024
b959ec3
add check that cycle_scalar is in field
maramihali May 31, 2024
d1159f3
wopsie pushed too early, now i added validate cycle scalar in field
maramihali May 31, 2024
a361264
Merge branch 'mm/cycle-scalar-group-work' into mm/eccvm-pcs-work
maramihali May 31, 2024
d71eb6a
make kesha somewhat happy
maramihali May 31, 2024
933fe7c
Merge branch 'mm/cycle-scalar-group-work' into mm/eccvm-pcs-work
maramihali May 31, 2024
3c38782
yay
maramihali May 31, 2024
90cbc44
add issue to TODO
maramihali May 31, 2024
9bb9567
Merge branch 'mm/cycle-scalar-group-work' into mm/eccvm-pcs-work
maramihali May 31, 2024
be1f215
respond to PR comments
maramihali May 31, 2024
77f0b38
remove stale todos
maramihali May 31, 2024
9b4f231
make sure it's just the exact points at infinity where we do the hack
maramihali May 31, 2024
28f7f49
undo
maramihali May 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 14 additions & 28 deletions barretenberg/barretenberg.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,10 @@
"ms-vscode.cpptools"
]
},
"launch": {
// Configure LLDB
"configurations": [
{
"name": "(lldb) Launch Target",
"type": "lldb",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [],
"cwd": "${workspaceFolder}/cpp/build",
"internalConsoleOptions": "openOnSessionStart",
"console": "internalConsole",
}
],
},
// Global settings which will apply to all subprojects.
// Each subproject may have their own `.vscode/settings.json`
// for configuring extensions which are specific to a certain project.
// Some settings can only be configured here.
// The following are just provided as example.
"settings": {
"files.associations": {
"*.tcc": "cpp",
Expand All @@ -96,7 +80,6 @@
//
// Location of base CMakeLists file
"cmake.sourceDirectory": "${workspaceFolder}/cpp/",
"cmake.buildDirectory": "${workspaceFolder}/cpp/build",
//
// C/C++ (should be disabled)
//
Expand All @@ -116,9 +99,9 @@
//
// Ensures tests are run from the `build` directory
// which ensures SRS can be read
"testMate.cpp.test.workingDirectory": "${workspaceFolder}/cpp/build",
"testMate.cpp.test.workingDirectory": "${command:cmake.buildDirectory}",
// Filter all binaries that are not tests or benchmarks
"testMate.cpp.test.executables": "${workspaceFolder}/cpp/{build}/bin/*{test,Test,TEST,bench}*",
"testMate.cpp.test.executables": "${command:cmake.buildDirectory}/bin/*{test,Test,TEST,bench}*",
//
// Other
//
Expand All @@ -144,21 +127,24 @@
}
]
},
//
// GTest adapter (not currently used)
//
"gtest-adapter.debugConfig": [
"(lldb) Launch Target"
],
"[cpp]": {
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
},
"cmake.configureArgs": [
"--preset clang16",
"-G Ninja"
],
"cmake.useCMakePresets": "auto",
"cmake.useCMakePresets": "always",
"editor.inlayHints.enabled": "offUnlessPressed",
"git.detectSubmodules": false
"git.detectSubmodules": false,
"testMate.cpp.discovery.loadOnStartup": false,
"testMate.cpp.debug.configTemplate": {
"type": "lldb",
"MIMode": "lldb",
"program": "${exec}",
"args": "${argsArray}",
"cwd": "${command:cmake.buildDirectory}",
"internalConsoleOptions": "openOnSessionStart",
"console": "internalConsole",
}
},
}
369 changes: 247 additions & 122 deletions barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,8 @@ template <typename PCS> class ZeroMorphVerifier_ {
auto phi_n_x = phi_numerator / (x_challenge - 1);

// Add contribution: -v * x * \Phi_n(x) * [1]_1
if constexpr (Curve::is_stdlib_type) {
auto builder = x_challenge.get_context();
scalars.emplace_back(FF(builder, -1) * batched_evaluation * x_challenge * phi_n_x);
} else {
scalars.emplace_back(FF(-1) * batched_evaluation * x_challenge * phi_n_x);
}
scalars.emplace_back(FF(-1) * batched_evaluation * x_challenge * phi_n_x);

commitments.emplace_back(first_g1);

// Add contribution: x * \sum_{i=0}^{m-1} \rho^i*[f_i]
Expand Down Expand Up @@ -704,20 +700,18 @@ template <typename PCS> class ZeroMorphVerifier_ {

// Compute commitment C_{\zeta,Z}
Commitment C_zeta_Z;
FF evaluation;
if constexpr (Curve::is_stdlib_type) {

// Express operation as a batch_mul in order to use Goblinization if available
auto builder = z_challenge.get_context();
std::vector<FF> scalars = { FF(builder, 1), z_challenge };
std::vector<Commitment> points = { C_zeta_x, C_Z_x };
C_zeta_Z = Commitment::batch_mul(points, scalars);
evaluation = FF(builder, 0);
} else {
C_zeta_Z = C_zeta_x + C_Z_x * z_challenge;
evaluation = FF(0);
}

return { .opening_pair = { .challenge = x_challenge, .evaluation = evaluation }, .commitment = C_zeta_Z };
return { .opening_pair = { .challenge = x_challenge, .evaluation = FF(0) }, .commitment = C_zeta_Z };
}

/**
Expand Down Expand Up @@ -782,14 +776,8 @@ template <typename PCS> class ZeroMorphVerifier_ {
const std::vector<RefVector<Commitment>>& concatenation_group_commitments = {},
RefSpan<FF> concatenated_evaluations = {})
{
Commitment first_g1;
// Retrieve the first element in the SRS [1]_1 which will be different depending on the curve we operate on
if constexpr (Curve::is_stdlib_type) {
auto builder = multivariate_challenge[0].get_context();
first_g1 = Commitment(builder, vk->srs->get_first_g1());
} else {
first_g1 = vk->get_first_g1();
}
Commitment first_g1 = vk->get_first_g1();

auto opening_claim = compute_univariate_evaluation_opening_claim(unshifted_commitments,
to_be_shifted_commitments,
unshifted_evaluations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ template <typename Builder> void create_multi_scalar_mul_constraint(Builder& bui
}

// Call batch_mul to multiply the points and scalars and sum the results
auto output_point = cycle_group_ct::batch_mul(scalars, points);
auto output_point = cycle_group_ct::batch_mul(points, scalars);

// Add the constraints
builder.assert_equal(output_point.x.get_witness_index(), input.out_point_x);
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ECCVMProver::ECCVMProver(CircuitBuilder& builder, const std::shared_ptr<Transcri
void ECCVMProver::execute_preamble_round()
{
const auto circuit_size = static_cast<uint32_t>(key->circuit_size);

info("circuit_size");
transcript->send_to_verifier("circuit_size", circuit_size);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ template <typename BuilderType> class ECCVMRecursiveFlavor_ {
using CircuitBuilder = BuilderType; // determines the arithmetisation of recursive verifier
using Curve = stdlib::grumpkin<CircuitBuilder>;
using Commitment = Curve::AffineElement;
using GroupElement = Curve::Element;
using FF = Curve::ScalarField;
using BF = Curve::BaseField;
using RelationSeparator = FF;
using NativeFlavor = ECCVMFlavor;
using NativeVerificationKey = NativeFlavor::VerificationKey;
using PCS = IPA<Curve>;

static constexpr size_t NUM_WIRES = ECCVMFlavor::NUM_WIRES;
// The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ECCVMRecursiveVerifier_<Flavor>::ECCVMRecursiveVerifier_(
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1007): Finish this
template <typename Flavor> void ECCVMRecursiveVerifier_<Flavor>::verify_proof(const HonkProof& proof)
{

using ZeroMorph = ZeroMorphVerifier_<PCS>;
RelationParameters<FF> relation_parameters;

StdlibProof<Builder> stdlib_proof = bb::convert_proof_to_witness(builder, proof);
Expand All @@ -30,6 +30,12 @@ template <typename Flavor> void ECCVMRecursiveVerifier_<Flavor>::verify_proof(co
const auto circuit_size = transcript->template receive_from_prover<BF>("circuit_size");
for (auto [comm, label] : zip_view(commitments.get_wires(), commitment_labels.get_wires())) {
comm = transcript->template receive_from_prover<Commitment>(label);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1017): This is a hack to ensure zero commitments
// are still on curve as the transcript doesn't currently support a point at infinity representation for
// cycle_group
if (!comm.get_value().on_curve()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the point at infinity is at another place, this will fail the circuit. You need to do set_point_at_infinity(x==x_error&&y=y_error)

comm.set_point_at_infinity(true);
}
}

// Get challenge for sorted list batching and wire four memory records
Expand Down Expand Up @@ -64,6 +70,58 @@ template <typename Flavor> void ECCVMRecursiveVerifier_<Flavor>::verify_proof(co

auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] =
sumcheck.verify(relation_parameters, alpha, gate_challenges);

// removed return bool
bool multivariate_opening_verified = ZeroMorph::verify(commitments.get_unshifted(),
commitments.get_to_be_shifted(),
claimed_evaluations.get_unshifted(),
claimed_evaluations.get_shifted(),
multivariate_challenge,
key->pcs_verification_key,
transcript);
// Execute transcript consistency univariate opening round
// TODO(#768): Find a better way to do this. See issue for details.
bool univariate_opening_verified = false;
{
auto hack_commitment = transcript->template receive_from_prover<Commitment>("Translation:hack_commitment");

FF evaluation_challenge_x = transcript->template get_challenge<FF>("Translation:evaluation_challenge_x");

// Construct arrays of commitments and evaluations to be batched
const size_t NUM_UNIVARIATES = 6;
std::array<Commitment, NUM_UNIVARIATES> transcript_commitments = {
commitments.transcript_op, commitments.transcript_Px, commitments.transcript_Py,
commitments.transcript_z1, commitments.transcript_z2, hack_commitment
};
std::array<FF, NUM_UNIVARIATES> transcript_evaluations = {
transcript->template receive_from_prover<FF>("Translation:op"),
transcript->template receive_from_prover<FF>("Translation:Px"),
transcript->template receive_from_prover<FF>("Translation:Py"),
transcript->template receive_from_prover<FF>("Translation:z1"),
transcript->template receive_from_prover<FF>("Translation:z2"),
transcript->template receive_from_prover<FF>("Translation:hack_evaluation")
};

// Get another challenge for batching the univariate claims
FF ipa_batching_challenge = transcript->template get_challenge<FF>("Translation:ipa_batching_challenge");

// Construct batched commitment and batched evaluation
auto batched_commitment = transcript_commitments[0];
auto batched_transcript_eval = transcript_evaluations[0];
auto batching_scalar = ipa_batching_challenge;
for (size_t idx = 1; idx < transcript_commitments.size(); ++idx) {
batched_commitment = batched_commitment + transcript_commitments[idx] * batching_scalar;
batched_transcript_eval += batching_scalar * transcript_evaluations[idx];
batching_scalar *= ipa_batching_challenge;
}

// Construct and verify batched opening claim
OpeningClaim<Curve> batched_univariate_claim = { { evaluation_challenge_x, batched_transcript_eval },
batched_commitment };
univariate_opening_verified =
PCS::reduce_verify(key->pcs_verification_key, batched_univariate_claim, transcript);
}
ASSERT(sumcheck_verified && multivariate_opening_verified && univariate_opening_verified);
}

template class ECCVMRecursiveVerifier_<ECCVMRecursiveFlavor_<UltraCircuitBuilder>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ template <typename Flavor> class ECCVMRecursiveVerifier_ {
using NativeVerificationKey = typename Flavor::NativeVerificationKey;
using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey;
using Builder = typename Flavor::CircuitBuilder;
// using PCS = typename Flavor::PCS;
using PCS = typename Flavor::PCS;
using Transcript = bb::BaseTranscript<bb::stdlib::recursion::honk::StdlibTranscriptParams<Builder>>;
using VerifierCommitments = typename Flavor::VerifierCommitments; // dunno if I need thos
using VerifierCommitments = typename Flavor::VerifierCommitments;

public:
explicit ECCVMRecursiveVerifier_(Builder* builder,
const std::shared_ptr<NativeVerificationKey>& native_verifier_key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ template <typename RecursiveFlavor> class ECCVMRecursiveTests : public ::testing
using InnerFF = InnerFlavor::FF;
using InnerBF = InnerFlavor::BF;

using Transcript = InnerFlavor::Transcript;

using RecursiveVerifier = ECCVMRecursiveVerifier_<RecursiveFlavor>;

using OuterBuilder = typename RecursiveFlavor::CircuitBuilder;
Expand Down Expand Up @@ -74,6 +76,7 @@ template <typename RecursiveFlavor> class ECCVMRecursiveTests : public ::testing
{
InnerBuilder builder = generate_circuit(&engine);
InnerProver prover(builder);
info(builder.get_num_gates());
auto proof = prover.construct_proof();
auto verification_key = std::make_shared<typename InnerFlavor::VerificationKey>(prover.key);

Expand All @@ -85,6 +88,17 @@ template <typename RecursiveFlavor> class ECCVMRecursiveTests : public ::testing
// Check for a failure flag in the recursive verifier circuit
EXPECT_EQ(outer_circuit.failed(), false) << outer_circuit.err();

InnerVerifier native_verifier(prover.key);
bool native_result = native_verifier.verify_proof(proof);
EXPECT_TRUE(native_result);

auto recursive_manifest = verifier.transcript->get_manifest();
auto native_manifest = native_verifier.transcript->get_manifest();
for (size_t i = 0; i < recursive_manifest.size(); ++i) {
EXPECT_EQ(recursive_manifest[i], native_manifest[i])
<< "Recursive Verifier/Verifier manifest discrepency in round " << i;
}

// Ensure verification key is the same
EXPECT_EQ(verifier.key->circuit_size, verification_key->circuit_size);
EXPECT_EQ(verifier.key->log_circuit_size, verification_key->log_circuit_size);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once
#include "barretenberg/commitment_schemes/verification_key.hpp"
#include "barretenberg/stdlib/primitives/curves/bn254.hpp"
#include "barretenberg/stdlib/primitives/group/cycle_group.hpp"
namespace bb {

/**
Expand All @@ -11,13 +9,15 @@ namespace bb {
*/
template <typename Curve> class VerifierCommitmentKey {
using Builder = Curve::Builder;
using Commitment = stdlib::cycle_group<Builder>;
using Commitment = Curve::AffineElement;
using NativeEmbeddedCurve = typename Builder::EmbeddedCurve;

public:
/**
* @brief Construct a new Verifier Commitment Key object from its native counterpart. instantiated on Grumpkin.
* This will potentially be part of the ECCVMRecursiveFlavor once implemented.
* This will be part of the ECCVMRecursiveFlavor once implemented. The Grumpkin SRS points are represented after
* applying the pippenger point table so the values at odd indices contain the point {srs[i-1].x * beta,
* srs[i-1].y}, where beta is the endomorphism. We retrieve only the original SRS for IPA verification.
*
* @details The Grumpkin SRS points will be initialised as constants in the circuit but might be subsequently
* turned into constant witnesses to make operations in the circuit more efficient.
Expand All @@ -29,7 +29,7 @@ template <typename Curve> class VerifierCommitmentKey {
{

auto* native_points = native_pcs_verification_key->get_monomial_points();
for (size_t i = 0; i < num_points; i++) {
for (size_t i = 0; i < num_points * 2; i += 2) {
monomial_points.emplace_back(Commitment(native_points[i]));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

#include "barretenberg/eccvm_recursion/verifier_commitment_key.hpp"
#include "barretenberg/stdlib/primitives/curves/grumpkin.hpp"
#include <gtest/gtest.h>
namespace bb {
template <typename Curve> class RecursiveVeriferCommitmentKeyTest : public testing::Test {
Expand Down Expand Up @@ -27,13 +28,16 @@ template <typename Curve> class RecursiveVeriferCommitmentKeyTest : public testi
EXPECT_EQ(native_vk->get_first_g1(), recursive_vk->get_first_g1().get_value());
auto* native_monomial_points = native_vk->get_monomial_points();
auto recursive_monomial_points = recursive_vk->get_monomial_points();
for (size_t i = 0; i < num_points; i++) {
EXPECT_EQ(native_monomial_points[i], recursive_monomial_points[i].get_value());

// The recursive verifier commitment key only stores the SRS so we verify against the even indices of the native
// key (the odd containt elements produced after applying the pippenger point table).
for (size_t i = 0; i < num_points * 2; i += 2) {
EXPECT_EQ(native_monomial_points[i], recursive_monomial_points[i >> 1].get_value());
}
}
};

using Curves = testing::Types<stdlib::bn254<UltraCircuitBuilder>, stdlib::bn254<MegaCircuitBuilder>>;
using Curves = testing::Types<stdlib::grumpkin<UltraCircuitBuilder>, stdlib::grumpkin<MegaCircuitBuilder>>;

TYPED_TEST_SUITE(RecursiveVeriferCommitmentKeyTest, Curves);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cycle_group<C> pedersen_commitment<C>::commit(const std::vector<field_t>& inputs
points.emplace_back(base_points[i]);
}

return cycle_group::batch_mul(scalars, points);
return cycle_group::batch_mul(points, scalars);
}

template <typename C>
Expand All @@ -37,7 +37,7 @@ cycle_group<C> pedersen_commitment<C>::commit(const std::vector<std::pair<field_
points.emplace_back(context.generators->get(1, context.offset, context.domain_separator)[0]);
}

return cycle_group::batch_mul(scalars, points);
return cycle_group::batch_mul(points, scalars);
}

template class pedersen_commitment<bb::StandardCircuitBuilder>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ std::array<field_t<C>, 2> schnorr_verify_signature_internal(const byte_array<C>&
cycle_group<C> g1(grumpkin::g1::one);
// compute g1 * sig.s + key * sig,e

auto x_3 = cycle_group<C>::batch_mul({ sig.s, sig.e }, { g1, pub_key }).x;
auto x_3 = cycle_group<C>::batch_mul({ g1, pub_key }, { sig.s, sig.e }).x;
// build input (pedersen(([s]g + [e]pub).x | pub.x | pub.y) | message) to hash function
// pedersen hash ([r].x | pub.x) to make sure the size of `hash_input` is <= 64 bytes for a 32 byte message
byte_array<C> hash_input(pedersen_hash<C>::hash({ x_3, pub_key.x, pub_key.y }));
Expand Down
Loading
Loading