Skip to content

Commit

Permalink
chore: Remove HashToField128Security ACIR opcode (AztecProtocol#3631)
Browse files Browse the repository at this point in the history
Please provide a paragraph or two giving a summary of the change,
including relevant motivation and context.

Remove the HashToField128Security ACIR opcode from the codebase.
Resolve issue noir-lang/noir#3340

This PR encompass PR noir-lang/noir#3389 which
can be closed once this one is merged.

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [X] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [X] Every change is related to the PR description.
- [X] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).

---------

Co-authored-by: kevaundray <kevtheappdev@gmail.com>
  • Loading branch information
guipublic and kevaundray authored Jan 5, 2024
1 parent 88fcf8d commit 1d6d3c9
Show file tree
Hide file tree
Showing 32 changed files with 10 additions and 493 deletions.
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ void acvm_info(const std::string& output_path)
"width" : 3
},
"opcodes_supported" : ["arithmetic", "directive", "brillig", "memory_init", "memory_op"],
"black_box_functions_supported" : ["and", "xor", "range", "sha256", "blake2s", "keccak256", "schnorr_verify", "pedersen", "pedersen_hash", "hash_to_field_128_security", "ecdsa_secp256k1", "ecdsa_secp256r1", "fixed_base_scalar_mul", "recursive_aggregation"]
"black_box_functions_supported" : ["and", "xor", "range", "sha256", "blake2s", "keccak256", "schnorr_verify", "pedersen", "pedersen_hash", "ecdsa_secp256k1", "ecdsa_secp256r1", "fixed_base_scalar_mul", "recursive_aggregation"]
})";

size_t length = strlen(jsonData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ void build_constraints(Builder& builder, acir_format const& constraint_system, b
create_fixed_base_constraint(builder, constraint);
}

// Add hash to field constraints
for (const auto& constraint : constraint_system.hash_to_field_constraints) {
create_hash_to_field_constraints(builder, constraint);
}

// Add block constraints
for (const auto& constraint : constraint_system.block_constraints) {
create_block_constraints(builder, constraint, has_valid_witness_assignments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "ecdsa_secp256k1.hpp"
#include "ecdsa_secp256r1.hpp"
#include "fixed_base_scalar_mul.hpp"
#include "hash_to_field.hpp"
#include "keccak_constraint.hpp"
#include "logic_constraint.hpp"
#include "pedersen.hpp"
Expand Down Expand Up @@ -35,7 +34,6 @@ struct acir_format {
std::vector<KeccakVarConstraint> keccak_var_constraints;
std::vector<PedersenConstraint> pedersen_constraints;
std::vector<PedersenHashConstraint> pedersen_hash_constraints;
std::vector<HashToFieldConstraint> hash_to_field_constraints;
std::vector<FixedBaseScalarMul> fixed_base_scalar_mul_constraints;
std::vector<RecursionConstraint> recursion_constraints;

Expand All @@ -61,7 +59,6 @@ struct acir_format {
keccak_var_constraints,
pedersen_constraints,
pedersen_hash_constraints,
hash_to_field_constraints,
fixed_base_scalar_mul_constraints,
recursion_constraints,
constraints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ TEST_F(AcirFormatTests, TestASingleConstraintNoPubInputs)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = { constraint },
Expand Down Expand Up @@ -148,7 +147,6 @@ TEST_F(AcirFormatTests, TestLogicGateFromNoirCircuit)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = { expr_a, expr_b, expr_c, expr_d },
Expand Down Expand Up @@ -213,7 +211,6 @@ TEST_F(AcirFormatTests, TestSchnorrVerifyPass)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = { poly_triple{
Expand Down Expand Up @@ -301,7 +298,6 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = { poly_triple{
Expand Down Expand Up @@ -408,7 +404,6 @@ TEST_F(AcirFormatTests, TestVarKeccak)
.keccak_var_constraints = { keccak },
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = { dummy },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "barretenberg/dsl/acir_format/blake2s_constraint.hpp"
#include "barretenberg/dsl/acir_format/block_constraint.hpp"
#include "barretenberg/dsl/acir_format/ecdsa_secp256k1.hpp"
#include "barretenberg/dsl/acir_format/hash_to_field.hpp"
#include "barretenberg/dsl/acir_format/keccak_constraint.hpp"
#include "barretenberg/dsl/acir_format/logic_constraint.hpp"
#include "barretenberg/dsl/acir_format/pedersen.hpp"
Expand Down Expand Up @@ -135,17 +134,6 @@ void handle_blackbox_func_call(Circuit::Opcode::BlackBoxFuncCall const& arg, aci
.hash_index = arg.domain_separator,
.result = arg.output.value,
});
} else if constexpr (std::is_same_v<T, Circuit::BlackBoxFuncCall::HashToField128Security>) {
af.hash_to_field_constraints.push_back(HashToFieldConstraint{
.inputs = map(arg.inputs,
[](auto& e) {
return HashToFieldInput{
.witness = e.witness.value,
.num_bits = e.num_bits,
};
}),
.result = arg.output.value,
});
} else if constexpr (std::is_same_v<T, Circuit::BlackBoxFuncCall::EcdsaSecp256k1>) {
af.ecdsa_k1_constraints.push_back(EcdsaSecp256k1Constraint{
.hashed_message = map(arg.hashed_message, [](auto& e) { return e.witness.value; }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ TEST_F(UltraPlonkRAM, TestBlockConstraint)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintSucceed)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = {},
Expand Down Expand Up @@ -142,7 +141,6 @@ TEST_F(ECDSASecp256k1, TestECDSACompilesForVerifier)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = {},
Expand Down Expand Up @@ -178,7 +176,6 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintFail)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ TEST(ECDSASecp256r1, test_hardcoded)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = {},
Expand Down Expand Up @@ -177,7 +176,6 @@ TEST(ECDSASecp256r1, TestECDSAConstraintSucceed)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = {},
Expand Down Expand Up @@ -217,7 +215,6 @@ TEST(ECDSASecp256r1, TestECDSACompilesForVerifier)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = {},
Expand Down Expand Up @@ -252,7 +249,6 @@ TEST(ECDSASecp256r1, TestECDSAConstraintFail)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = {},
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ Builder create_inner_circuit()
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = {},
.constraints = { expr_a, expr_b, expr_c, expr_d },
Expand Down Expand Up @@ -252,7 +251,6 @@ Builder create_outer_circuit(std::vector<Builder>& inner_circuits)
.keccak_var_constraints = {},
.pedersen_constraints = {},
.pedersen_hash_constraints = {},
.hash_to_field_constraints = {},
.fixed_base_scalar_mul_constraints = {},
.recursion_constraints = recursion_constraints,
.constraints = {},
Expand Down
Loading

0 comments on commit 1d6d3c9

Please sign in to comment.