Skip to content

Commit 1d6d3c9

Browse files
chore: Remove HashToField128Security ACIR opcode (AztecProtocol#3631)
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>
1 parent 88fcf8d commit 1d6d3c9

File tree

32 files changed

+10
-493
lines changed

32 files changed

+10
-493
lines changed

barretenberg/cpp/src/barretenberg/bb/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ void acvm_info(const std::string& output_path)
400400
"width" : 3
401401
},
402402
"opcodes_supported" : ["arithmetic", "directive", "brillig", "memory_init", "memory_op"],
403-
"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"]
403+
"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"]
404404
})";
405405

406406
size_t length = strlen(jsonData);

barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ void build_constraints(Builder& builder, acir_format const& constraint_system, b
141141
create_fixed_base_constraint(builder, constraint);
142142
}
143143

144-
// Add hash to field constraints
145-
for (const auto& constraint : constraint_system.hash_to_field_constraints) {
146-
create_hash_to_field_constraints(builder, constraint);
147-
}
148-
149144
// Add block constraints
150145
for (const auto& constraint : constraint_system.block_constraints) {
151146
create_block_constraints(builder, constraint, has_valid_witness_assignments);

barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "ecdsa_secp256k1.hpp"
88
#include "ecdsa_secp256r1.hpp"
99
#include "fixed_base_scalar_mul.hpp"
10-
#include "hash_to_field.hpp"
1110
#include "keccak_constraint.hpp"
1211
#include "logic_constraint.hpp"
1312
#include "pedersen.hpp"
@@ -35,7 +34,6 @@ struct acir_format {
3534
std::vector<KeccakVarConstraint> keccak_var_constraints;
3635
std::vector<PedersenConstraint> pedersen_constraints;
3736
std::vector<PedersenHashConstraint> pedersen_hash_constraints;
38-
std::vector<HashToFieldConstraint> hash_to_field_constraints;
3937
std::vector<FixedBaseScalarMul> fixed_base_scalar_mul_constraints;
4038
std::vector<RecursionConstraint> recursion_constraints;
4139

@@ -61,7 +59,6 @@ struct acir_format {
6159
keccak_var_constraints,
6260
pedersen_constraints,
6361
pedersen_hash_constraints,
64-
hash_to_field_constraints,
6562
fixed_base_scalar_mul_constraints,
6663
recursion_constraints,
6764
constraints,

barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ TEST_F(AcirFormatTests, TestASingleConstraintNoPubInputs)
4141
.keccak_var_constraints = {},
4242
.pedersen_constraints = {},
4343
.pedersen_hash_constraints = {},
44-
.hash_to_field_constraints = {},
4544
.fixed_base_scalar_mul_constraints = {},
4645
.recursion_constraints = {},
4746
.constraints = { constraint },
@@ -148,7 +147,6 @@ TEST_F(AcirFormatTests, TestLogicGateFromNoirCircuit)
148147
.keccak_var_constraints = {},
149148
.pedersen_constraints = {},
150149
.pedersen_hash_constraints = {},
151-
.hash_to_field_constraints = {},
152150
.fixed_base_scalar_mul_constraints = {},
153151
.recursion_constraints = {},
154152
.constraints = { expr_a, expr_b, expr_c, expr_d },
@@ -213,7 +211,6 @@ TEST_F(AcirFormatTests, TestSchnorrVerifyPass)
213211
.keccak_var_constraints = {},
214212
.pedersen_constraints = {},
215213
.pedersen_hash_constraints = {},
216-
.hash_to_field_constraints = {},
217214
.fixed_base_scalar_mul_constraints = {},
218215
.recursion_constraints = {},
219216
.constraints = { poly_triple{
@@ -301,7 +298,6 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange)
301298
.keccak_var_constraints = {},
302299
.pedersen_constraints = {},
303300
.pedersen_hash_constraints = {},
304-
.hash_to_field_constraints = {},
305301
.fixed_base_scalar_mul_constraints = {},
306302
.recursion_constraints = {},
307303
.constraints = { poly_triple{
@@ -408,7 +404,6 @@ TEST_F(AcirFormatTests, TestVarKeccak)
408404
.keccak_var_constraints = { keccak },
409405
.pedersen_constraints = {},
410406
.pedersen_hash_constraints = {},
411-
.hash_to_field_constraints = {},
412407
.fixed_base_scalar_mul_constraints = {},
413408
.recursion_constraints = {},
414409
.constraints = { dummy },

barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp

-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "barretenberg/dsl/acir_format/blake2s_constraint.hpp"
66
#include "barretenberg/dsl/acir_format/block_constraint.hpp"
77
#include "barretenberg/dsl/acir_format/ecdsa_secp256k1.hpp"
8-
#include "barretenberg/dsl/acir_format/hash_to_field.hpp"
98
#include "barretenberg/dsl/acir_format/keccak_constraint.hpp"
109
#include "barretenberg/dsl/acir_format/logic_constraint.hpp"
1110
#include "barretenberg/dsl/acir_format/pedersen.hpp"
@@ -135,17 +134,6 @@ void handle_blackbox_func_call(Circuit::Opcode::BlackBoxFuncCall const& arg, aci
135134
.hash_index = arg.domain_separator,
136135
.result = arg.output.value,
137136
});
138-
} else if constexpr (std::is_same_v<T, Circuit::BlackBoxFuncCall::HashToField128Security>) {
139-
af.hash_to_field_constraints.push_back(HashToFieldConstraint{
140-
.inputs = map(arg.inputs,
141-
[](auto& e) {
142-
return HashToFieldInput{
143-
.witness = e.witness.value,
144-
.num_bits = e.num_bits,
145-
};
146-
}),
147-
.result = arg.output.value,
148-
});
149137
} else if constexpr (std::is_same_v<T, Circuit::BlackBoxFuncCall::EcdsaSecp256k1>) {
150138
af.ecdsa_k1_constraints.push_back(EcdsaSecp256k1Constraint{
151139
.hashed_message = map(arg.hashed_message, [](auto& e) { return e.witness.value; }),

barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ TEST_F(UltraPlonkRAM, TestBlockConstraint)
122122
.keccak_var_constraints = {},
123123
.pedersen_constraints = {},
124124
.pedersen_hash_constraints = {},
125-
.hash_to_field_constraints = {},
126125
.fixed_base_scalar_mul_constraints = {},
127126
.recursion_constraints = {},
128127
.constraints = {},

barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintSucceed)
101101
.keccak_var_constraints = {},
102102
.pedersen_constraints = {},
103103
.pedersen_hash_constraints = {},
104-
.hash_to_field_constraints = {},
105104
.fixed_base_scalar_mul_constraints = {},
106105
.recursion_constraints = {},
107106
.constraints = {},
@@ -142,7 +141,6 @@ TEST_F(ECDSASecp256k1, TestECDSACompilesForVerifier)
142141
.keccak_var_constraints = {},
143142
.pedersen_constraints = {},
144143
.pedersen_hash_constraints = {},
145-
.hash_to_field_constraints = {},
146144
.fixed_base_scalar_mul_constraints = {},
147145
.recursion_constraints = {},
148146
.constraints = {},
@@ -178,7 +176,6 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintFail)
178176
.keccak_var_constraints = {},
179177
.pedersen_constraints = {},
180178
.pedersen_hash_constraints = {},
181-
.hash_to_field_constraints = {},
182179
.fixed_base_scalar_mul_constraints = {},
183180
.recursion_constraints = {},
184181
.constraints = {},

barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ TEST(ECDSASecp256r1, test_hardcoded)
135135
.keccak_var_constraints = {},
136136
.pedersen_constraints = {},
137137
.pedersen_hash_constraints = {},
138-
.hash_to_field_constraints = {},
139138
.fixed_base_scalar_mul_constraints = {},
140139
.recursion_constraints = {},
141140
.constraints = {},
@@ -177,7 +176,6 @@ TEST(ECDSASecp256r1, TestECDSAConstraintSucceed)
177176
.keccak_var_constraints = {},
178177
.pedersen_constraints = {},
179178
.pedersen_hash_constraints = {},
180-
.hash_to_field_constraints = {},
181179
.fixed_base_scalar_mul_constraints = {},
182180
.recursion_constraints = {},
183181
.constraints = {},
@@ -217,7 +215,6 @@ TEST(ECDSASecp256r1, TestECDSACompilesForVerifier)
217215
.keccak_var_constraints = {},
218216
.pedersen_constraints = {},
219217
.pedersen_hash_constraints = {},
220-
.hash_to_field_constraints = {},
221218
.fixed_base_scalar_mul_constraints = {},
222219
.recursion_constraints = {},
223220
.constraints = {},
@@ -252,7 +249,6 @@ TEST(ECDSASecp256r1, TestECDSAConstraintFail)
252249
.keccak_var_constraints = {},
253250
.pedersen_constraints = {},
254251
.pedersen_hash_constraints = {},
255-
.hash_to_field_constraints = {},
256252
.fixed_base_scalar_mul_constraints = {},
257253
.recursion_constraints = {},
258254
.constraints = {},

barretenberg/cpp/src/barretenberg/dsl/acir_format/hash_to_field.cpp

-49
This file was deleted.

barretenberg/cpp/src/barretenberg/dsl/acir_format/hash_to_field.hpp

-29
This file was deleted.

barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ Builder create_inner_circuit()
9494
.keccak_var_constraints = {},
9595
.pedersen_constraints = {},
9696
.pedersen_hash_constraints = {},
97-
.hash_to_field_constraints = {},
9897
.fixed_base_scalar_mul_constraints = {},
9998
.recursion_constraints = {},
10099
.constraints = { expr_a, expr_b, expr_c, expr_d },
@@ -252,7 +251,6 @@ Builder create_outer_circuit(std::vector<Builder>& inner_circuits)
252251
.keccak_var_constraints = {},
253252
.pedersen_constraints = {},
254253
.pedersen_hash_constraints = {},
255-
.hash_to_field_constraints = {},
256254
.fixed_base_scalar_mul_constraints = {},
257255
.recursion_constraints = recursion_constraints,
258256
.constraints = {},

0 commit comments

Comments
 (0)