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: variable_base_scalar_mul blackbox func #6039

Merged
merged 32 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
eb8944f
feat: variable_base_scalar_mul blacbox func
benesjan Apr 26, 2024
ea1b654
WIP
benesjan Apr 26, 2024
e12fcce
WIP
benesjan Apr 26, 2024
08f7786
re-generating codegen/acir.cpp
benesjan Apr 26, 2024
a7a5e39
It compiles!
benesjan Apr 26, 2024
e3183a0
cargo fmt
benesjan Apr 26, 2024
a1aadbc
test: variable_base_scalar_mul_circuit
benesjan Apr 26, 2024
e57e663
added missing initializers
benesjan Apr 26, 2024
fe04f76
test: variable_base_matches_fixed_base_for_generator_on_input
benesjan Apr 26, 2024
e7d1aeb
making fixed_base_scalar_mul call variable_base_scalar_mul
benesjan Apr 26, 2024
0049cac
better naming
benesjan Apr 26, 2024
e7746c1
cleanup
benesjan Apr 26, 2024
fae4540
exposing new functionality in grumpkin_scalar_mul.nr
benesjan Apr 26, 2024
6ea6718
Apply suggestions from code review
benesjan Apr 26, 2024
0d09ea1
nuking stale TODOs
benesjan Apr 26, 2024
44164b2
invalid point test + fixes
benesjan Apr 26, 2024
2a3070b
test fix
benesjan Apr 29, 2024
91020e7
fix
benesjan Apr 29, 2024
11a549b
Apply suggestions from code review
benesjan Apr 29, 2024
b60575e
updated issue
benesjan Apr 29, 2024
98cfd05
variable_base_scalar_mul integration test
benesjan Apr 29, 2024
ab81133
docs
benesjan Apr 29, 2024
22bac72
comment
benesjan Apr 29, 2024
b10ca03
more tests
benesjan Apr 29, 2024
d2dd0c8
Update noir/noir-repo/acvm-repo/brillig_vm/src/black_box.rs
benesjan Apr 29, 2024
1cbdb3a
Update noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ge…
benesjan Apr 29, 2024
460f9be
error message fix
benesjan Apr 29, 2024
e7edbf0
testing brillig
benesjan Apr 29, 2024
2505489
Update noir/noir-repo/test_programs/execution_success/variable_base_s…
benesjan Apr 29, 2024
969c224
un-exposing embedded_curve_add
benesjan Apr 29, 2024
587973f
acvm_js test fix
benesjan Apr 30, 2024
fdb0ff4
bumping timeout on state vars e2e
benesjan Apr 30, 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
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ void build_constraints(Builder& builder, AcirFormat const& constraint_system, bo
create_fixed_base_constraint(builder, constraint);
}

// Add variable base scalar mul constraints
for (const auto& constraint : constraint_system.variable_base_scalar_mul_constraints) {
create_variable_base_constraint(builder, constraint);
}

// Add ec add constraints
for (const auto& constraint : constraint_system.ec_add_constraints) {
create_ec_add_constraint(builder, constraint, has_valid_witness_assignments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "recursion_constraint.hpp"
#include "schnorr_verify.hpp"
#include "sha256_constraint.hpp"
#include "variable_base_scalar_mul.hpp"
#include <utility>

namespace acir_format {
Expand Down Expand Up @@ -48,6 +49,7 @@ struct AcirFormat {
std::vector<PedersenHashConstraint> pedersen_hash_constraints;
std::vector<Poseidon2Constraint> poseidon2_constraints;
std::vector<FixedBaseScalarMul> fixed_base_scalar_mul_constraints;
std::vector<VariableBaseScalarMul> variable_base_scalar_mul_constraints;
std::vector<EcAdd> ec_add_constraints;
std::vector<RecursionConstraint> recursion_constraints;
std::vector<BigIntFromLeBytes> bigint_from_le_bytes_constraints;
Expand Down Expand Up @@ -82,6 +84,7 @@ struct AcirFormat {
pedersen_hash_constraints,
poseidon2_constraints,
fixed_base_scalar_mul_constraints,
variable_base_scalar_mul_constraints,
ec_add_constraints,
recursion_constraints,
poly_triple_constraints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ TEST_F(AcirFormatTests, TestASingleConstraintNoPubInputs)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -164,6 +165,7 @@ TEST_F(AcirFormatTests, TestLogicGateFromNoirCircuit)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -232,6 +234,7 @@ TEST_F(AcirFormatTests, TestSchnorrVerifyPass)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -327,6 +330,7 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -441,6 +445,7 @@ TEST_F(AcirFormatTests, TestVarKeccak)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -488,6 +493,7 @@ TEST_F(AcirFormatTests, TestKeccakPermutation)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,15 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, Aci
.pub_key_x = arg.outputs[0].value,
.pub_key_y = arg.outputs[1].value,
});
} else if constexpr (std::is_same_v<T, Program::BlackBoxFuncCall::VariableBaseScalarMul>) {
af.variable_base_scalar_mul_constraints.push_back(VariableBaseScalarMul{
.point_x = arg.point_x.witness.value,
.point_y = arg.point_y.witness.value,
.scalar_low = arg.scalar_low.witness.value,
.scalar_high = arg.scalar_high.witness.value,
.out_point_x = arg.outputs[0].value,
.out_point_y = arg.outputs[1].value,
});
} else if constexpr (std::is_same_v<T, Program::BlackBoxFuncCall::EmbeddedCurveAdd>) {
af.ec_add_constraints.push_back(EcAdd{
.input1_x = arg.input1_x.witness.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ TEST_F(BigIntTests, TestBigIntConstraintMultiple)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -253,6 +254,7 @@ TEST_F(BigIntTests, TestBigIntConstraintSimple)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = { from_le_bytes_constraint_bigint1 },
Expand Down Expand Up @@ -306,6 +308,7 @@ TEST_F(BigIntTests, TestBigIntConstraintReuse)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -363,6 +366,7 @@ TEST_F(BigIntTests, TestBigIntConstraintReuse2)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -441,6 +445,7 @@ TEST_F(BigIntTests, TestBigIntDIV)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = { from_le_bytes_constraint_bigint1, from_le_bytes_constraint_bigint2 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ TEST_F(UltraPlonkRAM, TestBlockConstraint)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ TEST_F(EcOperations, TestECOperations)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = { ec_add_constraint },
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintSucceed)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -156,6 +157,7 @@ TEST_F(ECDSASecp256k1, TestECDSACompilesForVerifier)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -200,6 +202,7 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintFail)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ TEST(ECDSASecp256r1, test_hardcoded)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -192,6 +193,7 @@ TEST(ECDSASecp256r1, TestECDSAConstraintSucceed)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -241,6 +243,7 @@ TEST(ECDSASecp256r1, TestECDSACompilesForVerifier)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -285,6 +288,7 @@ TEST(ECDSASecp256r1, TestECDSAConstraintFail)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ TEST_F(Poseidon2Tests, TestPoseidon2Permutation)
.pedersen_hash_constraints = {},
.poseidon2_constraints = { poseidon2_constraint },
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Builder create_inner_circuit()
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = {},
.bigint_from_le_bytes_constraints = {},
Expand Down Expand Up @@ -256,6 +257,7 @@ Builder create_outer_circuit(std::vector<Builder>& inner_circuits)
.pedersen_hash_constraints = {},
.poseidon2_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.variable_base_scalar_mul_constraints = {},
.ec_add_constraints = {},
.recursion_constraints = recursion_constraints,
.bigint_from_le_bytes_constraints = {},
Expand Down
Loading
Loading