Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ecdsa_constraints.hpp
Go to the documentation of this file.
1
// === AUDIT STATUS ===
2
// internal: { status: completed, auditors: [Federico], date: 2025-10-24 }
3
// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4
// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5
// =====================
6
7
#pragma once
8
#include "
barretenberg/crypto/ecdsa/ecdsa.hpp
"
9
#include "
barretenberg/dsl/acir_format/witness_constant.hpp
"
10
#include "
barretenberg/serialize/msgpack.hpp
"
11
#include "
barretenberg/stdlib/primitives/byte_array/byte_array.hpp
"
12
#include <vector>
13
14
namespace
acir_format
{
15
16
using namespace
bb
;
17
40
struct
EcdsaConstraint
{
41
bb::CurveType
type
;
42
43
// The byte representation of the hashed message.
44
std::array<uint32_t, 32>
hashed_message
;
45
46
// The signature
47
std::array<uint32_t, 64>
signature
;
48
49
// The public key against which the signature must be verified.
50
// Since Fr does not have enough bits to represent the prime field in
51
// secp256k1 or secp256r1, a byte array is used.
52
std::array<uint32_t, 32>
pub_x_indices
;
53
std::array<uint32_t, 32>
pub_y_indices
;
54
55
// Predicate indicating whether the constraint should be disabled:
56
// - true: the constraint is valid
57
// - false: the constraint is disabled, i.e it must not fail and can return whatever.
58
WitnessOrConstant<bb::fr>
predicate
;
59
60
// Expected result of signature verification
61
uint32_t
result
;
62
63
// For serialization, update with any new fields
64
MSGPACK_FIELDS
(
hashed_message
,
signature
,
pub_x_indices
,
pub_y_indices
,
predicate
,
result
);
65
friend
bool
operator==
(
EcdsaConstraint
const
& lhs,
EcdsaConstraint
const
& rhs) =
default
;
66
};
67
68
template
<
typename
Curve>
69
void
create_ecdsa_verify_constraints
(
typename
Curve::Builder&
builder
,
const
EcdsaConstraint
& input);
70
71
template
<
typename
Curve>
72
void
create_dummy_ecdsa_constraint
(
typename
Curve::Builder&
builder
,
73
const
std::vector<
stdlib::field_t<typename Curve::Builder>
>& hashed_message_fields,
74
const
std::vector<
stdlib::field_t<typename Curve::Builder>
>& r_fields,
75
const
std::vector<
stdlib::field_t<typename Curve::Builder>
>& s_fields,
76
const
std::vector<
stdlib::field_t<typename Curve::Builder>
>& pub_x_fields,
77
const
std::vector<
stdlib::field_t<typename Curve::Builder>
>& pub_y_fields,
78
const
stdlib::field_t<typename Curve::Builder>
& result_field);
79
80
}
// namespace acir_format
byte_array.hpp
bb::stdlib::field_t
Definition
field.hpp:45
builder
AluTraceBuilder builder
Definition
alu.test.cpp:124
ecdsa.hpp
msgpack.hpp
acir_format
Definition
acir_format.cpp:31
acir_format::create_ecdsa_verify_constraints
void create_ecdsa_verify_constraints(typename Curve::Builder &builder, const EcdsaConstraint &input)
Create constraints to verify an ECDSA signature.
Definition
ecdsa_constraints.cpp:41
acir_format::create_dummy_ecdsa_constraint
void create_dummy_ecdsa_constraint(typename Curve::Builder &builder, const std::vector< stdlib::field_t< typename Curve::Builder > > &hashed_message_fields, const std::vector< stdlib::field_t< typename Curve::Builder > > &r_fields, const std::vector< stdlib::field_t< typename Curve::Builder > > &s_fields, const std::vector< stdlib::field_t< typename Curve::Builder > > &pub_x_fields, const std::vector< stdlib::field_t< typename Curve::Builder > > &pub_y_fields, const stdlib::field_t< typename Curve::Builder > &result_field)
Generate dummy ECDSA constraints when the builder doesn't have witnesses.
Definition
ecdsa_constraints.cpp:127
bb
Entry point for Barretenberg command-line interface.
Definition
api.hpp:5
bb::CurveType
CurveType
Definition
types.hpp:10
acir_format::EcdsaConstraint
ECDSA constraints.
Definition
ecdsa_constraints.hpp:40
acir_format::EcdsaConstraint::MSGPACK_FIELDS
MSGPACK_FIELDS(hashed_message, signature, pub_x_indices, pub_y_indices, predicate, result)
acir_format::EcdsaConstraint::pub_x_indices
std::array< uint32_t, 32 > pub_x_indices
Definition
ecdsa_constraints.hpp:52
acir_format::EcdsaConstraint::type
bb::CurveType type
Definition
ecdsa_constraints.hpp:41
acir_format::EcdsaConstraint::hashed_message
std::array< uint32_t, 32 > hashed_message
Definition
ecdsa_constraints.hpp:44
acir_format::EcdsaConstraint::result
uint32_t result
Definition
ecdsa_constraints.hpp:61
acir_format::EcdsaConstraint::operator==
friend bool operator==(EcdsaConstraint const &lhs, EcdsaConstraint const &rhs)=default
acir_format::EcdsaConstraint::predicate
WitnessOrConstant< bb::fr > predicate
Definition
ecdsa_constraints.hpp:58
acir_format::EcdsaConstraint::signature
std::array< uint32_t, 64 > signature
Definition
ecdsa_constraints.hpp:47
acir_format::EcdsaConstraint::pub_y_indices
std::array< uint32_t, 32 > pub_y_indices
Definition
ecdsa_constraints.hpp:53
acir_format::WitnessOrConstant
Definition
witness_constant.hpp:13
witness_constant.hpp
src
barretenberg
dsl
acir_format
ecdsa_constraints.hpp
Generated by
1.9.8