Skip to content

Commit

Permalink
Merge branch 'master' into 116-fix-algebra_fields_plonk_non_native_mu…
Browse files Browse the repository at this point in the history
…ltiplication
  • Loading branch information
nemothenoone authored Mar 31, 2023
2 parents c025b88 + 856c172 commit 909e58e
Show file tree
Hide file tree
Showing 26 changed files with 1,148 additions and 919 deletions.
26 changes: 14 additions & 12 deletions include/nil/blueprint/blueprint/r1cs/circuit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

#include <nil/crypto3/zk/snark/arithmetization/constraint_satisfaction_problems/r1cs.hpp>

#include <nil/crypto3/zk/blueprint/detail/r1cs/blueprint_variable.hpp>
#include <nil/crypto3/zk/blueprint/detail/r1cs/blueprint_linear_combination.hpp>
#include <nil/blueprint/blueprint/r1cs/detail/r1cs/blueprint_variable.hpp>
#include <nil/blueprint/blueprint/r1cs/detail/r1cs/blueprint_linear_combination.hpp>

namespace nil {
namespace crypto3 {
Expand All @@ -47,17 +47,17 @@ namespace nil {

template<typename BlueprintFieldType>
class blueprint<crypto3::zk::snark::r1cs_constraint_system<BlueprintFieldType>> {
typedef snark::r1cs_constraint_system<BlueprintFieldType> ArithmetizationType;
typedef zk::snark::r1cs_constraint_system<BlueprintFieldType> ArithmetizationType;

snark::r1cs_variable_assignment<BlueprintFieldType>
zk::snark::r1cs_variable_assignment<BlueprintFieldType>
values; /* values[0] will hold the value of the first
allocated variable of the blueprint, *NOT* constant 1 */
typename BlueprintFieldType::value_type constant_term;

typename math::linear_variable<BlueprintFieldType>::index_type next_free_var;
typename detail::blueprint_linear_combination<ArithmetizationType>::index_type next_free_lc;
std::vector<typename BlueprintFieldType::value_type> lc_values;
snark::r1cs_constraint_system<BlueprintFieldType> constraint_system;
zk::snark::r1cs_constraint_system<BlueprintFieldType> constraint_system;

public:
// typedef BlueprintFieldType field_type;
Expand Down Expand Up @@ -105,7 +105,7 @@ namespace nil {
}
}

void add_r1cs_constraint(const snark::r1cs_constraint<BlueprintFieldType> &constr) {
void add_r1cs_constraint(const zk::snark::r1cs_constraint<BlueprintFieldType> &constr) {
constraint_system.constraints.emplace_back(constr);
}

Expand All @@ -131,19 +131,21 @@ namespace nil {
constraint_system.auxiliary_input_size = num_variables() - primary_input_size;
}

snark::r1cs_variable_assignment<BlueprintFieldType> full_variable_assignment() const {
zk::snark::r1cs_variable_assignment<BlueprintFieldType> full_variable_assignment() const {
return values;
}

snark::r1cs_primary_input<BlueprintFieldType> primary_input() const {
return snark::r1cs_primary_input<BlueprintFieldType>(values.begin(), values.begin() + num_inputs());
zk::snark::r1cs_primary_input<BlueprintFieldType> primary_input() const {
return zk::snark::r1cs_primary_input<BlueprintFieldType>(values.begin(),
values.begin() + num_inputs());
}

snark::r1cs_auxiliary_input<BlueprintFieldType> auxiliary_input() const {
return snark::r1cs_auxiliary_input<BlueprintFieldType>(values.begin() + num_inputs(), values.end());
zk::snark::r1cs_auxiliary_input<BlueprintFieldType> auxiliary_input() const {
return zk::snark::r1cs_auxiliary_input<BlueprintFieldType>(values.begin() + num_inputs(),
values.end());
}

snark::r1cs_constraint_system<BlueprintFieldType> get_constraint_system() const {
zk::snark::r1cs_constraint_system<BlueprintFieldType> get_constraint_system() const {
return constraint_system;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ namespace nil {
class blueprint_linear_combination;

template<typename BlueprintFieldType>
class blueprint_linear_combination<crypto3::zk::snark::r1cs_constraint_system<BlueprintFieldType>> :
public snark::linear_combination<BlueprintFieldType> {
class blueprint_linear_combination<crypto3::zk::snark::r1cs_constraint_system<BlueprintFieldType>>
: public math::linear_combination<BlueprintFieldType> {

typedef snark::r1cs_constraint_system<BlueprintFieldType> ArithmetizationType;
typedef zk::snark::r1cs_constraint_system<BlueprintFieldType> ArithmetizationType;
typedef BlueprintFieldType field_type;
typedef typename field_type::value_type field_value_type;

Expand Down Expand Up @@ -121,10 +121,12 @@ namespace nil {
class blueprint_linear_combination_vector;

template<typename BlueprintFieldType>
class blueprint_linear_combination_vector<crypto3::zk::snark::r1cs_constraint_system<BlueprintFieldType>>
: private std::vector<blueprint_linear_combination<crypto3::zk::snark::r1cs_constraint_system<BlueprintFieldType>>> {
class blueprint_linear_combination_vector<
crypto3::zk::snark::r1cs_constraint_system<BlueprintFieldType>>
: private std::vector<blueprint_linear_combination<
crypto3::zk::snark::r1cs_constraint_system<BlueprintFieldType>>> {

typedef snark::r1cs_constraint_system<BlueprintFieldType> ArithmetizationType;
typedef zk::snark::r1cs_constraint_system<BlueprintFieldType> ArithmetizationType;
typedef typename BlueprintFieldType::value_type field_value_type;
typedef std::vector<blueprint_linear_combination<ArithmetizationType>> contents;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace nil {
// BlueprintFieldType> class blueprint_variable;

template<typename BlueprintFieldType>
class blueprint_variable<snark::r1cs_constraint_system<BlueprintFieldType>>
class blueprint_variable<zk::snark::r1cs_constraint_system<BlueprintFieldType>>
: public math::linear_variable<BlueprintFieldType> {
public:
blueprint_variable(const typename math::linear_variable<BlueprintFieldType>::index_type index = 0) :
Expand All @@ -79,7 +79,7 @@ namespace nil {
class blueprint_variable_vector<crypto3::zk::snark::r1cs_constraint_system<BlueprintFieldType>> :
private std::vector<blueprint_variable<crypto3::zk::snark::r1cs_constraint_system<BlueprintFieldType>>> {

typedef snark::r1cs_constraint_system<BlueprintFieldType> ArithmetizationType;
typedef zk::snark::r1cs_constraint_system<BlueprintFieldType> ArithmetizationType;
typedef typename BlueprintFieldType::value_type field_value_type;
typedef std::vector<blueprint_variable<ArithmetizationType>> contents;

Expand Down
Loading

0 comments on commit 909e58e

Please sign in to comment.