Skip to content

Commit

Permalink
feat: Add the prototype of goblin translator circuit builder (#577)
Browse files Browse the repository at this point in the history
Co-authored-by: codygunton <codygunton@gmail.com>
  • Loading branch information
Rumata888 and codygunton authored Jul 27, 2023
1 parent 970bb07 commit fcfabfa
Show file tree
Hide file tree
Showing 16 changed files with 1,191 additions and 39 deletions.
3 changes: 1 addition & 2 deletions cpp/src/barretenberg/common/serialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
__extension__ using uint128_t = unsigned __int128;
#endif

template <typename T>
concept IntegralOrEnum = std::integral<T> || std::is_enum_v<T>;
template <typename T> concept IntegralOrEnum = std::integral<T> || std::is_enum_v<T>;

namespace serialize {
// Forward declare derived msgpack methods
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/barretenberg/common/streams.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ template <std::integral T, typename A> inline std::ostream& operator<<(std::ostr
}

template <typename T, typename A>
requires(!std::integral<T>)
inline std::ostream& operator<<(std::ostream& os, std::vector<T, A> const& arr)
requires(!std::integral<T>) inline std::ostream& operator<<(std::ostream& os, std::vector<T, A> const& arr)
{
os << "[\n";
for (auto element : arr) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "block_constraint.hpp"
#include "acir_format.hpp"
#include "barretenberg/plonk/proof_system/types/proof.hpp"
#include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp"
#include "block_constraint.hpp"

#include <gtest/gtest.h>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "ecdsa_secp256k1.hpp"
#include "acir_format.hpp"
#include "barretenberg/crypto/ecdsa/ecdsa.hpp"
#include "barretenberg/plonk/proof_system/types/proof.hpp"
#include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp"
#include "ecdsa_secp256k1.hpp"

#include <gtest/gtest.h>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "ecdsa_secp256r1.hpp"
#include "acir_format.hpp"
#include "barretenberg/crypto/ecdsa/ecdsa.hpp"
#include "barretenberg/plonk/proof_system/types/proof.hpp"
#include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp"
#include "ecdsa_secp256r1.hpp"

#include <gtest/gtest.h>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "recursion_constraint.hpp"
#include "acir_format.hpp"
#include "barretenberg/plonk/proof_system/types/proof.hpp"
#include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp"
#include "recursion_constraint.hpp"

#include <gtest/gtest.h>
#include <vector>
Expand Down
20 changes: 11 additions & 9 deletions cpp/src/barretenberg/honk/sumcheck/relations/relation_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
#include "relation_parameters.hpp"

namespace proof_system::honk::sumcheck {
template <typename T>
concept HasSubrelationLinearlyIndependentMember = requires(T) { T::Relation::SUBRELATION_LINEARLY_INDEPENDENT; };
template <typename T> concept HasSubrelationLinearlyIndependentMember = requires(T)
{
T::Relation::SUBRELATION_LINEARLY_INDEPENDENT;
};
/**
* @brief The templates defined herein facilitate sharing the relation arithmetic between the prover and the verifier.
*
Expand All @@ -34,9 +36,9 @@ concept HasSubrelationLinearlyIndependentMember = requires(T) { T::Relation::SUB
* @return requires
*/
template <typename FF, typename AccumulatorTypes, typename T>
requires std::is_same<std::span<FF>, T>::value
inline typename std::tuple_element<0, typename AccumulatorTypes::AccumulatorViews>::type get_view(const T& input,
const size_t index)
requires std::is_same<std::span<FF>, T>::value inline
typename std::tuple_element<0, typename AccumulatorTypes::AccumulatorViews>::type
get_view(const T& input, const size_t index)
{
return input[index];
}
Expand Down Expand Up @@ -110,8 +112,8 @@ template <typename FF, template <typename> typename RelationBase> class Relation
* @tparam size_t
*/
template <size_t>
static constexpr bool is_subrelation_linearly_independent()
requires(!HasSubrelationLinearlyIndependentMember<Relation>)
static constexpr bool is_subrelation_linearly_independent() requires(
!HasSubrelationLinearlyIndependentMember<Relation>)
{
return true;
}
Expand All @@ -122,8 +124,8 @@ template <typename FF, template <typename> typename RelationBase> class Relation
* @tparam size_t
*/
template <size_t subrelation_index>
static constexpr bool is_subrelation_linearly_independent()
requires(HasSubrelationLinearlyIndependentMember<Relation>)
static constexpr bool is_subrelation_linearly_independent() requires(
HasSubrelationLinearlyIndependentMember<Relation>)
{
return std::get<subrelation_index>(Relation::SUBRELATION_LINEARLY_INDEPENDENT);
}
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/barretenberg/honk/sumcheck/sumcheck_round.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,8 @@ template <typename Flavor> class SumcheckRound {
template <typename... T>
static constexpr void add_tuples(std::tuple<T...>& tuple_1, const std::tuple<T...>& tuple_2)
{
[&]<std::size_t... I>(std::index_sequence<I...>) {
((std::get<I>(tuple_1) += std::get<I>(tuple_2)), ...);
}(std::make_index_sequence<sizeof...(T)>{});
[&]<std::size_t... I>(std::index_sequence<I...>) { ((std::get<I>(tuple_1) += std::get<I>(tuple_2)), ...); }
(std::make_index_sequence<sizeof...(T)>{});
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "barretenberg/ecc/curves/bn254/bn254.hpp"
#include <array>
#include <barretenberg/common/slab_allocator.hpp>
#include <cstddef>
Expand Down Expand Up @@ -173,4 +174,10 @@ template <typename _FF> class Ultra : public Arithmetization</*NUM_WIRES =*/4, /
// ~Selectors() = default;
};
};
class GoblinTranslator : public Arithmetization</*NUM_WIRES =*/78, /*num_selectors =*/0> {
public:
// Dirty hack
using Selectors = bool;
using FF = curve::BN254::ScalarField;
};
} // namespace arithmetization
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ void CircuitBuilderBase<Arithmetization>::assert_equal(const uint32_t a_variable
template class CircuitBuilderBase<arithmetization::Standard<barretenberg::fr>>;
template class CircuitBuilderBase<arithmetization::Standard<grumpkin::fr>>;
template class CircuitBuilderBase<arithmetization::Ultra<barretenberg::fr>>;
template class CircuitBuilderBase<arithmetization::GoblinTranslator>;
template class CircuitBuilderBase<arithmetization::Turbo<barretenberg::fr>>;
} // namespace proof_system
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ template <typename Arithmetization> class CircuitBuilderBase {
prev_var_index.reserve(size_hint * 3);
real_variable_index.reserve(size_hint * 3);
real_variable_tags.reserve(size_hint * 3);
for (auto& p : selectors) {
p.reserve(size_hint);
// We set selectors type to bool, when we don't actually use them
if constexpr (!std::is_same<typename Arithmetization::Selectors, bool>::value) {
for (auto& p : selectors) {
p.reserve(size_hint);
}
}
}

Expand Down
Loading

0 comments on commit fcfabfa

Please sign in to comment.