Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
witness_constant.cpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
9
10namespace acir_format {
11
12using namespace bb;
13using namespace bb::stdlib;
14template <typename Builder, typename FF>
16 const WitnessOrConstant<FF>& input_y,
17 const WitnessOrConstant<FF>& input_infinite,
18 bool has_valid_witness_assignments,
20{
22 auto point_x = to_field_ct(input_x, builder);
23 auto point_y = to_field_ct(input_y, builder);
24 auto infinite = bool_ct(to_field_ct(input_infinite, builder));
25
26 // When we do not have the witness assignments, we set is_infinite value to true if it is not constant
27 // else default values would give a point which is not on the curve and this will fail verification
28 if (!has_valid_witness_assignments) {
29 if (!input_infinite.is_constant) {
30 builder.set_variable(input_infinite.index, fr(1));
31 } else if (input_infinite.value == fr::zero() && !(input_x.is_constant || input_y.is_constant)) {
32 // else, if is_infinite is false, but the coordinates (x, y) are witness (and not constant)
33 // then we set their value to an arbitrary valid curve point (in our case G1).
35 builder.set_variable(input_x.index, g1.x);
36 builder.set_variable(input_y.index, g1.y);
37 }
38 }
39 cycle_group<Builder> input_point(point_x, point_y, infinite);
40 return input_point;
41}
42
44 const WitnessOrConstant<fr>& input_y,
45 const WitnessOrConstant<fr>& input_infinite,
46 bool has_valid_witness_assignments,
49 const WitnessOrConstant<fr>& input_y,
50 const WitnessOrConstant<fr>& input_infinite,
51 bool has_valid_witness_assignments,
53
54} // namespace acir_format
group class. Represents an elliptic curve group element. Group is parametrised by Fq and Fr
Definition group.hpp:36
static constexpr affine_element affine_one
Definition group.hpp:48
Implements boolean logic in-circuit.
Definition bool.hpp:59
cycle_group represents a group Element of the proving system's embedded curve i.e....
AluTraceBuilder builder
Definition alu.test.cpp:123
stdlib::bool_t< Builder > bool_ct
bb::stdlib::field_t< Builder > to_field_ct(const WitnessOrConstant< FF > &input, Builder &builder)
bb::stdlib::cycle_group< Builder > to_grumpkin_point(const WitnessOrConstant< FF > &input_x, const WitnessOrConstant< FF > &input_y, const WitnessOrConstant< FF > &input_infinite, bool has_valid_witness_assignments, Builder &builder)
Entry point for Barretenberg command-line interface.
static constexpr field zero()