diff --git a/avm-transpiler/src/transpile.rs b/avm-transpiler/src/transpile.rs index d3244f6363d..e441f2cf8ae 100644 --- a/avm-transpiler/src/transpile.rs +++ b/avm-transpiler/src/transpile.rs @@ -989,32 +989,6 @@ fn handle_black_box_function(avm_instrs: &mut Vec, operation: &B ..Default::default() }); } - BlackBoxOp::PedersenHash { inputs, domain_separator, output } => { - let message_offset = inputs.pointer.to_usize(); - let message_size_offset = inputs.size.to_usize(); - - let index_offset = domain_separator.to_usize(); - let dest_offset = output.to_usize(); - - avm_instrs.push(AvmInstruction { - opcode: AvmOpcode::PEDERSEN, - indirect: Some( - AddressingModeBuilder::default() - .direct_operand(domain_separator) - .direct_operand(output) - .indirect_operand(&inputs.pointer) - .direct_operand(&inputs.size) - .build(), - ), - operands: vec![ - AvmOperand::U32 { value: index_offset as u32 }, - AvmOperand::U32 { value: dest_offset as u32 }, - AvmOperand::U32 { value: message_offset as u32 }, - AvmOperand::U32 { value: message_size_offset as u32 }, - ], - ..Default::default() - }); - } BlackBoxOp::Poseidon2Permutation { message, output, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp index 3faba5e923d..eebb644e390 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp @@ -164,13 +164,6 @@ void build_constraints(Builder& builder, constraint_system.original_opcode_indices.pedersen_constraints.at(i)); } - for (size_t i = 0; i < constraint_system.pedersen_hash_constraints.size(); ++i) { - const auto& constraint = constraint_system.pedersen_hash_constraints.at(i); - create_pedersen_hash_constraint(builder, constraint); - gate_counter.track_diff(constraint_system.gates_per_opcode, - constraint_system.original_opcode_indices.pedersen_hash_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); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp index c21a91609f2..29046a8d1ab 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp @@ -49,7 +49,6 @@ struct AcirFormatOriginalOpcodeIndices { std::vector blake3_constraints; std::vector keccak_permutations; std::vector pedersen_constraints; - std::vector pedersen_hash_constraints; std::vector poseidon2_constraints; std::vector multi_scalar_mul_constraints; std::vector ec_add_constraints; @@ -96,7 +95,6 @@ struct AcirFormat { std::vector blake3_constraints; std::vector keccak_permutations; std::vector pedersen_constraints; - std::vector pedersen_hash_constraints; std::vector poseidon2_constraints; std::vector multi_scalar_mul_constraints; std::vector ec_add_constraints; @@ -147,7 +145,6 @@ struct AcirFormat { blake3_constraints, keccak_permutations, pedersen_constraints, - pedersen_hash_constraints, poseidon2_constraints, multi_scalar_mul_constraints, ec_add_constraints, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp index f419b557cca..0c2855652c8 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp @@ -53,7 +53,6 @@ TEST_F(AcirFormatTests, TestASingleConstraintNoPubInputs) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -176,7 +175,6 @@ TEST_F(AcirFormatTests, TestLogicGateFromNoirCircuit) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -258,7 +256,6 @@ TEST_F(AcirFormatTests, TestSchnorrVerifyPass) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -366,7 +363,6 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -425,7 +421,6 @@ 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 @@ -477,7 +472,6 @@ TEST_F(AcirFormatTests, TestKeccakPermutation) .blake3_constraints = {}, .keccak_permutations = { keccak_permutation }, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -553,7 +547,6 @@ TEST_F(AcirFormatTests, TestCollectsGateCounts) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -681,7 +674,6 @@ TEST_F(AcirFormatTests, TestBigAdd) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format_mocks.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format_mocks.cpp index fdfe7396720..0e1471506d7 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format_mocks.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format_mocks.cpp @@ -14,7 +14,6 @@ acir_format::AcirFormatOriginalOpcodeIndices create_empty_original_opcode_indice .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -68,9 +67,6 @@ void mock_opcode_indices(acir_format::AcirFormat& constraint_system) 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.pedersen_hash_constraints.size(); i++) { - constraint_system.original_opcode_indices.pedersen_hash_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++); } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp index dff52b89672..cb6ff105e1c 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp @@ -582,14 +582,6 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, 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) { - af.pedersen_hash_constraints.push_back(PedersenHashConstraint{ - .scalars = map(arg.inputs, [](auto& e) { return get_witness_from_function_input(e); }), - .hash_index = arg.domain_separator, - .result = arg.output.value, - }); - af.constrained_witness.insert(af.pedersen_hash_constraints.back().result); - af.original_opcode_indices.pedersen_hash_constraints.push_back(opcode_index); } else if constexpr (std::is_same_v) { af.ecdsa_k1_constraints.push_back(EcdsaSecp256k1Constraint{ .hashed_message = diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp index f7ef70c71fb..029af4828bf 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp @@ -186,7 +186,6 @@ TEST_F(BigIntTests, TestBigIntConstraintMultiple) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -261,7 +260,6 @@ TEST_F(BigIntTests, TestBigIntConstraintSimple) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -320,7 +318,6 @@ TEST_F(BigIntTests, TestBigIntConstraintReuse) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -384,7 +381,6 @@ TEST_F(BigIntTests, TestBigIntConstraintReuse2) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -469,7 +465,6 @@ TEST_F(BigIntTests, TestBigIntDIV) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp index 2bcd9cf0f92..e9688e613b9 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp @@ -154,7 +154,6 @@ TEST_F(UltraPlonkRAM, TestBlockConstraint) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -207,7 +206,6 @@ TEST_F(MegaHonk, Databus) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -315,7 +313,6 @@ TEST_F(MegaHonk, DatabusReturn) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ec_operations.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ec_operations.test.cpp index 9b5e9eacf53..da3797330e4 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ec_operations.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ec_operations.test.cpp @@ -76,7 +76,6 @@ TEST_F(EcOperations, TestECOperations) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = { ec_add_constraint }, @@ -214,7 +213,6 @@ TEST_F(EcOperations, TestECMultiScalarMul) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = { msm_constrain }, .ec_add_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp index de64682de76..d035aae8cec 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp @@ -108,7 +108,6 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintSucceed) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -164,7 +163,6 @@ TEST_F(ECDSASecp256k1, TestECDSACompilesForVerifier) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -215,7 +213,6 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintFail) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp index 0ecb9fd545d..d86dab894e2 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp @@ -142,7 +142,6 @@ TEST(ECDSASecp256r1, test_hardcoded) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -200,7 +199,6 @@ TEST(ECDSASecp256r1, TestECDSAConstraintSucceed) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -256,7 +254,6 @@ TEST(ECDSASecp256r1, TestECDSACompilesForVerifier) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -308,7 +305,6 @@ TEST(ECDSASecp256r1, TestECDSAConstraintFail) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/honk_recursion_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/honk_recursion_constraint.test.cpp index 709326e935f..467c1b4c4c4 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/honk_recursion_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/honk_recursion_constraint.test.cpp @@ -104,7 +104,6 @@ class AcirHonkRecursionConstraint : public ::testing::Test { .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/multi_scalar_mul.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/multi_scalar_mul.test.cpp index 52e319aa4cf..6326d7a7d3a 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/multi_scalar_mul.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/multi_scalar_mul.test.cpp @@ -76,7 +76,6 @@ TEST_F(MSMTests, TestMSM) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = { msm_constrain }, .ec_add_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/pedersen.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/pedersen.cpp index becacc2fe15..183ef5e6951 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/pedersen.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/pedersen.cpp @@ -26,30 +26,8 @@ template void create_pedersen_constraint(Builder& builder, co builder.assert_equal(point.y.witness_index, input.result_y); } -template void create_pedersen_hash_constraint(Builder& builder, const PedersenHashConstraint& input) -{ - using field_ct = stdlib::field_t; - - std::vector scalars; - - for (const auto& scalar : input.scalars) { - // convert input indices to field_ct - field_ct scalar_as_field = field_ct::from_witness_index(&builder, scalar); - scalars.push_back(scalar_as_field); - } - - auto result = stdlib::pedersen_hash::hash(scalars, input.hash_index); - - builder.assert_equal(result.witness_index, input.result); -} - template void create_pedersen_constraint(UltraCircuitBuilder& builder, const PedersenConstraint& input); -template void create_pedersen_hash_constraint(UltraCircuitBuilder& builder, - const PedersenHashConstraint& input); template void create_pedersen_constraint(MegaCircuitBuilder& builder, const PedersenConstraint& input); -template void create_pedersen_hash_constraint(MegaCircuitBuilder& builder, - const PedersenHashConstraint& input); - } // namespace acir_format diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/pedersen.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/pedersen.hpp index 5737da41e37..dcef6bfa1d8 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/pedersen.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/pedersen.hpp @@ -16,17 +16,7 @@ struct PedersenConstraint { friend bool operator==(PedersenConstraint const& lhs, PedersenConstraint const& rhs) = default; }; -struct PedersenHashConstraint { - std::vector scalars; - uint32_t hash_index; - - uint32_t result; - - friend bool operator==(PedersenHashConstraint const& lhs, PedersenHashConstraint const& rhs) = default; -}; - template void create_pedersen_constraint(Builder& builder, const PedersenConstraint& input); -template void create_pedersen_hash_constraint(Builder& builder, const PedersenHashConstraint& input); template inline void read(B& buf, PedersenConstraint& constraint) { diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/poseidon2_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/poseidon2_constraint.test.cpp index 46337fa0122..14a05a2f358 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/poseidon2_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/poseidon2_constraint.test.cpp @@ -56,7 +56,6 @@ TEST_F(Poseidon2Tests, TestPoseidon2Permutation) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = { poseidon2_constraint }, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp index 2cdd1fea2ce..3446cfd5021 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp @@ -101,7 +101,6 @@ Builder create_inner_circuit() .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, @@ -264,7 +263,6 @@ Builder create_outer_circuit(std::vector& inner_circuits) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp index 973303b385a..f4bacef6c0c 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp @@ -340,16 +340,6 @@ struct BlackBoxOp { static PedersenCommitment bincodeDeserialize(std::vector); }; - struct PedersenHash { - Program::HeapVector inputs; - Program::MemoryAddress domain_separator; - Program::MemoryAddress output; - - friend bool operator==(const PedersenHash&, const PedersenHash&); - std::vector bincodeSerialize() const; - static PedersenHash bincodeDeserialize(std::vector); - }; - struct MultiScalarMul { Program::HeapVector points; Program::HeapVector scalars; @@ -472,7 +462,6 @@ struct BlackBoxOp { EcdsaSecp256r1, SchnorrVerify, PedersenCommitment, - PedersenHash, MultiScalarMul, EmbeddedCurveAdd, BigIntAdd, @@ -900,16 +889,6 @@ struct BlackBoxFuncCall { static PedersenCommitment bincodeDeserialize(std::vector); }; - struct PedersenHash { - std::vector inputs; - uint32_t domain_separator; - Program::Witness output; - - friend bool operator==(const PedersenHash&, const PedersenHash&); - std::vector bincodeSerialize() const; - static PedersenHash bincodeDeserialize(std::vector); - }; - struct EcdsaSecp256k1 { std::array public_key_x; std::array public_key_y; @@ -1062,7 +1041,6 @@ struct BlackBoxFuncCall { Blake3, SchnorrVerify, PedersenCommitment, - PedersenHash, EcdsaSecp256k1, EcdsaSecp256r1, MultiScalarMul, @@ -3121,63 +3099,6 @@ Program::BlackBoxFuncCall::PedersenCommitment serde::Deserializable< namespace Program { -inline bool operator==(const BlackBoxFuncCall::PedersenHash& lhs, const BlackBoxFuncCall::PedersenHash& rhs) -{ - if (!(lhs.inputs == rhs.inputs)) { - return false; - } - if (!(lhs.domain_separator == rhs.domain_separator)) { - return false; - } - if (!(lhs.output == rhs.output)) { - return false; - } - return true; -} - -inline std::vector BlackBoxFuncCall::PedersenHash::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxFuncCall::PedersenHash BlackBoxFuncCall::PedersenHash::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Program - -template <> -template -void serde::Serializable::serialize( - const Program::BlackBoxFuncCall::PedersenHash& obj, Serializer& serializer) -{ - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.domain_separator, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Program::BlackBoxFuncCall::PedersenHash serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Program::BlackBoxFuncCall::PedersenHash obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.domain_separator = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Program { - inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256k1& lhs, const BlackBoxFuncCall::EcdsaSecp256k1& rhs) { if (!(lhs.public_key_x == rhs.public_key_x)) { @@ -4528,63 +4449,6 @@ Program::BlackBoxOp::PedersenCommitment serde::Deserializable BlackBoxOp::PedersenHash::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::PedersenHash BlackBoxOp::PedersenHash::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Program - -template <> -template -void serde::Serializable::serialize(const Program::BlackBoxOp::PedersenHash& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.domain_separator, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Program::BlackBoxOp::PedersenHash serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Program::BlackBoxOp::PedersenHash obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.domain_separator = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Program { - inline bool operator==(const BlackBoxOp::MultiScalarMul& lhs, const BlackBoxOp::MultiScalarMul& rhs) { if (!(lhs.points == rhs.points)) { diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/sha256_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/sha256_constraint.test.cpp index 7a70d92885e..e85f5927449 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/sha256_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/sha256_constraint.test.cpp @@ -51,7 +51,6 @@ TEST_F(Sha256Tests, TestSha256Compression) .blake3_constraints = {}, .keccak_permutations = {}, .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, .poseidon2_constraints = {}, .multi_scalar_mul_constraints = {}, .ec_add_constraints = {}, diff --git a/noir/noir-repo/acvm-repo/acir/codegen/acir.cpp b/noir/noir-repo/acvm-repo/acir/codegen/acir.cpp index 31a1d04880e..6468f8e1732 100644 --- a/noir/noir-repo/acvm-repo/acir/codegen/acir.cpp +++ b/noir/noir-repo/acvm-repo/acir/codegen/acir.cpp @@ -340,16 +340,6 @@ namespace Program { static PedersenCommitment bincodeDeserialize(std::vector); }; - struct PedersenHash { - Program::HeapVector inputs; - Program::MemoryAddress domain_separator; - Program::MemoryAddress output; - - friend bool operator==(const PedersenHash&, const PedersenHash&); - std::vector bincodeSerialize() const; - static PedersenHash bincodeDeserialize(std::vector); - }; - struct MultiScalarMul { Program::HeapVector points; Program::HeapVector scalars; @@ -464,7 +454,7 @@ namespace Program { static ToRadix bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; friend bool operator==(const BlackBoxOp&, const BlackBoxOp&); std::vector bincodeSerialize() const; @@ -860,16 +850,6 @@ namespace Program { static PedersenCommitment bincodeDeserialize(std::vector); }; - struct PedersenHash { - std::vector inputs; - uint32_t domain_separator; - Program::Witness output; - - friend bool operator==(const PedersenHash&, const PedersenHash&); - std::vector bincodeSerialize() const; - static PedersenHash bincodeDeserialize(std::vector); - }; - struct EcdsaSecp256k1 { std::array public_key_x; std::array public_key_y; @@ -1014,7 +994,7 @@ namespace Program { static Sha256Compression bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); std::vector bincodeSerialize() const; @@ -2780,50 +2760,6 @@ Program::BlackBoxFuncCall::PedersenCommitment serde::Deserializable BlackBoxFuncCall::PedersenHash::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxFuncCall::PedersenHash BlackBoxFuncCall::PedersenHash::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Program - -template <> -template -void serde::Serializable::serialize(const Program::BlackBoxFuncCall::PedersenHash &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.domain_separator, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Program::BlackBoxFuncCall::PedersenHash serde::Deserializable::deserialize(Deserializer &deserializer) { - Program::BlackBoxFuncCall::PedersenHash obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.domain_separator = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - namespace Program { inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256k1 &lhs, const BlackBoxFuncCall::EcdsaSecp256k1 &rhs) { @@ -3858,50 +3794,6 @@ Program::BlackBoxOp::PedersenCommitment serde::Deserializable BlackBoxOp::PedersenHash::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxOp::PedersenHash BlackBoxOp::PedersenHash::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Program - -template <> -template -void serde::Serializable::serialize(const Program::BlackBoxOp::PedersenHash &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.domain_separator, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Program::BlackBoxOp::PedersenHash serde::Deserializable::deserialize(Deserializer &deserializer) { - Program::BlackBoxOp::PedersenHash obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.domain_separator = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - namespace Program { inline bool operator==(const BlackBoxOp::MultiScalarMul &lhs, const BlackBoxOp::MultiScalarMul &rhs) { diff --git a/noir/noir-repo/acvm-repo/acir/src/circuit/black_box_functions.rs b/noir/noir-repo/acvm-repo/acir/src/circuit/black_box_functions.rs index b7dd41c64db..4bdce9a2d21 100644 --- a/noir/noir-repo/acvm-repo/acir/src/circuit/black_box_functions.rs +++ b/noir/noir-repo/acvm-repo/acir/src/circuit/black_box_functions.rs @@ -78,8 +78,6 @@ pub enum BlackBoxFunc { SchnorrVerify, /// Will be deprecated PedersenCommitment, - /// Will be deprecated - PedersenHash, /// Verifies a ECDSA signature over the secp256k1 curve. /// - inputs: /// - x coordinate of public key as 32 bytes @@ -223,7 +221,6 @@ impl BlackBoxFunc { BlackBoxFunc::Poseidon2Permutation => "poseidon2_permutation", BlackBoxFunc::Sha256Compression => "sha256_compression", BlackBoxFunc::PedersenCommitment => "pedersen_commitment", - BlackBoxFunc::PedersenHash => "pedersen_hash", } } @@ -251,7 +248,6 @@ impl BlackBoxFunc { "poseidon2_permutation" => Some(BlackBoxFunc::Poseidon2Permutation), "sha256_compression" => Some(BlackBoxFunc::Sha256Compression), "pedersen_commitment" => Some(BlackBoxFunc::PedersenCommitment), - "pedersen_hash" => Some(BlackBoxFunc::PedersenHash), _ => None, } } diff --git a/noir/noir-repo/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs b/noir/noir-repo/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs index d5902c4d85c..4a8a50d4bc5 100644 --- a/noir/noir-repo/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs +++ b/noir/noir-repo/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs @@ -123,12 +123,6 @@ pub enum BlackBoxFuncCall { domain_separator: u32, outputs: (Witness, Witness), }, - /// Will be deprecated - PedersenHash { - inputs: Vec>, - domain_separator: u32, - output: Witness, - }, EcdsaSecp256k1 { public_key_x: Box<[FunctionInput; 32]>, public_key_y: Box<[FunctionInput; 32]>, @@ -260,7 +254,6 @@ impl BlackBoxFuncCall { BlackBoxFuncCall::Poseidon2Permutation { .. } => BlackBoxFunc::Poseidon2Permutation, BlackBoxFuncCall::Sha256Compression { .. } => BlackBoxFunc::Sha256Compression, BlackBoxFuncCall::PedersenCommitment { .. } => BlackBoxFunc::PedersenCommitment, - BlackBoxFuncCall::PedersenHash { .. } => BlackBoxFunc::PedersenHash, } } @@ -275,7 +268,6 @@ impl BlackBoxFuncCall { | BlackBoxFuncCall::Blake3 { inputs, .. } | BlackBoxFuncCall::BigIntFromLeBytes { inputs, .. } | BlackBoxFuncCall::PedersenCommitment { inputs, .. } - | BlackBoxFuncCall::PedersenHash { inputs, .. } | BlackBoxFuncCall::Poseidon2Permutation { inputs, .. } => inputs.to_vec(), BlackBoxFuncCall::Keccakf1600 { inputs, .. } => inputs.to_vec(), @@ -388,7 +380,6 @@ impl BlackBoxFuncCall { | BlackBoxFuncCall::XOR { output, .. } | BlackBoxFuncCall::SchnorrVerify { output, .. } | BlackBoxFuncCall::EcdsaSecp256k1 { output, .. } - | BlackBoxFuncCall::PedersenHash { output, .. } | BlackBoxFuncCall::EcdsaSecp256r1 { output, .. } => vec![*output], BlackBoxFuncCall::PedersenCommitment { outputs, .. } => vec![outputs.0, outputs.1], BlackBoxFuncCall::MultiScalarMul { outputs, .. } @@ -463,12 +454,8 @@ fn get_outputs_string(outputs: &[Witness]) -> String { impl std::fmt::Display for BlackBoxFuncCall { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - BlackBoxFuncCall::PedersenCommitment { .. } => { - return write!(f, "BLACKBOX::Deprecated") - } - BlackBoxFuncCall::PedersenHash { .. } => return write!(f, "BLACKBOX::Deprecated"), - _ => (), + if matches!(self, BlackBoxFuncCall::PedersenCommitment { .. }) { + return write!(f, "BLACKBOX::Deprecated"); } let uppercase_name = self.name().to_uppercase(); diff --git a/noir/noir-repo/acvm-repo/acir/tests/test_program_serialization.rs b/noir/noir-repo/acvm-repo/acir/tests/test_program_serialization.rs index 599cf9212b3..278857c5a7b 100644 --- a/noir/noir-repo/acvm-repo/acir/tests/test_program_serialization.rs +++ b/noir/noir-repo/acvm-repo/acir/tests/test_program_serialization.rs @@ -91,10 +91,10 @@ fn multi_scalar_mul_circuit() { let bytes = Program::serialize_program(&program); let expected_serialization: Vec = vec![ - 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 93, 141, 11, 10, 0, 32, 8, 67, 43, 181, 15, 221, 255, - 186, 145, 210, 130, 149, 240, 112, 234, 212, 156, 78, 12, 39, 67, 71, 158, 142, 80, 29, 44, - 228, 66, 90, 168, 119, 189, 74, 115, 131, 174, 78, 115, 58, 124, 70, 254, 130, 59, 74, 253, - 68, 255, 255, 221, 39, 54, 29, 134, 27, 102, 193, 0, 0, 0, + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 93, 141, 11, 10, 0, 32, 8, 67, 43, 181, 223, 253, 207, + 27, 41, 45, 88, 9, 15, 167, 78, 205, 233, 196, 112, 50, 116, 228, 233, 8, 213, 193, 66, 46, + 164, 133, 122, 215, 171, 52, 55, 232, 234, 52, 167, 195, 103, 228, 47, 184, 163, 212, 79, + 244, 255, 223, 125, 98, 3, 85, 236, 192, 195, 193, 0, 0, 0, ]; assert_eq!(bytes, expected_serialization) diff --git a/noir/noir-repo/acvm-repo/acvm/src/pwg/blackbox/mod.rs b/noir/noir-repo/acvm-repo/acvm/src/pwg/blackbox/mod.rs index 0f23ec361d8..3600a3e30e6 100644 --- a/noir/noir-repo/acvm-repo/acvm/src/pwg/blackbox/mod.rs +++ b/noir/noir-repo/acvm-repo/acvm/src/pwg/blackbox/mod.rs @@ -27,7 +27,7 @@ use embedded_curve_ops::{embedded_curve_add, multi_scalar_mul}; // Hash functions should eventually be exposed for external consumers. use hash::{solve_generic_256_hash_opcode, solve_sha_256_permutation_opcode}; use logic::{and, xor}; -use pedersen::{pedersen, pedersen_hash}; +use pedersen::pedersen; pub(crate) use range::solve_range_opcode; use signature::{ ecdsa::{secp256k1_prehashed, secp256r1_prehashed}, @@ -123,9 +123,6 @@ pub(crate) fn solve( BlackBoxFuncCall::PedersenCommitment { inputs, domain_separator, outputs } => { pedersen(backend, initial_witness, inputs, *domain_separator, *outputs) } - BlackBoxFuncCall::PedersenHash { inputs, domain_separator, output } => { - pedersen_hash(backend, initial_witness, inputs, *domain_separator, *output) - } BlackBoxFuncCall::EcdsaSecp256k1 { public_key_x, public_key_y, diff --git a/noir/noir-repo/acvm-repo/acvm/src/pwg/blackbox/pedersen.rs b/noir/noir-repo/acvm-repo/acvm/src/pwg/blackbox/pedersen.rs index 654814bf92d..a85a8abfc9b 100644 --- a/noir/noir-repo/acvm-repo/acvm/src/pwg/blackbox/pedersen.rs +++ b/noir/noir-repo/acvm-repo/acvm/src/pwg/blackbox/pedersen.rs @@ -27,21 +27,3 @@ pub(super) fn pedersen( Ok(()) } - -pub(super) fn pedersen_hash( - backend: &impl BlackBoxFunctionSolver, - initial_witness: &mut WitnessMap, - inputs: &[FunctionInput], - domain_separator: u32, - output: Witness, -) -> Result<(), OpcodeResolutionError> { - let scalars: Result, _> = - inputs.iter().map(|input| input_to_value(initial_witness, *input, false)).collect(); - let scalars: Vec<_> = scalars?.into_iter().collect(); - - let res = backend.pedersen_hash(&scalars, domain_separator)?; - - insert_value(&output, res, initial_witness)?; - - Ok(()) -} diff --git a/noir/noir-repo/acvm-repo/acvm_js/test/shared/complex_foreign_call.ts b/noir/noir-repo/acvm-repo/acvm_js/test/shared/complex_foreign_call.ts index 3048b74e51f..8eb7b7d5059 100644 --- a/noir/noir-repo/acvm-repo/acvm_js/test/shared/complex_foreign_call.ts +++ b/noir/noir-repo/acvm-repo/acvm_js/test/shared/complex_foreign_call.ts @@ -1,7 +1,16 @@ import { WitnessMap } from '@noir-lang/acvm_js'; // See `complex_brillig_foreign_call` integration test in `acir/tests/test_program_serialization.rs`. -export const bytecode = Uint8Array.from([31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 85, 93, 10, 194, 48, 12, 78, 155, 233, 54, 240, 205, 11, 8, 122, 128, 76, 47, 176, 187, 136, 111, 138, 62, 122, 124, 45, 75, 88, 23, 139, 19, 76, 64, 63, 24, 89, 75, 242, 229, 159, 6, 24, 208, 60, 191, 192, 255, 11, 150, 145, 101, 186, 71, 152, 66, 116, 123, 150, 244, 29, 186, 96, 199, 69, 94, 49, 198, 63, 136, 17, 29, 98, 132, 172, 255, 63, 216, 111, 203, 190, 152, 214, 15, 11, 251, 83, 193, 176, 95, 75, 62, 215, 44, 27, 93, 232, 100, 20, 225, 117, 241, 38, 144, 233, 105, 149, 4, 229, 185, 183, 201, 232, 208, 42, 191, 198, 252, 36, 213, 216, 192, 103, 249, 250, 228, 185, 39, 225, 71, 23, 126, 234, 132, 191, 114, 234, 83, 173, 234, 149, 231, 146, 251, 93, 193, 56, 129, 199, 235, 229, 118, 62, 221, 177, 96, 170, 205, 19, 182, 234, 188, 43, 148, 108, 142, 67, 144, 63, 52, 239, 244, 67, 65, 127, 206, 102, 13, 227, 56, 201, 195, 246, 0, 155, 0, 46, 128, 245, 6, 0, 0]); +export const bytecode = Uint8Array.from([ + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 85, 93, 10, 194, 48, 12, 78, 155, 233, 54, 240, 205, 11, 8, 122, 128, 76, 47, + 176, 187, 136, 111, 138, 62, 122, 124, 45, 75, 88, 23, 139, 19, 76, 64, 63, 24, 89, 75, 242, 229, 159, 6, 24, 208, 60, + 191, 192, 255, 11, 150, 145, 101, 186, 71, 152, 66, 116, 123, 150, 244, 29, 186, 96, 199, 69, 94, 49, 198, 63, 136, + 17, 29, 98, 132, 172, 255, 63, 216, 111, 203, 190, 152, 214, 15, 11, 251, 83, 193, 176, 95, 75, 62, 215, 44, 27, 93, + 232, 100, 20, 225, 117, 241, 38, 144, 233, 105, 149, 4, 229, 185, 183, 201, 232, 208, 42, 191, 198, 252, 36, 213, 216, + 192, 103, 249, 250, 228, 185, 39, 225, 71, 23, 126, 234, 132, 191, 114, 234, 83, 173, 234, 149, 231, 146, 251, 93, + 193, 56, 129, 199, 235, 229, 118, 62, 221, 177, 96, 170, 205, 19, 182, 234, 188, 43, 148, 108, 142, 67, 144, 63, 52, + 239, 244, 67, 65, 127, 206, 102, 13, 227, 56, 201, 195, 246, 0, 155, 0, 46, 128, 245, 6, 0, 0, +]); export const initialWitnessMap: WitnessMap = new Map([ [1, '0x0000000000000000000000000000000000000000000000000000000000000001'], [2, '0x0000000000000000000000000000000000000000000000000000000000000002'], diff --git a/noir/noir-repo/acvm-repo/acvm_js/test/shared/foreign_call.ts b/noir/noir-repo/acvm-repo/acvm_js/test/shared/foreign_call.ts index 08123c01c2f..dc3c6f23f6f 100644 --- a/noir/noir-repo/acvm-repo/acvm_js/test/shared/foreign_call.ts +++ b/noir/noir-repo/acvm-repo/acvm_js/test/shared/foreign_call.ts @@ -1,7 +1,13 @@ import { WitnessMap } from '@noir-lang/acvm_js'; // See `simple_brillig_foreign_call` integration test in `acir/tests/test_program_serialization.rs`. -export const bytecode = Uint8Array.from([31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 79, 73, 10, 128, 48, 12, 204, 40, 46, 5, 111, 126, 36, 254, 192, 207, 120, 240, 226, 65, 196, 247, 91, 48, 129, 80, 218, 122, 48, 3, 33, 147, 9, 89, 6, 244, 98, 140, 1, 225, 157, 100, 173, 45, 84, 91, 37, 243, 63, 44, 240, 219, 197, 246, 223, 38, 37, 176, 34, 85, 156, 169, 251, 144, 233, 183, 142, 206, 67, 114, 215, 121, 63, 15, 84, 135, 222, 157, 98, 244, 194, 247, 227, 222, 206, 11, 31, 19, 165, 186, 164, 207, 153, 222, 3, 91, 101, 84, 220, 120, 2, 0, 0]); +export const bytecode = Uint8Array.from([ + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 79, 73, 10, 128, 48, 12, 204, 40, 46, 5, 111, 126, 36, 254, 192, 207, 120, + 240, 226, 65, 196, 247, 91, 48, 129, 80, 218, 122, 48, 3, 33, 147, 9, 89, 6, 244, 98, 140, 1, 225, 157, 100, 173, 45, + 84, 91, 37, 243, 63, 44, 240, 219, 197, 246, 223, 38, 37, 176, 34, 85, 156, 169, 251, 144, 233, 183, 142, 206, 67, + 114, 215, 121, 63, 15, 84, 135, 222, 157, 98, 244, 194, 247, 227, 222, 206, 11, 31, 19, 165, 186, 164, 207, 153, 222, + 3, 91, 101, 84, 220, 120, 2, 0, 0, +]); export const initialWitnessMap: WitnessMap = new Map([ [1, '0x0000000000000000000000000000000000000000000000000000000000000005'], ]); diff --git a/noir/noir-repo/acvm-repo/acvm_js/test/shared/multi_scalar_mul.ts b/noir/noir-repo/acvm-repo/acvm_js/test/shared/multi_scalar_mul.ts index f23847a75fc..69c77a7eaf1 100644 --- a/noir/noir-repo/acvm-repo/acvm_js/test/shared/multi_scalar_mul.ts +++ b/noir/noir-repo/acvm-repo/acvm_js/test/shared/multi_scalar_mul.ts @@ -1,8 +1,8 @@ // See `multi_scalar_mul_circuit` integration test in `acir/tests/test_program_serialization.rs`. export const bytecode = Uint8Array.from([ - 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 93, 141, 11, 10, 0, 32, 8, 67, 43, 181, 15, 221, 255, 186, 145, 210, 130, 149, 240, - 112, 234, 212, 156, 78, 12, 39, 67, 71, 158, 142, 80, 29, 44, 228, 66, 90, 168, 119, 189, 74, 115, 131, 174, 78, 115, - 58, 124, 70, 254, 130, 59, 74, 253, 68, 255, 255, 221, 39, 54, 29, 134, 27, 102, 193, 0, 0, 0, + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 93, 141, 11, 10, 0, 32, 8, 67, 43, 181, 223, 253, 207, 27, 41, 45, 88, 9, 15, 167, + 78, 205, 233, 196, 112, 50, 116, 228, 233, 8, 213, 193, 66, 46, 164, 133, 122, 215, 171, 52, 55, 232, 234, 52, 167, + 195, 103, 228, 47, 184, 163, 212, 79, 244, 255, 223, 125, 98, 3, 85, 236, 192, 195, 193, 0, 0, 0, ]); export const initialWitnessMap = new Map([ [1, '0x0000000000000000000000000000000000000000000000000000000000000001'], diff --git a/noir/noir-repo/acvm-repo/blackbox_solver/src/curve_specific_solver.rs b/noir/noir-repo/acvm-repo/blackbox_solver/src/curve_specific_solver.rs index f729a5033fb..e66cfe8a92a 100644 --- a/noir/noir-repo/acvm-repo/blackbox_solver/src/curve_specific_solver.rs +++ b/noir/noir-repo/acvm-repo/blackbox_solver/src/curve_specific_solver.rs @@ -19,11 +19,6 @@ pub trait BlackBoxFunctionSolver { inputs: &[F], domain_separator: u32, ) -> Result<(F, F), BlackBoxResolutionError>; - fn pedersen_hash( - &self, - inputs: &[F], - domain_separator: u32, - ) -> Result; fn multi_scalar_mul( &self, points: &[F], @@ -74,13 +69,6 @@ impl BlackBoxFunctionSolver for StubbedBlackBoxSolver { ) -> Result<(F, F), BlackBoxResolutionError> { Err(Self::fail(BlackBoxFunc::PedersenCommitment)) } - fn pedersen_hash( - &self, - _inputs: &[F], - _domain_separator: u32, - ) -> Result { - Err(Self::fail(BlackBoxFunc::PedersenHash)) - } fn multi_scalar_mul( &self, diff --git a/noir/noir-repo/acvm-repo/bn254_blackbox_solver/src/lib.rs b/noir/noir-repo/acvm-repo/bn254_blackbox_solver/src/lib.rs index 952c4498d84..78e6c2b2d10 100644 --- a/noir/noir-repo/acvm-repo/bn254_blackbox_solver/src/lib.rs +++ b/noir/noir-repo/acvm-repo/bn254_blackbox_solver/src/lib.rs @@ -60,17 +60,6 @@ impl BlackBoxFunctionSolver for Bn254BlackBoxSolver { Ok(result) } - fn pedersen_hash( - &self, - inputs: &[FieldElement], - domain_separator: u32, - ) -> Result { - let inputs: Vec = inputs.iter().map(|input| input.into_repr()).collect(); - let result = pedersen::hash::hash_with_index(&inputs, domain_separator); - let result = FieldElement::from_repr(result); - Ok(result) - } - fn multi_scalar_mul( &self, points: &[FieldElement], diff --git a/noir/noir-repo/acvm-repo/brillig/src/black_box.rs b/noir/noir-repo/acvm-repo/brillig/src/black_box.rs index ee191a39b66..a6721461d6a 100644 --- a/noir/noir-repo/acvm-repo/brillig/src/black_box.rs +++ b/noir/noir-repo/acvm-repo/brillig/src/black_box.rs @@ -57,12 +57,6 @@ pub enum BlackBoxOp { domain_separator: MemoryAddress, output: HeapArray, }, - /// Will be deprecated - PedersenHash { - inputs: HeapVector, - domain_separator: MemoryAddress, - output: MemoryAddress, - }, /// Performs multi scalar multiplication over the embedded curve. MultiScalarMul { points: HeapVector, diff --git a/noir/noir-repo/acvm-repo/brillig_vm/src/black_box.rs b/noir/noir-repo/acvm-repo/brillig_vm/src/black_box.rs index 81fd6ee7396..88bec2eebd8 100644 --- a/noir/noir-repo/acvm-repo/brillig_vm/src/black_box.rs +++ b/noir/noir-repo/acvm-repo/brillig_vm/src/black_box.rs @@ -240,22 +240,6 @@ pub(crate) fn evaluate_black_box ); Ok(()) } - BlackBoxOp::PedersenHash { inputs, domain_separator, output } => { - let inputs: Vec = read_heap_vector(memory, inputs) - .iter() - .map(|x| *x.extract_field().unwrap()) - .collect(); - let domain_separator: u32 = - memory.read(*domain_separator).try_into().map_err(|_| { - BlackBoxResolutionError::Failed( - BlackBoxFunc::PedersenCommitment, - "Invalid separator length".to_string(), - ) - })?; - let hash = solver.pedersen_hash(&inputs, domain_separator)?; - memory.write(*output, MemoryValue::new_field(hash)); - Ok(()) - } BlackBoxOp::BigIntAdd { lhs, rhs, output } => { let lhs = memory.read(*lhs).try_into().unwrap(); let rhs = memory.read(*rhs).try_into().unwrap(); @@ -455,8 +439,7 @@ fn black_box_function_from_op(op: &BlackBoxOp) -> BlackBoxFunc { BlackBoxOp::BigIntToLeBytes { .. } => BlackBoxFunc::BigIntToLeBytes, BlackBoxOp::Poseidon2Permutation { .. } => BlackBoxFunc::Poseidon2Permutation, BlackBoxOp::Sha256Compression { .. } => BlackBoxFunc::Sha256Compression, - BlackBoxOp::ToRadix { .. } => unreachable!("ToRadix is not an ACIR BlackBoxFunc"), BlackBoxOp::PedersenCommitment { .. } => BlackBoxFunc::PedersenCommitment, - BlackBoxOp::PedersenHash { .. } => BlackBoxFunc::PedersenHash, + BlackBoxOp::ToRadix { .. } => unreachable!("ToRadix is not an ACIR BlackBoxFunc"), } } diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs index 7b936702bbe..e5a5c0ea9b4 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs @@ -160,23 +160,6 @@ pub(crate) fn convert_black_box_call { - if let ( - [message, BrilligVariable::SingleAddr(domain_separator)], - [BrilligVariable::SingleAddr(result)], - ) = (function_arguments, function_results) - { - let inputs = convert_array_or_vector(brillig_context, *message, bb_func); - brillig_context.black_box_op_instruction(BlackBoxOp::PedersenHash { - inputs, - domain_separator: domain_separator.address, - output: result.address, - }); - brillig_context.deallocate_heap_vector(inputs); - } else { - unreachable!("ICE: Pedersen hash expects one array argument, a register for the domain separator, and one register result") - } - } BlackBoxFunc::SchnorrVerify => { if let ( [BrilligVariable::SingleAddr(public_key_x), BrilligVariable::SingleAddr(public_key_y), signature, message], diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir.rs index 42f593dc227..38c924772d1 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir.rs @@ -180,13 +180,6 @@ pub(crate) mod tests { ) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> { Ok((2_u128.into(), 3_u128.into())) } - fn pedersen_hash( - &self, - _inputs: &[FieldElement], - _domain_separator: u32, - ) -> Result { - Ok(6_u128.into()) - } fn multi_scalar_mul( &self, _points: &[FieldElement], diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs index 83eb7b5b31a..effd13c569e 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs @@ -344,15 +344,6 @@ impl DebugShow { output ); } - BlackBoxOp::PedersenHash { inputs, domain_separator, output } => { - debug_println!( - self.enable_debug_trace, - " PEDERSEN_HASH {} {} -> {}", - inputs, - domain_separator, - output - ); - } BlackBoxOp::SchnorrVerify { public_key_x, public_key_y, diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs index 1069416b7b8..f2c5821e118 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs @@ -1286,7 +1286,7 @@ impl AcirContext { ) -> Result, RuntimeError> { // Separate out any arguments that should be constants let (constant_inputs, constant_outputs) = match name { - BlackBoxFunc::PedersenCommitment | BlackBoxFunc::PedersenHash => { + BlackBoxFunc::PedersenCommitment => { // The last argument of pedersen is the domain separator, which must be a constant let domain_var = match inputs.pop() { Some(domain_var) => domain_var.into_var()?, diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs index 6000edf4bc4..dd65446e9b9 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs @@ -230,11 +230,6 @@ impl GeneratedAcir { outputs: (outputs[0], outputs[1]), domain_separator: constant_inputs[0].to_u128() as u32, }, - BlackBoxFunc::PedersenHash => BlackBoxFuncCall::PedersenHash { - inputs: inputs[0].clone(), - output: outputs[0], - domain_separator: constant_inputs[0].to_u128() as u32, - }, BlackBoxFunc::EcdsaSecp256k1 => { BlackBoxFuncCall::EcdsaSecp256k1 { // 32 bytes for each public key co-ordinate @@ -643,8 +638,7 @@ fn black_box_func_expected_input_size(name: BlackBoxFunc) -> Option { BlackBoxFunc::AES128Encrypt | BlackBoxFunc::Blake2s | BlackBoxFunc::Blake3 - | BlackBoxFunc::PedersenCommitment - | BlackBoxFunc::PedersenHash => None, + | BlackBoxFunc::PedersenCommitment => None, BlackBoxFunc::Keccakf1600 => Some(25), // The permutation takes a fixed number of inputs, but the inputs length depends on the proving system implementation. @@ -703,9 +697,6 @@ fn black_box_expected_output_size(name: BlackBoxFunc) -> Option { // Pedersen commitment returns a point BlackBoxFunc::PedersenCommitment => Some(2), - // Pedersen hash returns a field - BlackBoxFunc::PedersenHash => Some(1), - // Can only apply a range constraint to one // witness at a time. BlackBoxFunc::RANGE => Some(0), diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs index 6d16117d3d8..dfda675f439 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs @@ -552,9 +552,7 @@ fn simplify_black_box_func( acvm::blackbox_solver::ecdsa_secp256r1_verify, ), - BlackBoxFunc::PedersenCommitment - | BlackBoxFunc::PedersenHash - | BlackBoxFunc::MultiScalarMul => SimplifyResult::None, + BlackBoxFunc::PedersenCommitment | BlackBoxFunc::MultiScalarMul => SimplifyResult::None, BlackBoxFunc::EmbeddedCurveAdd => blackbox::simplify_ec_add(dfg, solver, arguments), BlackBoxFunc::SchnorrVerify => blackbox::simplify_schnorr_verify(dfg, solver, arguments), diff --git a/noir/noir-repo/noir_stdlib/src/hash/mod.nr b/noir/noir-repo/noir_stdlib/src/hash/mod.nr index af758642a0f..f41bcf830d5 100644 --- a/noir/noir-repo/noir_stdlib/src/hash/mod.nr +++ b/noir/noir-repo/noir_stdlib/src/hash/mod.nr @@ -33,10 +33,6 @@ pub fn pedersen_commitment(input: [Field; N]) -> EmbeddedCurvePoint } #[inline_always] -pub fn pedersen_hash_with_separator(input: [Field; N], separator: u32) -> Field { - pedersen_hash_with_separator_noir(input, separator) -} - pub fn pedersen_commitment_with_separator(input: [Field; N], separator: u32) -> EmbeddedCurvePoint { let value = __pedersen_commitment_with_separator(input, separator); if (value[0] == 0) & (value[1] == 0) { @@ -57,8 +53,15 @@ fn pedersen_commitment_with_separator_noir(input: [Field; N], separa multi_scalar_mul(generators, points) } +// docs:start:pedersen_hash +pub fn pedersen_hash(input: [Field; N]) -> Field +// docs:end:pedersen_hash +{ + pedersen_hash_with_separator(input, 0) +} + #[no_predicates] -fn pedersen_hash_with_separator_noir(input: [Field; N], separator: u32) -> Field { +pub fn pedersen_hash_with_separator(input: [Field; N], separator: u32) -> Field { let mut scalars: Vec = Vec::from_slice([EmbeddedCurveScalar { lo: 0, hi: 0 }; N].as_slice()); //Vec::new(); for i in 0..N { @@ -75,16 +78,6 @@ fn pedersen_hash_with_separator_noir(input: [Field; N], separator: u multi_scalar_mul_slice(vec_generators.slice, scalars.slice)[0] } -// docs:start:pedersen_hash -pub fn pedersen_hash(input: [Field; N]) -> Field -// docs:end:pedersen_hash -{ - pedersen_hash_with_separator_noir(input, 0) -} - -#[foreign(pedersen_hash)] -fn __pedersen_hash_with_separator(input: [Field; N], separator: u32) -> Field {} - #[foreign(pedersen_commitment)] fn __pedersen_commitment_with_separator(input: [Field; N], separator: u32) -> [Field; 2] {} diff --git a/noir/noir-repo/tooling/lsp/src/solver.rs b/noir/noir-repo/tooling/lsp/src/solver.rs index 9d1185e3a79..e379ca92e4a 100644 --- a/noir/noir-repo/tooling/lsp/src/solver.rs +++ b/noir/noir-repo/tooling/lsp/src/solver.rs @@ -24,14 +24,6 @@ impl BlackBoxFunctionSolver for WrapperSolver { self.0.pedersen_commitment(inputs, domain_separator) } - fn pedersen_hash( - &self, - inputs: &[acvm::FieldElement], - domain_separator: u32, - ) -> Result { - self.0.pedersen_hash(inputs, domain_separator) - } - fn multi_scalar_mul( &self, points: &[acvm::FieldElement], diff --git a/noir/noir-repo/tooling/profiler/src/opcode_formatter.rs b/noir/noir-repo/tooling/profiler/src/opcode_formatter.rs index 6f106d5de3e..6539a185c47 100644 --- a/noir/noir-repo/tooling/profiler/src/opcode_formatter.rs +++ b/noir/noir-repo/tooling/profiler/src/opcode_formatter.rs @@ -18,7 +18,6 @@ fn format_blackbox_function(call: &BlackBoxFuncCall) -> String { BlackBoxFuncCall::Blake3 { .. } => "blake3".to_string(), BlackBoxFuncCall::SchnorrVerify { .. } => "schnorr_verify".to_string(), BlackBoxFuncCall::PedersenCommitment { .. } => "pedersen_commitment".to_string(), - BlackBoxFuncCall::PedersenHash { .. } => "pedersen_hash".to_string(), BlackBoxFuncCall::EcdsaSecp256k1 { .. } => "ecdsa_secp256k1".to_string(), BlackBoxFuncCall::EcdsaSecp256r1 { .. } => "ecdsa_secp256r1".to_string(), BlackBoxFuncCall::MultiScalarMul { .. } => "multi_scalar_mul".to_string(), @@ -43,7 +42,6 @@ fn format_blackbox_op(call: &BlackBoxOp) -> String { BlackBoxOp::Blake3 { .. } => "blake3".to_string(), BlackBoxOp::SchnorrVerify { .. } => "schnorr_verify".to_string(), BlackBoxOp::PedersenCommitment { .. } => "pedersen_commitment".to_string(), - BlackBoxOp::PedersenHash { .. } => "pedersen_hash".to_string(), BlackBoxOp::EcdsaSecp256k1 { .. } => "ecdsa_secp256k1".to_string(), BlackBoxOp::EcdsaSecp256r1 { .. } => "ecdsa_secp256r1".to_string(), BlackBoxOp::MultiScalarMul { .. } => "multi_scalar_mul".to_string(),