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: sumcheck part of ECCVM recursive verifier instantiated as an UltraCircuit #6413

Merged
merged 59 commits into from
May 28, 2024
Merged
Changes from 3 commits
Commits
Show all changes
59 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
ce88bb0
Merge branch 'mm/eccvm-work' of github.com:AztecProtocol/aztec-packag…
maramihali May 28, 2024
a9f3b86
fix gcc
maramihali May 28, 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
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ set(BARRETENBERG_TARGET_OBJECTS
$<TARGET_OBJECTS:dsl_objects>
$<TARGET_OBJECTS:ecc_objects>
$<TARGET_OBJECTS:eccvm_objects>
$<TARGET_OBJECTS:eccvm_recursion_objects>
$<TARGET_OBJECTS:eccvm_recursion_objects>
$<TARGET_OBJECTS:execution_trace_objects>
$<TARGET_OBJECTS:simple_example_objects>
$<TARGET_OBJECTS:flavor_objects>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
barretenberg_module(eccvm_recursion eccvm stdlib_honk_recursion commitment_schemes)
barretenberg_module(eccvm_recursion eccvm relations stdlib_circuit_builders commitment_schemes stdlib_primitives)
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include "barretenberg/eccvm_recursion/eccvm_recursive_flavor.hpp"
#include "barretenberg/relations/ecc_vm/ecc_lookup_relation.hpp"
#include "barretenberg/relations/ecc_vm/ecc_msm_relation.hpp"
#include "barretenberg/relations/ecc_vm/ecc_point_table_relation.hpp"
#include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp"
#include <gtest/gtest.h>
namespace bb {

class EccRelationsConsistency : public testing::Test {
public:
template <typename InputElements> static InputElements get_input()
{
InputElements result;
for (auto& element : result.get_all()) {
element = 4;
}
return result;
}
template <template <typename> class Relation> static void validate_relation_execution()
{
using RecursiveFlavor = ECCVMRecursiveFlavor_<UltraCircuitBuilder>;
using RecursiveRelation = Relation<typename RecursiveFlavor::FF>;
const RelationParameters<typename RecursiveFlavor::FF> parameters;
const auto input_elements = get_input<typename RecursiveFlavor::AllValues>();
typename RecursiveRelation::SumcheckArrayOfValuesOverSubrelations accumulator;
std::fill(accumulator.begin(), accumulator.end(), typename RecursiveRelation::FF(0));
RecursiveRelation::accumulate(accumulator, input_elements, parameters, 1);

using NativeFlavor = ECCVMFlavor;
using NativeRelation = Relation<typename NativeFlavor::FF>;
const RelationParameters<typename NativeFlavor::FF> native_parameters;
const auto native_input_elements = get_input<typename NativeFlavor::AllValues>();
typename NativeRelation::SumcheckArrayOfValuesOverSubrelations native_accumulator;
std::fill(native_accumulator.begin(), native_accumulator.end(), typename NativeRelation::FF(0));
NativeRelation::accumulate(native_accumulator, native_input_elements, native_parameters, 1);

for (auto [val, native_val] : zip_view(accumulator, native_accumulator)) {
EXPECT_EQ(val.get_value().lo, uint256_t(native_val));
}
// return accumulator;
};
};

TEST_F(EccRelationsConsistency, ECCVMLookupRelation)
{

validate_relation_execution<ECCVMMSMRelation>();

// using NativeRelation = ECCVMLookupRelation<NativeFF>;
// auto native_accumulator = validate_relation_execution<NativeRelation>();

// for (auto [val, native_val] : zip_view(accumulator, native_accumulator)) {
// EXPECT_EQ(bb::fq((val.get_value() % uint512_t(bb::fq::modulus)).lo), native_val);
// }

// using ECCVMMSMRelation = ECCVMMSMRelation<FF>;
// validate_relation_execution<ECCVMMSMRelation>();

// using ECCVMPointTableRelation = ECCVMPointTableRelation<FF>;
// validate_relation_execution<ECCVMPointTableRelation>();

// using ECCVMSetRelation = ECCVMSetRelation<FF>;
// validate_relation_execution<ECCVMSetRelation>();

// using ECCVMTranscriptRelation = ECCVMTranscriptRelation<FF>;
// validate_relation_execution<ECCVMTranscriptRelation>();

// using ECCVMWnafRelation = ECCVMWnafRelation<FF>;
// validate_relation_execution<ECCVMWnafRelation>();
}
} // namespace bb
Original file line number Diff line number Diff line change
@@ -26,16 +26,12 @@ template <typename BuilderType> class ECCVMRecursiveFlavor_ {
using CircuitBuilder = BuilderType; // determines the arithmetisation of recursive verifier

// I need to somehow make this bn254 hashtag confusion
// the native stuff becomes nonnative and the nonnative stuff becomes native and everything is in circuit land is
// probably what's going on
using Curve = stdlib::bn254<CircuitBuilder, true>;
using PCS = IPA<Curve>;
using Commitment = typename Curve::AffineElement;
using FF = typename Curve::ScalarField;
using BF = typename Curve::BaseField;
using RelationSeparator = FF;
using NativeFlavor = ECCVMFlavor;
using NativeVerificationKey = NativeFlavor::VerificationKey;

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
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#include "barretenberg/common/constexpr_utils.hpp"

#include "barretenberg/honk/proof_system/logderivative_library.hpp"
#include "ecc_lookup_relation.hpp"

Original file line number Diff line number Diff line change
@@ -42,7 +42,6 @@ void ECCVMMSMRelationImpl<FF>::accumulate(ContainerOverSubrelations& accumulator
{
using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>;
using View = typename Accumulator::View;

const auto& x1 = View(in.msm_x1);
const auto& y1 = View(in.msm_y1);
const auto& x2 = View(in.msm_x2);
@@ -255,7 +254,7 @@ void ECCVMMSMRelationImpl<FF>::accumulate(ContainerOverSubrelations& accumulator
* i.e. for the skew round we can use the slice values as our "selector" when doing conditional point adds
*/
Accumulator skew_relation(0);
static constexpr FF inverse_seven = FF(7).invert();
static FF inverse_seven = FF(7).invert();
auto skew1_select = slice1 * inverse_seven;
auto skew2_select = slice2 * inverse_seven;
auto skew3_select = slice3 * inverse_seven;
Original file line number Diff line number Diff line change
@@ -128,7 +128,11 @@ Accumulator ECCVMSetRelationImpl<FF>::compute_grand_product_numerator(const AllE
const auto& table_y = View(in.precompute_ty);

const auto& precompute_skew = View(in.precompute_skew);
<<<<<<< HEAD
static constexpr FF negative_inverse_seven = FF(-7).invert();
=======
static FF negative_inverse_seven = FF(-7).invert();
>>>>>>> mm/ecc_relations_stdlib
auto adjusted_skew = precompute_skew * negative_inverse_seven;

const auto& wnaf_scalar_sum = View(in.precompute_scalar_sum);
@@ -297,7 +301,7 @@ Accumulator ECCVMSetRelationImpl<FF>::compute_grand_product_denominator(const Al

auto lookup_first = (-z1_zero + 1);
auto lookup_second = (-z2_zero + 1);
FF endomorphism_base_field_shift = FF::cube_root_of_unity();
FF endomorphism_base_field_shift = FF(bb::fq::cube_root_of_unity());

auto transcript_input1 = transcript_pc + transcript_Px * beta + transcript_Py * beta_sqr + z1 * beta_cube;
auto transcript_input2 = (transcript_pc - 1) + transcript_Px * endomorphism_base_field_shift * beta -
Original file line number Diff line number Diff line change
@@ -14,8 +14,9 @@ namespace bb::stdlib {
template <typename Builder, typename T> class bigfield {

public:
typedef T TParams;
typedef bb::field<T> native;
using View = bigfield;
using TParams = T;
using native = bb::field<T>;

struct Basis {
uint512_t modulus;
@@ -60,8 +61,27 @@ template <typename Builder, typename T> class bigfield {
const size_t maximum_bitlength = 0);
bigfield(Builder* parent_context = nullptr);
bigfield(Builder* parent_context, const uint256_t& value);
// (:
bigfield(const uint256_t& value) { bigfield(nullptr, value); }

explicit bigfield(const uint256_t& value) { bigfield(nullptr, value); }

/**
* @brief Constructs a new bigfield object from an int value. We first need to to construct a field element from the
* value to avoid bugs that have to do with the value being negative.
*
*/
bigfield(const int value)
{
uint256_t result = uint256_t(bb::fr(value));
bigfield(nullptr, result);
}

/**
* @brief Construct a new bigfield object from bb::fq. We first convert to uint256_t as field elements are in
* Montgomery form internally.
*
* @param value
*/
bigfield(const bb::fq value) { bigfield(nullptr, uint256_t(value)); }

// we assume the limbs have already been normalized!
bigfield(const field_t<Builder>& a,
@@ -257,6 +277,14 @@ template <typename Builder, typename T> class bigfield {
void self_reduce() const;

bool is_constant() const { return prime_basis_limb.witness_index == IS_CONSTANT; }

/**
* @brief Inverting function with the assumption that the bigfield element we are calling invert on is not zero.
*
* @return bigfield
*/
bigfield invert() const { return (bigfield(1) / bigfield(*this)); }

/**
* Create a public one constant
* */
@@ -499,4 +527,4 @@ template <typename C, typename T> inline std::ostream& operator<<(std::ostream&

} // namespace bb::stdlib

#include "bigfield_impl.hpp"
#include "bigfield_impl.hpp"