Skip to content

Commit fcfabfa

Browse files
feat: Add the prototype of goblin translator circuit builder (#577)
Co-authored-by: codygunton <[email protected]>
1 parent 970bb07 commit fcfabfa

16 files changed

+1191
-39
lines changed

cpp/src/barretenberg/common/serialize.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
__extension__ using uint128_t = unsigned __int128;
4545
#endif
4646

47-
template <typename T>
48-
concept IntegralOrEnum = std::integral<T> || std::is_enum_v<T>;
47+
template <typename T> concept IntegralOrEnum = std::integral<T> || std::is_enum_v<T>;
4948

5049
namespace serialize {
5150
// Forward declare derived msgpack methods

cpp/src/barretenberg/common/streams.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ template <std::integral T, typename A> inline std::ostream& operator<<(std::ostr
3030
}
3131

3232
template <typename T, typename A>
33-
requires(!std::integral<T>)
34-
inline std::ostream& operator<<(std::ostream& os, std::vector<T, A> const& arr)
33+
requires(!std::integral<T>) inline std::ostream& operator<<(std::ostream& os, std::vector<T, A> const& arr)
3534
{
3635
os << "[\n";
3736
for (auto element : arr) {

cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#include "block_constraint.hpp"
21
#include "acir_format.hpp"
32
#include "barretenberg/plonk/proof_system/types/proof.hpp"
43
#include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp"
4+
#include "block_constraint.hpp"
55

66
#include <gtest/gtest.h>
77
#include <vector>

cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#include "ecdsa_secp256k1.hpp"
21
#include "acir_format.hpp"
32
#include "barretenberg/crypto/ecdsa/ecdsa.hpp"
43
#include "barretenberg/plonk/proof_system/types/proof.hpp"
54
#include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp"
5+
#include "ecdsa_secp256k1.hpp"
66

77
#include <gtest/gtest.h>
88
#include <vector>

cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#include "ecdsa_secp256r1.hpp"
21
#include "acir_format.hpp"
32
#include "barretenberg/crypto/ecdsa/ecdsa.hpp"
43
#include "barretenberg/plonk/proof_system/types/proof.hpp"
54
#include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp"
5+
#include "ecdsa_secp256r1.hpp"
66

77
#include <gtest/gtest.h>
88
#include <vector>

cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#include "recursion_constraint.hpp"
21
#include "acir_format.hpp"
32
#include "barretenberg/plonk/proof_system/types/proof.hpp"
43
#include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp"
4+
#include "recursion_constraint.hpp"
55

66
#include <gtest/gtest.h>
77
#include <vector>

cpp/src/barretenberg/honk/sumcheck/relations/relation_types.hpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
#include "relation_parameters.hpp"
77

88
namespace proof_system::honk::sumcheck {
9-
template <typename T>
10-
concept HasSubrelationLinearlyIndependentMember = requires(T) { T::Relation::SUBRELATION_LINEARLY_INDEPENDENT; };
9+
template <typename T> concept HasSubrelationLinearlyIndependentMember = requires(T)
10+
{
11+
T::Relation::SUBRELATION_LINEARLY_INDEPENDENT;
12+
};
1113
/**
1214
* @brief The templates defined herein facilitate sharing the relation arithmetic between the prover and the verifier.
1315
*
@@ -34,9 +36,9 @@ concept HasSubrelationLinearlyIndependentMember = requires(T) { T::Relation::SUB
3436
* @return requires
3537
*/
3638
template <typename FF, typename AccumulatorTypes, typename T>
37-
requires std::is_same<std::span<FF>, T>::value
38-
inline typename std::tuple_element<0, typename AccumulatorTypes::AccumulatorViews>::type get_view(const T& input,
39-
const size_t index)
39+
requires std::is_same<std::span<FF>, T>::value inline
40+
typename std::tuple_element<0, typename AccumulatorTypes::AccumulatorViews>::type
41+
get_view(const T& input, const size_t index)
4042
{
4143
return input[index];
4244
}
@@ -110,8 +112,8 @@ template <typename FF, template <typename> typename RelationBase> class Relation
110112
* @tparam size_t
111113
*/
112114
template <size_t>
113-
static constexpr bool is_subrelation_linearly_independent()
114-
requires(!HasSubrelationLinearlyIndependentMember<Relation>)
115+
static constexpr bool is_subrelation_linearly_independent() requires(
116+
!HasSubrelationLinearlyIndependentMember<Relation>)
115117
{
116118
return true;
117119
}
@@ -122,8 +124,8 @@ template <typename FF, template <typename> typename RelationBase> class Relation
122124
* @tparam size_t
123125
*/
124126
template <size_t subrelation_index>
125-
static constexpr bool is_subrelation_linearly_independent()
126-
requires(HasSubrelationLinearlyIndependentMember<Relation>)
127+
static constexpr bool is_subrelation_linearly_independent() requires(
128+
HasSubrelationLinearlyIndependentMember<Relation>)
127129
{
128130
return std::get<subrelation_index>(Relation::SUBRELATION_LINEARLY_INDEPENDENT);
129131
}

cpp/src/barretenberg/honk/sumcheck/sumcheck_round.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,8 @@ template <typename Flavor> class SumcheckRound {
481481
template <typename... T>
482482
static constexpr void add_tuples(std::tuple<T...>& tuple_1, const std::tuple<T...>& tuple_2)
483483
{
484-
[&]<std::size_t... I>(std::index_sequence<I...>) {
485-
((std::get<I>(tuple_1) += std::get<I>(tuple_2)), ...);
486-
}(std::make_index_sequence<sizeof...(T)>{});
484+
[&]<std::size_t... I>(std::index_sequence<I...>) { ((std::get<I>(tuple_1) += std::get<I>(tuple_2)), ...); }
485+
(std::make_index_sequence<sizeof...(T)>{});
487486
}
488487

489488
/**

cpp/src/barretenberg/proof_system/arithmetization/arithmetization.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#pragma once
2+
#include "barretenberg/ecc/curves/bn254/bn254.hpp"
23
#include <array>
34
#include <barretenberg/common/slab_allocator.hpp>
45
#include <cstddef>
@@ -173,4 +174,10 @@ template <typename _FF> class Ultra : public Arithmetization</*NUM_WIRES =*/4, /
173174
// ~Selectors() = default;
174175
};
175176
};
177+
class GoblinTranslator : public Arithmetization</*NUM_WIRES =*/78, /*num_selectors =*/0> {
178+
public:
179+
// Dirty hack
180+
using Selectors = bool;
181+
using FF = curve::BN254::ScalarField;
182+
};
176183
} // namespace arithmetization

cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ void CircuitBuilderBase<Arithmetization>::assert_equal(const uint32_t a_variable
4646
template class CircuitBuilderBase<arithmetization::Standard<barretenberg::fr>>;
4747
template class CircuitBuilderBase<arithmetization::Standard<grumpkin::fr>>;
4848
template class CircuitBuilderBase<arithmetization::Ultra<barretenberg::fr>>;
49+
template class CircuitBuilderBase<arithmetization::GoblinTranslator>;
4950
template class CircuitBuilderBase<arithmetization::Turbo<barretenberg::fr>>;
5051
} // namespace proof_system

cpp/src/barretenberg/proof_system/circuit_builder/circuit_builder_base.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ template <typename Arithmetization> class CircuitBuilderBase {
6161
prev_var_index.reserve(size_hint * 3);
6262
real_variable_index.reserve(size_hint * 3);
6363
real_variable_tags.reserve(size_hint * 3);
64-
for (auto& p : selectors) {
65-
p.reserve(size_hint);
64+
// We set selectors type to bool, when we don't actually use them
65+
if constexpr (!std::is_same<typename Arithmetization::Selectors, bool>::value) {
66+
for (auto& p : selectors) {
67+
p.reserve(size_hint);
68+
}
6669
}
6770
}
6871

0 commit comments

Comments
 (0)