From 99991b88ea18b5ee8e13934d5ad257885f758a56 Mon Sep 17 00:00:00 2001 From: guipublic <47281315+guipublic@users.noreply.github.com> Date: Fri, 5 Jan 2024 10:55:00 +0100 Subject: [PATCH] chore: Remove HashToField128Security ACIR opcode (#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 https://github.com/noir-lang/noir/issues/3340 This PR encompass PR https://github.com/noir-lang/noir/pull/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 --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 2 +- .../dsl/acir_format/acir_format.cpp | 5 - .../dsl/acir_format/acir_format.hpp | 3 - .../dsl/acir_format/acir_format.test.cpp | 5 - .../acir_format/acir_to_constraint_buf.hpp | 12 -- .../dsl/acir_format/block_constraint.test.cpp | 1 - .../dsl/acir_format/ecdsa_secp256k1.test.cpp | 3 - .../dsl/acir_format/ecdsa_secp256r1.test.cpp | 4 - .../dsl/acir_format/hash_to_field.cpp | 49 ------- .../dsl/acir_format/hash_to_field.hpp | 29 ---- .../acir_format/recursion_constraint.test.cpp | 2 - .../dsl/acir_format/serde/acir.hpp | 127 ------------------ barretenberg/ts/src/info.ts | 1 - noir/acvm-repo/acir/codegen/acir.cpp | 104 +------------- .../acir/src/circuit/black_box_functions.rs | 8 -- .../opcodes/black_box_function_call.rs | 11 +- .../acvm/src/compiler/transformers/mod.rs | 6 +- noir/acvm-repo/acvm/src/pwg/blackbox/hash.rs | 17 +-- noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs | 5 +- .../acvm_js/src/black_box_solvers.rs | 15 --- .../test/browser/black_box_solvers.test.ts | 12 -- .../acvm_js/test/shared/black_box_solvers.ts | 7 - noir/acvm-repo/blackbox_solver/src/lib.rs | 13 -- noir/acvm-repo/brillig/src/black_box.rs | 6 - noir/acvm-repo/brillig_vm/src/black_box.rs | 11 +- .../brillig/brillig_gen/brillig_black_box.rs | 13 -- .../src/brillig/brillig_ir/debug_show.rs | 8 -- .../ssa/acir_gen/acir_ir/generated_acir.rs | 9 +- .../src/ssa/ir/instruction/call.rs | 12 -- .../noir/standard_library/black_box_fns.md | 1 - .../cryptographic_primitives/hashes.mdx | 1 - .../mock_backend/src/info_cmd.rs | 1 - 32 files changed, 10 insertions(+), 493 deletions(-) delete mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_format/hash_to_field.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_format/hash_to_field.hpp diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 3cf532f8958..f61d1913a06 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -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); 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 428af52015f..516fa1aaa89 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp @@ -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); 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 2860e810818..1f00b202b9f 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp @@ -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" @@ -35,7 +34,6 @@ struct acir_format { std::vector keccak_var_constraints; std::vector pedersen_constraints; std::vector pedersen_hash_constraints; - std::vector hash_to_field_constraints; std::vector fixed_base_scalar_mul_constraints; std::vector recursion_constraints; @@ -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, 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 b0711582deb..a4f64e0791c 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 @@ -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 }, @@ -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 }, @@ -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{ @@ -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{ @@ -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 }, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp index aaf4833b998..123c52a27a3 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp @@ -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" @@ -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) { - 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) { af.ecdsa_k1_constraints.push_back(EcdsaSecp256k1Constraint{ .hashed_message = map(arg.hashed_message, [](auto& e) { return e.witness.value; }), 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 37c7aa784f2..a20de2c75db 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 @@ -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 = {}, 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 57576bd763f..9bcbc89ec87 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 @@ -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 = {}, @@ -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 = {}, @@ -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 = {}, 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 0f8764c3bc8..5d26a4b7a37 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 @@ -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 = {}, @@ -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 = {}, @@ -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 = {}, @@ -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 = {}, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/hash_to_field.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/hash_to_field.cpp deleted file mode 100644 index b2315247e3e..00000000000 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/hash_to_field.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "hash_to_field.hpp" -#include "round.hpp" - -namespace acir_format { - -using namespace proof_system::plonk; - -template -void create_hash_to_field_constraints(Builder& builder, const HashToFieldConstraint constraint) -{ - using byte_array_ct = proof_system::plonk::stdlib::byte_array; - using field_ct = proof_system::plonk::stdlib::field_t; - - // Create byte array struct - byte_array_ct arr(&builder); - - // Get the witness assignment for each witness index - // Write the witness assignment to the byte_array - for (const auto& witness_index_num_bits : constraint.inputs) { - auto witness_index = witness_index_num_bits.witness; - auto num_bits = witness_index_num_bits.num_bits; - - // XXX: The implementation requires us to truncate the element to the nearest byte and not bit - auto num_bytes = round_to_nearest_byte(num_bits); - - field_ct element = field_ct::from_witness_index(&builder, witness_index); - byte_array_ct element_bytes(element, num_bytes); - byte_array_ct reversed_bytes = element_bytes.reverse(); - - arr.write(reversed_bytes); - } - - // Hash To Field using blake2s. - // Note: It does not need to be blake2s in the future - - byte_array_ct out_bytes = stdlib::blake2s(arr); - - field_ct out(out_bytes); - field_ct normalised_out = out.normalize(); - - builder.assert_equal(normalised_out.witness_index, constraint.result); -} - -template void create_hash_to_field_constraints(UltraCircuitBuilder& builder, - const HashToFieldConstraint constraint); -template void create_hash_to_field_constraints(GoblinUltraCircuitBuilder& builder, - const HashToFieldConstraint constraint); - -} // namespace acir_format diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/hash_to_field.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/hash_to_field.hpp deleted file mode 100644 index 212232cc868..00000000000 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/hash_to_field.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include "barretenberg/dsl/types.hpp" -#include "barretenberg/serialize/msgpack.hpp" -#include -#include - -namespace acir_format { - -struct HashToFieldInput { - uint32_t witness; - uint32_t num_bits; - - // For serialization, update with any new fields - MSGPACK_FIELDS(witness, num_bits); - friend bool operator==(HashToFieldInput const& lhs, HashToFieldInput const& rhs) = default; -}; - -struct HashToFieldConstraint { - std::vector inputs; - uint32_t result; - - // For serialization, update with any new fields - MSGPACK_FIELDS(inputs, result); - friend bool operator==(HashToFieldConstraint const& lhs, HashToFieldConstraint const& rhs) = default; -}; - -template void create_hash_to_field_constraints(Builder& builder, HashToFieldConstraint constraint); - -} // namespace acir_format 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 a64f65462bc..c4decf04a3a 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 @@ -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 }, @@ -252,7 +251,6 @@ Builder create_outer_circuit(std::vector& inner_circuits) .keccak_var_constraints = {}, .pedersen_constraints = {}, .pedersen_hash_constraints = {}, - .hash_to_field_constraints = {}, .fixed_base_scalar_mul_constraints = {}, .recursion_constraints = recursion_constraints, .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 dc1e8e14821..2d124e2a7b2 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp @@ -102,15 +102,6 @@ struct BlackBoxFuncCall { static PedersenHash bincodeDeserialize(std::vector); }; - struct HashToField128Security { - std::vector inputs; - Circuit::Witness output; - - friend bool operator==(const HashToField128Security&, const HashToField128Security&); - std::vector bincodeSerialize() const; - static HashToField128Security bincodeDeserialize(std::vector); - }; - struct EcdsaSecp256k1 { std::vector public_key_x; std::vector public_key_y; @@ -185,7 +176,6 @@ struct BlackBoxFuncCall { SchnorrVerify, PedersenCommitment, PedersenHash, - HashToField128Security, EcdsaSecp256k1, EcdsaSecp256r1, FixedBaseScalarMul, @@ -423,15 +413,6 @@ struct BlackBoxOp { static Keccak256 bincodeDeserialize(std::vector); }; - struct HashToField128Security { - Circuit::HeapVector message; - Circuit::RegisterIndex output; - - friend bool operator==(const HashToField128Security&, const HashToField128Security&); - std::vector bincodeSerialize() const; - static HashToField128Security bincodeDeserialize(std::vector); - }; - struct EcdsaSecp256k1 { Circuit::HeapVector hashed_msg; Circuit::HeapArray public_key_x; @@ -501,7 +482,6 @@ struct BlackBoxOp { std::variant BlackBoxFuncCall::HashToField128Security::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxFuncCall::HashToField128Security BlackBoxFuncCall::HashToField128Security::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 Circuit - -template <> -template -void serde::Serializable::serialize( - const Circuit::BlackBoxFuncCall::HashToField128Security& obj, Serializer& serializer) -{ - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxFuncCall::HashToField128Security serde::Deserializable< - Circuit::BlackBoxFuncCall::HashToField128Security>::deserialize(Deserializer& deserializer) -{ - Circuit::BlackBoxFuncCall::HashToField128Security obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256k1& lhs, const BlackBoxFuncCall::EcdsaSecp256k1& rhs) { if (!(lhs.public_key_x == rhs.public_key_x)) { @@ -2874,59 +2800,6 @@ Circuit::BlackBoxOp::Keccak256 serde::Deserializable BlackBoxOp::HashToField128Security::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::HashToField128Security BlackBoxOp::HashToField128Security::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 Circuit - -template <> -template -void serde::Serializable::serialize( - const Circuit::BlackBoxOp::HashToField128Security& obj, Serializer& serializer) -{ - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::HashToField128Security serde::Deserializable< - Circuit::BlackBoxOp::HashToField128Security>::deserialize(Deserializer& deserializer) -{ - Circuit::BlackBoxOp::HashToField128Security obj; - obj.message = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - inline bool operator==(const BlackBoxOp::EcdsaSecp256k1& lhs, const BlackBoxOp::EcdsaSecp256k1& rhs) { if (!(lhs.hashed_msg == rhs.hashed_msg)) { diff --git a/barretenberg/ts/src/info.ts b/barretenberg/ts/src/info.ts index d6f22a752e5..6032427bdd5 100644 --- a/barretenberg/ts/src/info.ts +++ b/barretenberg/ts/src/info.ts @@ -15,7 +15,6 @@ export const acvmInfoJson = { 'schnorr_verify', 'pedersen', 'pedersen_hash', - 'hash_to_field_128_security', 'ecdsa_secp256k1', 'ecdsa_secp256r1', 'fixed_base_scalar_mul', diff --git a/noir/acvm-repo/acir/codegen/acir.cpp b/noir/acvm-repo/acir/codegen/acir.cpp index c31fc4abd00..18532940752 100644 --- a/noir/acvm-repo/acir/codegen/acir.cpp +++ b/noir/acvm-repo/acir/codegen/acir.cpp @@ -102,15 +102,6 @@ namespace Circuit { static PedersenHash bincodeDeserialize(std::vector); }; - struct HashToField128Security { - std::vector inputs; - Circuit::Witness output; - - friend bool operator==(const HashToField128Security&, const HashToField128Security&); - std::vector bincodeSerialize() const; - static HashToField128Security bincodeDeserialize(std::vector); - }; - struct EcdsaSecp256k1 { std::vector public_key_x; std::vector public_key_y; @@ -177,7 +168,7 @@ namespace Circuit { static RecursiveAggregation bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); std::vector bincodeSerialize() const; @@ -408,15 +399,6 @@ namespace Circuit { static Keccak256 bincodeDeserialize(std::vector); }; - struct HashToField128Security { - Circuit::HeapVector message; - Circuit::RegisterIndex output; - - friend bool operator==(const HashToField128Security&, const HashToField128Security&); - std::vector bincodeSerialize() const; - static HashToField128Security bincodeDeserialize(std::vector); - }; - struct EcdsaSecp256k1 { Circuit::HeapVector hashed_msg; Circuit::HeapArray public_key_x; @@ -483,7 +465,7 @@ namespace Circuit { static FixedBaseScalarMul bincodeDeserialize(std::vector); }; - std::variant value; + std::variant value; friend bool operator==(const BlackBoxOp&, const BlackBoxOp&); std::vector bincodeSerialize() const; @@ -1977,47 +1959,6 @@ Circuit::BlackBoxFuncCall::PedersenHash serde::Deserializable BlackBoxFuncCall::HashToField128Security::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxFuncCall::HashToField128Security BlackBoxFuncCall::HashToField128Security::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 Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::HashToField128Security &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxFuncCall::HashToField128Security serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxFuncCall::HashToField128Security obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - namespace Circuit { inline bool operator==(const BlackBoxFuncCall::EcdsaSecp256k1 &lhs, const BlackBoxFuncCall::EcdsaSecp256k1 &rhs) { @@ -2465,47 +2406,6 @@ Circuit::BlackBoxOp::Keccak256 serde::Deserializable BlackBoxOp::HashToField128Security::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxOp::HashToField128Security BlackBoxOp::HashToField128Security::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 Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::HashToField128Security &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::HashToField128Security serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxOp::HashToField128Security obj; - obj.message = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - namespace Circuit { inline bool operator==(const BlackBoxOp::EcdsaSecp256k1 &lhs, const BlackBoxOp::EcdsaSecp256k1 &rhs) { diff --git a/noir/acvm-repo/acir/src/circuit/black_box_functions.rs b/noir/acvm-repo/acir/src/circuit/black_box_functions.rs index dec60c09077..b2dcbd73ef6 100644 --- a/noir/acvm-repo/acir/src/circuit/black_box_functions.rs +++ b/noir/acvm-repo/acir/src/circuit/black_box_functions.rs @@ -30,12 +30,6 @@ pub enum BlackBoxFunc { PedersenCommitment, /// Calculates a Pedersen hash to the inputs. PedersenHash, - /// Hashes a set of inputs and applies the field modulus to the result - /// to return a value which can be represented as a [`FieldElement`][acir_field::FieldElement] - /// - /// This is implemented using the `Blake2s` hash function. - /// The "128" in the name specifies that this function should have 128 bits of security. - HashToField128Security, /// Verifies a ECDSA signature over the secp256k1 curve. EcdsaSecp256k1, /// Verifies a ECDSA signature over the secp256r1 curve. @@ -63,7 +57,6 @@ impl BlackBoxFunc { BlackBoxFunc::Blake2s => "blake2s", BlackBoxFunc::PedersenCommitment => "pedersen_commitment", BlackBoxFunc::PedersenHash => "pedersen_hash", - BlackBoxFunc::HashToField128Security => "hash_to_field_128_security", BlackBoxFunc::EcdsaSecp256k1 => "ecdsa_secp256k1", BlackBoxFunc::FixedBaseScalarMul => "fixed_base_scalar_mul", BlackBoxFunc::AND => "and", @@ -81,7 +74,6 @@ impl BlackBoxFunc { "blake2s" => Some(BlackBoxFunc::Blake2s), "pedersen_commitment" => Some(BlackBoxFunc::PedersenCommitment), "pedersen_hash" => Some(BlackBoxFunc::PedersenHash), - "hash_to_field_128_security" => Some(BlackBoxFunc::HashToField128Security), "ecdsa_secp256k1" => Some(BlackBoxFunc::EcdsaSecp256k1), "ecdsa_secp256r1" => Some(BlackBoxFunc::EcdsaSecp256r1), "fixed_base_scalar_mul" => Some(BlackBoxFunc::FixedBaseScalarMul), diff --git a/noir/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs b/noir/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs index 70821913836..ded3b0898a0 100644 --- a/noir/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs +++ b/noir/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs @@ -56,12 +56,6 @@ pub enum BlackBoxFuncCall { domain_separator: u32, output: Witness, }, - // 128 here specifies that this function - // should have 128 bits of security - HashToField128Security { - inputs: Vec, - output: Witness, - }, EcdsaSecp256k1 { public_key_x: Vec, public_key_y: Vec, @@ -130,7 +124,6 @@ impl BlackBoxFuncCall { BlackBoxFuncCall::SchnorrVerify { .. } => BlackBoxFunc::SchnorrVerify, BlackBoxFuncCall::PedersenCommitment { .. } => BlackBoxFunc::PedersenCommitment, BlackBoxFuncCall::PedersenHash { .. } => BlackBoxFunc::PedersenHash, - BlackBoxFuncCall::HashToField128Security { .. } => BlackBoxFunc::HashToField128Security, BlackBoxFuncCall::EcdsaSecp256k1 { .. } => BlackBoxFunc::EcdsaSecp256k1, BlackBoxFuncCall::EcdsaSecp256r1 { .. } => BlackBoxFunc::EcdsaSecp256r1, BlackBoxFuncCall::FixedBaseScalarMul { .. } => BlackBoxFunc::FixedBaseScalarMul, @@ -150,8 +143,7 @@ impl BlackBoxFuncCall { | BlackBoxFuncCall::Blake2s { inputs, .. } | BlackBoxFuncCall::Keccak256 { inputs, .. } | BlackBoxFuncCall::PedersenCommitment { inputs, .. } - | BlackBoxFuncCall::PedersenHash { inputs, .. } - | BlackBoxFuncCall::HashToField128Security { inputs, .. } => inputs.to_vec(), + | BlackBoxFuncCall::PedersenHash { inputs, .. } => inputs.to_vec(), BlackBoxFuncCall::AND { lhs, rhs, .. } | BlackBoxFuncCall::XOR { lhs, rhs, .. } => { vec![*lhs, *rhs] } @@ -244,7 +236,6 @@ impl BlackBoxFuncCall { } => outputs.to_vec(), BlackBoxFuncCall::AND { output, .. } | BlackBoxFuncCall::XOR { output, .. } - | BlackBoxFuncCall::HashToField128Security { output, .. } | BlackBoxFuncCall::SchnorrVerify { output, .. } | BlackBoxFuncCall::EcdsaSecp256k1 { output, .. } | BlackBoxFuncCall::PedersenHash { output, .. } diff --git a/noir/acvm-repo/acvm/src/compiler/transformers/mod.rs b/noir/acvm-repo/acvm/src/compiler/transformers/mod.rs index 2a3e28c536a..664e0f9ac9a 100644 --- a/noir/acvm-repo/acvm/src/compiler/transformers/mod.rs +++ b/noir/acvm-repo/acvm/src/compiler/transformers/mod.rs @@ -132,11 +132,7 @@ pub(super) fn transform_internal( transformer.mark_solvable(outputs.0); transformer.mark_solvable(outputs.1); } - acir::circuit::opcodes::BlackBoxFuncCall::HashToField128Security { - output, - .. - } - | acir::circuit::opcodes::BlackBoxFuncCall::EcdsaSecp256k1 { output, .. } + acir::circuit::opcodes::BlackBoxFuncCall::EcdsaSecp256k1 { output, .. } | acir::circuit::opcodes::BlackBoxFuncCall::EcdsaSecp256r1 { output, .. } | acir::circuit::opcodes::BlackBoxFuncCall::SchnorrVerify { output, .. } | acir::circuit::opcodes::BlackBoxFuncCall::PedersenHash { output, .. } => { diff --git a/noir/acvm-repo/acvm/src/pwg/blackbox/hash.rs b/noir/acvm-repo/acvm/src/pwg/blackbox/hash.rs index 80665a743c4..1ada397fc59 100644 --- a/noir/acvm-repo/acvm/src/pwg/blackbox/hash.rs +++ b/noir/acvm-repo/acvm/src/pwg/blackbox/hash.rs @@ -3,26 +3,11 @@ use acir::{ native_types::{Witness, WitnessMap}, BlackBoxFunc, FieldElement, }; -use acvm_blackbox_solver::{hash_to_field_128_security, BlackBoxResolutionError}; +use acvm_blackbox_solver::BlackBoxResolutionError; use crate::pwg::{insert_value, witness_to_value}; use crate::OpcodeResolutionError; -/// Attempts to solve a `HashToField128Security` opcode -/// If successful, `initial_witness` will be mutated to contain the new witness assignment. -pub(super) fn solve_hash_to_field( - initial_witness: &mut WitnessMap, - inputs: &[FunctionInput], - output: &Witness, -) -> Result<(), OpcodeResolutionError> { - let message_input = get_hash_input(initial_witness, inputs, None)?; - let field = hash_to_field_128_security(&message_input)?; - - insert_value(output, field, initial_witness)?; - - Ok(()) -} - /// Attempts to solve a 256 bit hash function opcode. /// If successful, `initial_witness` will be mutated to contain the new witness assignment. pub(super) fn solve_generic_256_hash_opcode( diff --git a/noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs b/noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs index 7e8ab8b948c..ad15b121383 100644 --- a/noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs +++ b/noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs @@ -19,7 +19,7 @@ mod signature; use fixed_base_scalar_mul::fixed_base_scalar_mul; // Hash functions should eventually be exposed for external consumers. -use hash::{solve_generic_256_hash_opcode, solve_hash_to_field}; +use hash::solve_generic_256_hash_opcode; use logic::{and, xor}; use pedersen::pedersen; use range::solve_range_opcode; @@ -101,9 +101,6 @@ pub(crate) fn solve( bb_func.get_black_box_func(), ) } - BlackBoxFuncCall::HashToField128Security { inputs, output } => { - solve_hash_to_field(initial_witness, inputs, output) - } BlackBoxFuncCall::SchnorrVerify { public_key_x, public_key_y, diff --git a/noir/acvm-repo/acvm_js/src/black_box_solvers.rs b/noir/acvm-repo/acvm_js/src/black_box_solvers.rs index cc3edc3de04..fc0e3b28ebf 100644 --- a/noir/acvm-repo/acvm_js/src/black_box_solvers.rs +++ b/noir/acvm-repo/acvm_js/src/black_box_solvers.rs @@ -40,21 +40,6 @@ pub fn keccak256(inputs: &[u8]) -> Vec { acvm::blackbox_solver::keccak256(inputs).unwrap().into() } -/// Calculates the Blake2s256 hash of the input bytes and represents these as a single field element. -// #[wasm_bindgen] -// pub fn hash_to_field_128_security(inputs: Vec) -> JsString { -// let input_bytes: Vec = inputs -// .into_iter() -// .flat_map(|field_string| { -// let field_element = js_value_to_field_element(field_string.into()).unwrap(); -// witness_assignment.fetch_nearest_bytes(FieldElement::max_num_bits()); -// }) -// .collect(); -// field_element_to_js_string( -// &acvm::blackbox_solver::hash_to_field_128_security(&input_bytes).unwrap(), -// ) -// } - /// Verifies a ECDSA signature over the secp256k1 curve. #[wasm_bindgen] pub fn ecdsa_secp256k1_verify( diff --git a/noir/acvm-repo/acvm_js/test/browser/black_box_solvers.test.ts b/noir/acvm-repo/acvm_js/test/browser/black_box_solvers.test.ts index 9aec1403f6c..3c54fe8e38f 100644 --- a/noir/acvm-repo/acvm_js/test/browser/black_box_solvers.test.ts +++ b/noir/acvm-repo/acvm_js/test/browser/black_box_solvers.test.ts @@ -64,18 +64,6 @@ it('successfully calculates the keccak256 hash', async () => { } }); -// it("successfully calculates the hash_to_field_128_security field", async () => { -// const { hash_to_field_128_security_test_cases } = await import( -// "../shared/black_box_solvers" -// ); - -// for (const testCase of hash_to_field_128_security_test_cases) { -// const [preimage, expectedResult] = testCase; -// const hashField = hash_to_field_128_security(preimage); -// expect(hashField).to.be.eq(expectedResult); -// } -// }); - it('successfully verifies secp256k1 ECDSA signatures', async () => { const { ecdsa_secp256k1_test_cases } = await import('../shared/black_box_solvers'); diff --git a/noir/acvm-repo/acvm_js/test/shared/black_box_solvers.ts b/noir/acvm-repo/acvm_js/test/shared/black_box_solvers.ts index a5b6d1ac996..0ab3fc12b72 100644 --- a/noir/acvm-repo/acvm_js/test/shared/black_box_solvers.ts +++ b/noir/acvm-repo/acvm_js/test/shared/black_box_solvers.ts @@ -66,13 +66,6 @@ export const keccak256_test_cases: [Uint8Array, Uint8Array][] = [ ], ]; -// export const hash_to_field_128_security_test_cases: [string[], string][] = [ -// [ -// ["0x0000000000000000000000000000000000000000000000000000000000000001"], -// "0x25cebc29ded2fa515a937e2b5f674e3026c012e5b57f8a48d7dce6b7d274f9d9", -// ], -// ]; - export const ecdsa_secp256k1_test_cases: [[Uint8Array, Uint8Array, Uint8Array, Uint8Array], boolean][] = [ [ [ diff --git a/noir/acvm-repo/blackbox_solver/src/lib.rs b/noir/acvm-repo/blackbox_solver/src/lib.rs index 8b7c6343962..cf2cf295f7a 100644 --- a/noir/acvm-repo/blackbox_solver/src/lib.rs +++ b/noir/acvm-repo/blackbox_solver/src/lib.rs @@ -64,11 +64,6 @@ pub fn keccak256(inputs: &[u8]) -> Result<[u8; 32], BlackBoxResolutionError> { .map_err(|err| BlackBoxResolutionError::Failed(BlackBoxFunc::Keccak256, err)) } -pub fn hash_to_field_128_security(inputs: &[u8]) -> Result { - generic_hash_to_field::(inputs) - .map_err(|err| BlackBoxResolutionError::Failed(BlackBoxFunc::HashToField128Security, err)) -} - pub fn ecdsa_secp256k1_verify( hashed_msg: &[u8], public_key_x: &[u8; 32], @@ -95,14 +90,6 @@ fn generic_hash_256(message: &[u8]) -> Result<[u8; 32], String> { Ok(output_bytes) } -/// Does a generic hash of the entire inputs converting the resulting hash into a single output field. -fn generic_hash_to_field(message: &[u8]) -> Result { - let output_bytes: [u8; 32] = - D::digest(message).as_slice().try_into().map_err(|_| "digest should be 256 bits")?; - - Ok(FieldElement::from_be_bytes_reduce(&output_bytes)) -} - fn verify_secp256k1_ecdsa_signature( hashed_msg: &[u8], public_key_x_bytes: &[u8; 32], diff --git a/noir/acvm-repo/brillig/src/black_box.rs b/noir/acvm-repo/brillig/src/black_box.rs index 75fae0a10f0..41e54ab2705 100644 --- a/noir/acvm-repo/brillig/src/black_box.rs +++ b/noir/acvm-repo/brillig/src/black_box.rs @@ -11,12 +11,6 @@ pub enum BlackBoxOp { Blake2s { message: HeapVector, output: HeapArray }, /// Calculates the Keccak256 hash of the inputs. Keccak256 { message: HeapVector, output: HeapArray }, - /// Hashes a set of inputs and applies the field modulus to the result - /// to return a value which can be represented as a [`FieldElement`][acir_field::FieldElement] - /// - /// This is implemented using the `Blake2s` hash function. - /// The "128" in the name specifies that this function should have 128 bits of security. - HashToField128Security { message: HeapVector, output: RegisterIndex }, /// Verifies a ECDSA signature over the secp256k1 curve. EcdsaSecp256k1 { hashed_msg: HeapVector, diff --git a/noir/acvm-repo/brillig_vm/src/black_box.rs b/noir/acvm-repo/brillig_vm/src/black_box.rs index 66d40c48aec..bf05522f89a 100644 --- a/noir/acvm-repo/brillig_vm/src/black_box.rs +++ b/noir/acvm-repo/brillig_vm/src/black_box.rs @@ -1,8 +1,8 @@ use acir::brillig::{BlackBoxOp, HeapArray, HeapVector, Value}; use acir::{BlackBoxFunc, FieldElement}; use acvm_blackbox_solver::{ - blake2s, ecdsa_secp256k1_verify, ecdsa_secp256r1_verify, hash_to_field_128_security, keccak256, - sha256, BlackBoxFunctionSolver, BlackBoxResolutionError, + blake2s, ecdsa_secp256k1_verify, ecdsa_secp256r1_verify, keccak256, sha256, + BlackBoxFunctionSolver, BlackBoxResolutionError, }; use crate::{Memory, Registers}; @@ -64,13 +64,6 @@ pub(crate) fn evaluate_black_box( memory.write_slice(registers.get(output.pointer).to_usize(), &to_value_vec(&bytes)); Ok(()) } - BlackBoxOp::HashToField128Security { message, output } => { - let field = hash_to_field_128_security(&to_u8_vec(read_heap_vector( - memory, registers, message, - )))?; - registers.set(*output, field.into()); - Ok(()) - } BlackBoxOp::EcdsaSecp256k1 { hashed_msg, public_key_x, diff --git a/noir/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs b/noir/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs index 9979bf0cd29..d7f83c32cdf 100644 --- a/noir/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs +++ b/noir/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs @@ -58,19 +58,6 @@ pub(crate) fn convert_black_box_call( unreachable!("ICE: Keccak256 expects message, message size and result array") } } - BlackBoxFunc::HashToField128Security => { - if let ([message], [BrilligVariable::Simple(result_register)]) = - (function_arguments, function_results) - { - let message_vector = convert_array_or_vector(brillig_context, message, bb_func); - brillig_context.black_box_op_instruction(BlackBoxOp::HashToField128Security { - message: message_vector.to_heap_vector(), - output: *result_register, - }); - } else { - unreachable!("ICE: HashToField128Security expects one array argument and one register result") - } - } BlackBoxFunc::EcdsaSecp256k1 => { if let ( [BrilligVariable::BrilligArray(public_key_x), BrilligVariable::BrilligArray(public_key_y), BrilligVariable::BrilligArray(signature), message], diff --git a/noir/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs b/noir/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs index 65db47dd2e0..aae74849b8c 100644 --- a/noir/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs +++ b/noir/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs @@ -353,14 +353,6 @@ impl DebugShow { BlackBoxOp::Blake2s { message, output } => { debug_println!(self.enable_debug_trace, " BLAKE2S {} -> {}", message, output); } - BlackBoxOp::HashToField128Security { message, output } => { - debug_println!( - self.enable_debug_trace, - " HASH_TO_FIELD_128_SECURITY {} -> {}", - message, - output - ); - } BlackBoxOp::EcdsaSecp256k1 { hashed_msg, public_key_x, diff --git a/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs b/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs index f29d3c9ec05..bd8271260af 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs @@ -155,10 +155,6 @@ impl GeneratedAcir { BlackBoxFunc::Blake2s => { BlackBoxFuncCall::Blake2s { inputs: inputs[0].clone(), outputs } } - BlackBoxFunc::HashToField128Security => BlackBoxFuncCall::HashToField128Security { - inputs: inputs[0].clone(), - output: outputs[0], - }, BlackBoxFunc::SchnorrVerify => { BlackBoxFuncCall::SchnorrVerify { public_key_x: inputs[0][0], @@ -574,8 +570,7 @@ fn black_box_func_expected_input_size(name: BlackBoxFunc) -> Option { | BlackBoxFunc::SHA256 | BlackBoxFunc::Blake2s | BlackBoxFunc::PedersenCommitment - | BlackBoxFunc::PedersenHash - | BlackBoxFunc::HashToField128Security => None, + | BlackBoxFunc::PedersenHash => None, // Can only apply a range constraint to one // witness at a time. @@ -603,8 +598,6 @@ fn black_box_expected_output_size(name: BlackBoxFunc) -> Option { BlackBoxFunc::AND | BlackBoxFunc::XOR => Some(1), // 32 byte hash algorithms BlackBoxFunc::Keccak256 | BlackBoxFunc::SHA256 | BlackBoxFunc::Blake2s => Some(32), - // Hash to field returns a field element - BlackBoxFunc::HashToField128Security => Some(1), // Pedersen commitment returns a point BlackBoxFunc::PedersenCommitment => Some(2), // Pedersen hash returns a field diff --git a/noir/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs b/noir/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs index b07e2df7bd3..cada0b97f93 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs @@ -393,18 +393,6 @@ fn simplify_black_box_func( _ => SimplifyResult::None, } } - BlackBoxFunc::HashToField128Security => match dfg.get_array_constant(arguments[0]) { - Some((input, _)) if array_is_constant(dfg, &input) => { - let input_bytes: Vec = to_u8_vec(dfg, input); - - let field = acvm::blackbox_solver::hash_to_field_128_security(&input_bytes) - .expect("Rust solvable black box function should not fail"); - - let field_constant = dfg.make_constant(field, Type::field()); - SimplifyResult::SimplifiedTo(field_constant) - } - _ => SimplifyResult::None, - }, BlackBoxFunc::EcdsaSecp256k1 => { simplify_signature(dfg, arguments, acvm::blackbox_solver::ecdsa_secp256k1_verify) diff --git a/noir/docs/docs/noir/standard_library/black_box_fns.md b/noir/docs/docs/noir/standard_library/black_box_fns.md index 1dfabfe8f22..02a518e3803 100644 --- a/noir/docs/docs/noir/standard_library/black_box_fns.md +++ b/noir/docs/docs/noir/standard_library/black_box_fns.md @@ -31,7 +31,6 @@ Here is a list of the current black box functions that are supported by UltraPlo - [Blake2s](./cryptographic_primitives/hashes#blake2s) - [Pedersen Hash](./cryptographic_primitives/hashes#pedersen_hash) - [Pedersen Commitment](./cryptographic_primitives/hashes#pedersen_commitment) -- [HashToField128Security](./cryptographic_primitives/hashes#hash_to_field) - [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification) - [Fixed base scalar multiplication](./cryptographic_primitives/scalar) - [Compute merkle root](./merkle_trees#compute_merkle_root) diff --git a/noir/docs/docs/noir/standard_library/cryptographic_primitives/hashes.mdx b/noir/docs/docs/noir/standard_library/cryptographic_primitives/hashes.mdx index 9250cb4a0c0..3c5f7f79603 100644 --- a/noir/docs/docs/noir/standard_library/cryptographic_primitives/hashes.mdx +++ b/noir/docs/docs/noir/standard_library/cryptographic_primitives/hashes.mdx @@ -165,4 +165,3 @@ fn hash_to_field(_input : [Field; N]) -> Field {} Calculates the `blake2s` hash of the inputs and returns the hash modulo the field modulus to return a value which can be represented as a `Field`. - diff --git a/noir/tooling/backend_interface/test-binaries/mock_backend/src/info_cmd.rs b/noir/tooling/backend_interface/test-binaries/mock_backend/src/info_cmd.rs index e9a7842ba24..09c9596fb5a 100644 --- a/noir/tooling/backend_interface/test-binaries/mock_backend/src/info_cmd.rs +++ b/noir/tooling/backend_interface/test-binaries/mock_backend/src/info_cmd.rs @@ -18,7 +18,6 @@ const INFO_RESPONSE: &str = r#"{ "schnorr_verify", "pedersen", "pedersen_hash", - "hash_to_field_128_security", "ecdsa_secp256k1", "ecdsa_secp256r1", "fixed_base_scalar_mul",