Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove HashToField128Security ACIR opcode #3631

Merged
merged 16 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,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;
// A standard plonk arithmetic constraint, as defined in the poly_triple struct, consists of selector values
Expand All @@ -60,7 +58,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 @@ -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

This file was deleted.

This file was deleted.

127 changes: 0 additions & 127 deletions barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ struct BlackBoxFuncCall {
static PedersenHash bincodeDeserialize(std::vector<uint8_t>);
};

struct HashToField128Security {
std::vector<Circuit::FunctionInput> inputs;
Circuit::Witness output;

friend bool operator==(const HashToField128Security&, const HashToField128Security&);
std::vector<uint8_t> bincodeSerialize() const;
static HashToField128Security bincodeDeserialize(std::vector<uint8_t>);
};

struct EcdsaSecp256k1 {
std::vector<Circuit::FunctionInput> public_key_x;
std::vector<Circuit::FunctionInput> public_key_y;
Expand Down Expand Up @@ -185,7 +176,6 @@ struct BlackBoxFuncCall {
SchnorrVerify,
PedersenCommitment,
PedersenHash,
HashToField128Security,
EcdsaSecp256k1,
EcdsaSecp256r1,
FixedBaseScalarMul,
Expand Down Expand Up @@ -423,15 +413,6 @@ struct BlackBoxOp {
static Keccak256 bincodeDeserialize(std::vector<uint8_t>);
};

struct HashToField128Security {
Circuit::HeapVector message;
Circuit::RegisterIndex output;

friend bool operator==(const HashToField128Security&, const HashToField128Security&);
std::vector<uint8_t> bincodeSerialize() const;
static HashToField128Security bincodeDeserialize(std::vector<uint8_t>);
};

struct EcdsaSecp256k1 {
Circuit::HeapVector hashed_msg;
Circuit::HeapArray public_key_x;
Expand Down Expand Up @@ -501,7 +482,6 @@ struct BlackBoxOp {
std::variant<Sha256,
Blake2s,
Keccak256,
HashToField128Security,
EcdsaSecp256k1,
EcdsaSecp256r1,
SchnorrVerify,
Expand Down Expand Up @@ -2237,60 +2217,6 @@ Circuit::BlackBoxFuncCall::PedersenHash serde::Deserializable<Circuit::BlackBoxF

namespace Circuit {

inline bool operator==(const BlackBoxFuncCall::HashToField128Security& lhs,
const BlackBoxFuncCall::HashToField128Security& rhs)
{
if (!(lhs.inputs == rhs.inputs)) {
return false;
}
if (!(lhs.output == rhs.output)) {
return false;
}
return true;
}

inline std::vector<uint8_t> BlackBoxFuncCall::HashToField128Security::bincodeSerialize() const
{
auto serializer = serde::BincodeSerializer();
serde::Serializable<BlackBoxFuncCall::HashToField128Security>::serialize(*this, serializer);
return std::move(serializer).bytes();
}

inline BlackBoxFuncCall::HashToField128Security BlackBoxFuncCall::HashToField128Security::bincodeDeserialize(
std::vector<uint8_t> input)
{
auto deserializer = serde::BincodeDeserializer(input);
auto value = serde::Deserializable<BlackBoxFuncCall::HashToField128Security>::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 <typename Serializer>
void serde::Serializable<Circuit::BlackBoxFuncCall::HashToField128Security>::serialize(
const Circuit::BlackBoxFuncCall::HashToField128Security& obj, Serializer& serializer)
{
serde::Serializable<decltype(obj.inputs)>::serialize(obj.inputs, serializer);
serde::Serializable<decltype(obj.output)>::serialize(obj.output, serializer);
}

template <>
template <typename Deserializer>
Circuit::BlackBoxFuncCall::HashToField128Security serde::Deserializable<
Circuit::BlackBoxFuncCall::HashToField128Security>::deserialize(Deserializer& deserializer)
{
Circuit::BlackBoxFuncCall::HashToField128Security obj;
obj.inputs = serde::Deserializable<decltype(obj.inputs)>::deserialize(deserializer);
obj.output = serde::Deserializable<decltype(obj.output)>::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)) {
Expand Down Expand Up @@ -2874,59 +2800,6 @@ Circuit::BlackBoxOp::Keccak256 serde::Deserializable<Circuit::BlackBoxOp::Keccak

namespace Circuit {

inline bool operator==(const BlackBoxOp::HashToField128Security& lhs, const BlackBoxOp::HashToField128Security& rhs)
{
if (!(lhs.message == rhs.message)) {
return false;
}
if (!(lhs.output == rhs.output)) {
return false;
}
return true;
}

inline std::vector<uint8_t> BlackBoxOp::HashToField128Security::bincodeSerialize() const
{
auto serializer = serde::BincodeSerializer();
serde::Serializable<BlackBoxOp::HashToField128Security>::serialize(*this, serializer);
return std::move(serializer).bytes();
}

inline BlackBoxOp::HashToField128Security BlackBoxOp::HashToField128Security::bincodeDeserialize(
std::vector<uint8_t> input)
{
auto deserializer = serde::BincodeDeserializer(input);
auto value = serde::Deserializable<BlackBoxOp::HashToField128Security>::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 <typename Serializer>
void serde::Serializable<Circuit::BlackBoxOp::HashToField128Security>::serialize(
const Circuit::BlackBoxOp::HashToField128Security& obj, Serializer& serializer)
{
serde::Serializable<decltype(obj.message)>::serialize(obj.message, serializer);
serde::Serializable<decltype(obj.output)>::serialize(obj.output, serializer);
}

template <>
template <typename Deserializer>
Circuit::BlackBoxOp::HashToField128Security serde::Deserializable<
Circuit::BlackBoxOp::HashToField128Security>::deserialize(Deserializer& deserializer)
{
Circuit::BlackBoxOp::HashToField128Security obj;
obj.message = serde::Deserializable<decltype(obj.message)>::deserialize(deserializer);
obj.output = serde::Deserializable<decltype(obj.output)>::deserialize(deserializer);
return obj;
}

namespace Circuit {

inline bool operator==(const BlackBoxOp::EcdsaSecp256k1& lhs, const BlackBoxOp::EcdsaSecp256k1& rhs)
{
if (!(lhs.hashed_msg == rhs.hashed_msg)) {
Expand Down
Loading