Skip to content

Commit

Permalink
chore!: remove pedersen commitment (#9107)
Browse files Browse the repository at this point in the history
This PR removes the pedersen hash opcode as it's not currently possible
to emit these from noir code.
  • Loading branch information
TomAFrench authored Oct 18, 2024
1 parent 134bef8 commit 1823bde
Show file tree
Hide file tree
Showing 40 changed files with 17 additions and 620 deletions.
25 changes: 0 additions & 25 deletions avm-transpiler/src/transpile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,31 +1125,6 @@ fn handle_black_box_function(avm_instrs: &mut Vec<AvmInstruction>, operation: &B
..Default::default()
});
}
// Temporary while we dont have efficient noir implementations (again)
BlackBoxOp::PedersenCommitment { inputs, domain_separator, output } => {
let input_offset = inputs.pointer.to_usize();
let input_size_offset = inputs.size.to_usize();
let index_offset = domain_separator.to_usize();
let output_offset = output.pointer.to_usize();
avm_instrs.push(AvmInstruction {
opcode: AvmOpcode::PEDERSENCOMMITMENT,
indirect: Some(
AddressingModeBuilder::default()
.indirect_operand(&inputs.pointer)
.indirect_operand(&output.pointer)
.direct_operand(&inputs.size)
.direct_operand(domain_separator)
.build(),
),
operands: vec![
AvmOperand::U32 { value: input_offset as u32 },
AvmOperand::U32 { value: output_offset as u32 },
AvmOperand::U32 { value: input_size_offset as u32 },
AvmOperand::U32 { value: index_offset as u32 },
],
..Default::default()
});
}
_ => panic!("Transpiler doesn't know how to process {:?}", operation),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,6 @@ void build_constraints(Builder& builder,
constraint_system.original_opcode_indices.keccak_permutations[i]);
}

// Add pedersen constraints
for (size_t i = 0; i < constraint_system.pedersen_constraints.size(); ++i) {
const auto& constraint = constraint_system.pedersen_constraints.at(i);
create_pedersen_constraint(builder, constraint);
gate_counter.track_diff(constraint_system.gates_per_opcode,
constraint_system.original_opcode_indices.pedersen_constraints.at(i));
}

for (size_t i = 0; i < constraint_system.poseidon2_constraints.size(); ++i) {
const auto& constraint = constraint_system.poseidon2_constraints.at(i);
create_poseidon2_permutations(builder, constraint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "keccak_constraint.hpp"
#include "logic_constraint.hpp"
#include "multi_scalar_mul.hpp"
#include "pedersen.hpp"
#include "poseidon2_constraint.hpp"
#include "range_constraint.hpp"
#include "recursion_constraint.hpp"
Expand Down Expand Up @@ -48,7 +47,6 @@ struct AcirFormatOriginalOpcodeIndices {
std::vector<size_t> blake2s_constraints;
std::vector<size_t> blake3_constraints;
std::vector<size_t> keccak_permutations;
std::vector<size_t> pedersen_constraints;
std::vector<size_t> poseidon2_constraints;
std::vector<size_t> multi_scalar_mul_constraints;
std::vector<size_t> ec_add_constraints;
Expand Down Expand Up @@ -94,7 +92,6 @@ struct AcirFormat {
std::vector<Blake2sConstraint> blake2s_constraints;
std::vector<Blake3Constraint> blake3_constraints;
std::vector<Keccakf1600> keccak_permutations;
std::vector<PedersenConstraint> pedersen_constraints;
std::vector<Poseidon2Constraint> poseidon2_constraints;
std::vector<MultiScalarMul> multi_scalar_mul_constraints;
std::vector<EcAdd> ec_add_constraints;
Expand Down Expand Up @@ -144,7 +141,6 @@ struct AcirFormat {
blake2s_constraints,
blake3_constraints,
keccak_permutations,
pedersen_constraints,
poseidon2_constraints,
multi_scalar_mul_constraints,
ec_add_constraints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ TEST_F(AcirFormatTests, TestASingleConstraintNoPubInputs)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -174,7 +173,6 @@ TEST_F(AcirFormatTests, TestLogicGateFromNoirCircuit)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -255,7 +253,6 @@ TEST_F(AcirFormatTests, TestSchnorrVerifyPass)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -362,7 +359,6 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -421,6 +417,7 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange)
auto verifier = composer.create_ultra_with_keccak_verifier(builder);
EXPECT_EQ(verifier.verify_proof(proof), true);
}

TEST_F(AcirFormatTests, TestKeccakPermutation)
{
Keccakf1600
Expand Down Expand Up @@ -471,7 +468,6 @@ TEST_F(AcirFormatTests, TestKeccakPermutation)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = { keccak_permutation },
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -546,7 +542,6 @@ TEST_F(AcirFormatTests, TestCollectsGateCounts)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -673,7 +668,6 @@ TEST_F(AcirFormatTests, TestBigAdd)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ acir_format::AcirFormatOriginalOpcodeIndices create_empty_original_opcode_indice
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -64,9 +63,6 @@ void mock_opcode_indices(acir_format::AcirFormat& constraint_system)
for (size_t i = 0; i < constraint_system.keccak_permutations.size(); i++) {
constraint_system.original_opcode_indices.keccak_permutations.push_back(current_opcode++);
}
for (size_t i = 0; i < constraint_system.pedersen_constraints.size(); i++) {
constraint_system.original_opcode_indices.pedersen_constraints.push_back(current_opcode++);
}
for (size_t i = 0; i < constraint_system.poseidon2_constraints.size(); i++) {
constraint_system.original_opcode_indices.poseidon2_constraints.push_back(current_opcode++);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,16 +572,6 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg,
});
af.original_opcode_indices.schnorr_constraints.push_back(opcode_index);
af.constrained_witness.insert(af.schnorr_constraints.back().result);
} else if constexpr (std::is_same_v<T, Program::BlackBoxFuncCall::PedersenCommitment>) {
af.pedersen_constraints.push_back(PedersenConstraint{
.scalars = map(arg.inputs, [](auto& e) { return get_witness_from_function_input(e); }),
.hash_index = arg.domain_separator,
.result_x = arg.outputs[0].value,
.result_y = arg.outputs[1].value,
});
af.constrained_witness.insert(af.pedersen_constraints.back().result_x);
af.constrained_witness.insert(af.pedersen_constraints.back().result_y);
af.original_opcode_indices.pedersen_constraints.push_back(opcode_index);
} else if constexpr (std::is_same_v<T, Program::BlackBoxFuncCall::EcdsaSecp256k1>) {
af.ecdsa_k1_constraints.push_back(EcdsaSecp256k1Constraint{
.hashed_message =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ TEST_F(BigIntTests, TestBigIntConstraintMultiple)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -259,7 +258,6 @@ TEST_F(BigIntTests, TestBigIntConstraintSimple)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -317,7 +315,6 @@ TEST_F(BigIntTests, TestBigIntConstraintReuse)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -380,7 +377,6 @@ TEST_F(BigIntTests, TestBigIntConstraintReuse2)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -464,7 +460,6 @@ TEST_F(BigIntTests, TestBigIntDIV)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ TEST_F(UltraPlonkRAM, TestBlockConstraint)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -205,7 +204,6 @@ TEST_F(MegaHonk, Databus)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -312,7 +310,6 @@ TEST_F(MegaHonk, DatabusReturn)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ TEST_F(EcOperations, TestECOperations)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = { ec_add_constraint },
Expand Down Expand Up @@ -212,7 +211,6 @@ TEST_F(EcOperations, TestECMultiScalarMul)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = { msm_constrain },
.ec_add_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintSucceed)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -162,7 +161,6 @@ TEST_F(ECDSASecp256k1, TestECDSACompilesForVerifier)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -212,7 +210,6 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintFail)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ TEST(ECDSASecp256r1, test_hardcoded)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -198,7 +197,6 @@ TEST(ECDSASecp256r1, TestECDSAConstraintSucceed)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -253,7 +251,6 @@ TEST(ECDSASecp256r1, TestECDSACompilesForVerifier)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down Expand Up @@ -304,7 +301,6 @@ TEST(ECDSASecp256r1, TestECDSAConstraintFail)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class AcirHonkRecursionConstraint : public ::testing::Test {
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = {},
.ec_add_constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ TEST_F(MSMTests, TestMSM)
.blake2s_constraints = {},
.blake3_constraints = {},
.keccak_permutations = {},
.pedersen_constraints = {},
.poseidon2_constraints = {},
.multi_scalar_mul_constraints = { msm_constrain },
.ec_add_constraints = {},
Expand Down
33 changes: 0 additions & 33 deletions barretenberg/cpp/src/barretenberg/dsl/acir_format/pedersen.cpp

This file was deleted.

Loading

0 comments on commit 1823bde

Please sign in to comment.