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

feat!: add is_infinite to curve addition opcode #6384

Merged
merged 47 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e19e07c
Add is_infinite to curve addition opcode
guipublic May 14, 2024
7cabf86
Merge branch 'master' into gd/noir_issue_4978
guipublic May 14, 2024
f3192b2
fix build
guipublic May 14, 2024
92600e0
nargo fmt
guipublic May 14, 2024
242d91b
cargo format
guipublic May 14, 2024
11a0ebf
Merge branch 'master' into gd/noir_issue_4978
guipublic May 14, 2024
33625c5
update serialisation
guipublic May 14, 2024
f6300ad
Merge branch 'master' into gd/noir_issue_4978
guipublic May 14, 2024
e72cd1d
fix build
guipublic May 14, 2024
4121187
fix build (2)
guipublic May 14, 2024
0ea6ff2
Merge branch 'master' into gd/noir_issue_4978
guipublic May 14, 2024
59b58cc
use proper constructor for bool_t
guipublic May 14, 2024
7fdad1d
Merge branch 'master' into gd/noir_issue_4978
guipublic May 14, 2024
91ff542
revert to .yarn master
guipublic May 14, 2024
02ef713
Merge branch 'master' into gd/noir_issue_4978
guipublic May 14, 2024
c038a5e
Merge branch 'master' into gd/noir_issue_4978
guipublic May 14, 2024
7756155
Merge branch 'master' into gd/noir_issue_4978
guipublic May 15, 2024
6d9be9b
Merge branch 'master' into gd/noir_issue_4978
guipublic May 15, 2024
19aa50d
Merge branch 'master' into gd/noir_issue_4978
guipublic May 15, 2024
8b1bb52
code review
guipublic May 15, 2024
4a6e305
support point at infinity for scalar mul opcode
guipublic May 16, 2024
52d6d8a
Merge branch 'master' into gd/noir_issue_4978
guipublic May 16, 2024
ae8b846
format
guipublic May 16, 2024
ce78853
Merge branch 'master' into gd/noir_issue_4978
guipublic May 16, 2024
fd8e015
nargo fmt
guipublic May 16, 2024
9d9b203
update noir project
guipublic May 16, 2024
a83d446
fix aztec-nr update
guipublic May 16, 2024
492aad5
Merge branch 'master' into gd/noir_issue_4978
guipublic May 16, 2024
0984b87
nargo fmt
guipublic May 16, 2024
48f88c9
nargo fmt
guipublic May 16, 2024
65fafa3
update serialisation test
guipublic May 16, 2024
f608ad8
update serialisation tests
guipublic May 16, 2024
b521e0f
Merge branch 'master' into gd/noir_issue_4978
guipublic May 16, 2024
b669b00
fix unit test
guipublic May 16, 2024
7131fb9
try to fix serialisation test
guipublic May 16, 2024
6f3bef8
Merge branch 'master' into gd/noir_issue_4978
guipublic May 16, 2024
bb9c575
fix msm and adds a unit test
guipublic May 17, 2024
22ee9da
Merge branch 'master' into gd/noir_issue_4978
guipublic May 17, 2024
9de9e50
add unit tests
guipublic May 17, 2024
eb67a8b
add Eq trait to embeddedCurvePoint
guipublic May 17, 2024
24be6dc
Add struct for scalars
guipublic May 17, 2024
501c9bd
Merge branch 'master' into gd/noir_issue_4978
guipublic May 17, 2024
db6b940
update serialisation
guipublic May 17, 2024
538411e
update aztec.nr
guipublic May 17, 2024
6ad818d
nargo fmt
guipublic May 17, 2024
01a53c6
Move test out-of std_lib
guipublic May 17, 2024
e72255a
Merge branch 'master' into gd/noir_issue_4978
guipublic May 17, 2024
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 @@ -345,12 +345,15 @@ void handle_blackbox_func_call(Program::Opcode::BlackBoxFuncCall const& arg, Aci
});
} else if constexpr (std::is_same_v<T, Program::BlackBoxFuncCall::EmbeddedCurveAdd>) {
af.ec_add_constraints.push_back(EcAdd{
.input1_x = arg.input1_x.witness.value,
.input1_y = arg.input1_y.witness.value,
.input2_x = arg.input2_x.witness.value,
.input2_y = arg.input2_y.witness.value,
.input1_x = arg.input1[0].witness.value,
.input1_y = arg.input1[1].witness.value,
.input1_infinite = arg.input1[2].witness.value,
.input2_x = arg.input2[0].witness.value,
.input2_y = arg.input2[1].witness.value,
.input2_infinite = arg.input2[2].witness.value,
.result_x = arg.outputs[0].value,
.result_y = arg.outputs[1].value,
.result_infinite = arg.outputs[2].value,
});
} else if constexpr (std::is_same_v<T, Program::BlackBoxFuncCall::Keccak256>) {
af.keccak_constraints.push_back(KeccakConstraint{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,35 @@ void create_ec_add_constraint(Builder& builder, const EcAdd& input, bool has_val
// Input to cycle_group points
using cycle_group_ct = bb::stdlib::cycle_group<Builder>;
using field_ct = bb::stdlib::field_t<Builder>;
using bool_ct = bb::stdlib::bool_t<Builder>;

auto x1 = field_ct::from_witness_index(&builder, input.input1_x);
auto y1 = field_ct::from_witness_index(&builder, input.input1_y);
auto x2 = field_ct::from_witness_index(&builder, input.input2_x);
auto y2 = field_ct::from_witness_index(&builder, input.input2_y);
auto infinite1 = bool_ct(field_ct::from_witness_index(&builder, input.input1_infinite));
auto infinite2 = bool_ct(field_ct::from_witness_index(&builder, input.input2_infinite));
if (!has_valid_witness_assignments) {
auto g1 = grumpkin::g1::affine_one;
// We need to have correct values representing points on the curve
builder.variables[input.input1_x] = g1.x;
builder.variables[input.input1_y] = g1.y;
builder.variables[input.input1_infinite] = fr(0);
builder.variables[input.input2_x] = g1.x;
builder.variables[input.input2_y] = g1.y;
builder.variables[input.input2_infinite] = fr(0);
}

cycle_group_ct input1_point(x1, y1, false);
cycle_group_ct input2_point(x2, y2, false);

cycle_group_ct input1_point(x1, y1, infinite1);
cycle_group_ct input2_point(x2, y2, infinite2);
// Addition
cycle_group_ct result = input1_point + input2_point;

auto x_normalized = result.x.normalize();
auto y_normalized = result.y.normalize();
auto infinite = result.is_point_at_infinity().normalize();
builder.assert_equal(x_normalized.witness_index, input.result_x);
builder.assert_equal(y_normalized.witness_index, input.result_y);
builder.assert_equal(infinite.witness_index, input.result_infinite);
}

template void create_ec_add_constraint<UltraCircuitBuilder>(UltraCircuitBuilder& builder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ namespace acir_format {
struct EcAdd {
uint32_t input1_x;
uint32_t input1_y;
uint32_t input1_infinite;
uint32_t input2_x;
uint32_t input2_y;
uint32_t input2_infinite;
uint32_t result_x;
uint32_t result_y;
uint32_t result_infinite;

// for serialization, update with any new fields
MSGPACK_FIELDS(input1_x, input1_y, input2_x, input2_y, result_x, result_y);
MSGPACK_FIELDS(
input1_x, input1_y, input1_infinite, input2_x, input2_y, input2_infinite, result_x, result_y, result_infinite);
friend bool operator==(EcAdd const& lhs, EcAdd const& rhs) = default;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ size_t generate_ec_add_constraint(EcAdd& ec_add_constraint, WitnessVector& witne
witness_values.push_back(g1.y);
witness_values.push_back(result.x.get_value());
witness_values.push_back(result.y.get_value());
witness_values.push_back(fr(0));
witness_values.push_back(fr(0));
ec_add_constraint = EcAdd{
.input1_x = 1,
.input1_y = 2,
.input1_infinite = 7,
.input2_x = 3,
.input2_y = 4,
.input2_infinite = 7,
.result_x = 5,
.result_y = 6,
.result_infinite = 8,
};
return witness_values.size();
}
Expand Down
42 changes: 21 additions & 21 deletions barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,9 @@ struct BlackBoxFuncCall {
};

struct EmbeddedCurveAdd {
Program::FunctionInput input1_x;
Program::FunctionInput input1_y;
Program::FunctionInput input2_x;
Program::FunctionInput input2_y;
std::array<Program::Witness, 2> outputs;
std::array<Program::FunctionInput, 3> input1;
std::array<Program::FunctionInput, 3> input2;
std::array<Program::Witness, 3> outputs;

friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&);
std::vector<uint8_t> bincodeSerialize() const;
Expand Down Expand Up @@ -807,8 +805,10 @@ struct BlackBoxOp {
struct EmbeddedCurveAdd {
Program::MemoryAddress input1_x;
Program::MemoryAddress input1_y;
Program::MemoryAddress input1_infinite;
Program::MemoryAddress input2_x;
Program::MemoryAddress input2_y;
Program::MemoryAddress input2_infinite;
Program::HeapArray result;

friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&);
Expand Down Expand Up @@ -3194,16 +3194,10 @@ namespace Program {

inline bool operator==(const BlackBoxFuncCall::EmbeddedCurveAdd& lhs, const BlackBoxFuncCall::EmbeddedCurveAdd& rhs)
{
if (!(lhs.input1_x == rhs.input1_x)) {
return false;
}
if (!(lhs.input1_y == rhs.input1_y)) {
if (!(lhs.input1 == rhs.input1)) {
return false;
}
if (!(lhs.input2_x == rhs.input2_x)) {
return false;
}
if (!(lhs.input2_y == rhs.input2_y)) {
if (!(lhs.input2 == rhs.input2)) {
return false;
}
if (!(lhs.outputs == rhs.outputs)) {
Expand Down Expand Up @@ -3237,10 +3231,8 @@ template <typename Serializer>
void serde::Serializable<Program::BlackBoxFuncCall::EmbeddedCurveAdd>::serialize(
const Program::BlackBoxFuncCall::EmbeddedCurveAdd& obj, Serializer& serializer)
{
serde::Serializable<decltype(obj.input1_x)>::serialize(obj.input1_x, serializer);
serde::Serializable<decltype(obj.input1_y)>::serialize(obj.input1_y, serializer);
serde::Serializable<decltype(obj.input2_x)>::serialize(obj.input2_x, serializer);
serde::Serializable<decltype(obj.input2_y)>::serialize(obj.input2_y, serializer);
serde::Serializable<decltype(obj.input1)>::serialize(obj.input1, serializer);
serde::Serializable<decltype(obj.input2)>::serialize(obj.input2, serializer);
serde::Serializable<decltype(obj.outputs)>::serialize(obj.outputs, serializer);
}

Expand All @@ -3250,10 +3242,8 @@ Program::BlackBoxFuncCall::EmbeddedCurveAdd serde::Deserializable<
Program::BlackBoxFuncCall::EmbeddedCurveAdd>::deserialize(Deserializer& deserializer)
{
Program::BlackBoxFuncCall::EmbeddedCurveAdd obj;
obj.input1_x = serde::Deserializable<decltype(obj.input1_x)>::deserialize(deserializer);
obj.input1_y = serde::Deserializable<decltype(obj.input1_y)>::deserialize(deserializer);
obj.input2_x = serde::Deserializable<decltype(obj.input2_x)>::deserialize(deserializer);
obj.input2_y = serde::Deserializable<decltype(obj.input2_y)>::deserialize(deserializer);
obj.input1 = serde::Deserializable<decltype(obj.input1)>::deserialize(deserializer);
obj.input2 = serde::Deserializable<decltype(obj.input2)>::deserialize(deserializer);
obj.outputs = serde::Deserializable<decltype(obj.outputs)>::deserialize(deserializer);
return obj;
}
Expand Down Expand Up @@ -4638,12 +4628,18 @@ inline bool operator==(const BlackBoxOp::EmbeddedCurveAdd& lhs, const BlackBoxOp
if (!(lhs.input1_y == rhs.input1_y)) {
return false;
}
if (!(lhs.input1_infinite == rhs.input1_infinite)) {
return false;
}
if (!(lhs.input2_x == rhs.input2_x)) {
return false;
}
if (!(lhs.input2_y == rhs.input2_y)) {
return false;
}
if (!(lhs.input2_infinite == rhs.input2_infinite)) {
return false;
}
if (!(lhs.result == rhs.result)) {
return false;
}
Expand Down Expand Up @@ -4676,8 +4672,10 @@ void serde::Serializable<Program::BlackBoxOp::EmbeddedCurveAdd>::serialize(
{
serde::Serializable<decltype(obj.input1_x)>::serialize(obj.input1_x, serializer);
serde::Serializable<decltype(obj.input1_y)>::serialize(obj.input1_y, serializer);
serde::Serializable<decltype(obj.input1_infinite)>::serialize(obj.input1_infinite, serializer);
serde::Serializable<decltype(obj.input2_x)>::serialize(obj.input2_x, serializer);
serde::Serializable<decltype(obj.input2_y)>::serialize(obj.input2_y, serializer);
serde::Serializable<decltype(obj.input2_infinite)>::serialize(obj.input2_infinite, serializer);
serde::Serializable<decltype(obj.result)>::serialize(obj.result, serializer);
}

Expand All @@ -4689,8 +4687,10 @@ Program::BlackBoxOp::EmbeddedCurveAdd serde::Deserializable<Program::BlackBoxOp:
Program::BlackBoxOp::EmbeddedCurveAdd obj;
obj.input1_x = serde::Deserializable<decltype(obj.input1_x)>::deserialize(deserializer);
obj.input1_y = serde::Deserializable<decltype(obj.input1_y)>::deserialize(deserializer);
obj.input1_infinite = serde::Deserializable<decltype(obj.input1_infinite)>::deserialize(deserializer);
obj.input2_x = serde::Deserializable<decltype(obj.input2_x)>::deserialize(deserializer);
obj.input2_y = serde::Deserializable<decltype(obj.input2_y)>::deserialize(deserializer);
obj.input2_infinite = serde::Deserializable<decltype(obj.input2_infinite)>::deserialize(deserializer);
obj.result = serde::Deserializable<decltype(obj.result)>::deserialize(deserializer);
return obj;
}
Expand Down
34 changes: 17 additions & 17 deletions noir/noir-repo/acvm-repo/acir/codegen/acir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,9 @@ namespace Program {
};

struct EmbeddedCurveAdd {
Program::FunctionInput input1_x;
Program::FunctionInput input1_y;
Program::FunctionInput input2_x;
Program::FunctionInput input2_y;
std::array<Program::Witness, 2> outputs;
std::array<Program::FunctionInput, 3> input1;
std::array<Program::FunctionInput, 3> input2;
std::array<Program::Witness, 3> outputs;

friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&);
std::vector<uint8_t> bincodeSerialize() const;
Expand Down Expand Up @@ -782,8 +780,10 @@ namespace Program {
struct EmbeddedCurveAdd {
Program::MemoryAddress input1_x;
Program::MemoryAddress input1_y;
Program::MemoryAddress input1_infinite;
Program::MemoryAddress input2_x;
Program::MemoryAddress input2_y;
Program::MemoryAddress input2_infinite;
Program::HeapArray result;

friend bool operator==(const EmbeddedCurveAdd&, const EmbeddedCurveAdd&);
Expand Down Expand Up @@ -2800,10 +2800,8 @@ Program::BlackBoxFuncCall::MultiScalarMul serde::Deserializable<Program::BlackBo
namespace Program {

inline bool operator==(const BlackBoxFuncCall::EmbeddedCurveAdd &lhs, const BlackBoxFuncCall::EmbeddedCurveAdd &rhs) {
if (!(lhs.input1_x == rhs.input1_x)) { return false; }
if (!(lhs.input1_y == rhs.input1_y)) { return false; }
if (!(lhs.input2_x == rhs.input2_x)) { return false; }
if (!(lhs.input2_y == rhs.input2_y)) { return false; }
if (!(lhs.input1 == rhs.input1)) { return false; }
if (!(lhs.input2 == rhs.input2)) { return false; }
if (!(lhs.outputs == rhs.outputs)) { return false; }
return true;
}
Expand All @@ -2828,21 +2826,17 @@ namespace Program {
template <>
template <typename Serializer>
void serde::Serializable<Program::BlackBoxFuncCall::EmbeddedCurveAdd>::serialize(const Program::BlackBoxFuncCall::EmbeddedCurveAdd &obj, Serializer &serializer) {
serde::Serializable<decltype(obj.input1_x)>::serialize(obj.input1_x, serializer);
serde::Serializable<decltype(obj.input1_y)>::serialize(obj.input1_y, serializer);
serde::Serializable<decltype(obj.input2_x)>::serialize(obj.input2_x, serializer);
serde::Serializable<decltype(obj.input2_y)>::serialize(obj.input2_y, serializer);
serde::Serializable<decltype(obj.input1)>::serialize(obj.input1, serializer);
serde::Serializable<decltype(obj.input2)>::serialize(obj.input2, serializer);
serde::Serializable<decltype(obj.outputs)>::serialize(obj.outputs, serializer);
}

template <>
template <typename Deserializer>
Program::BlackBoxFuncCall::EmbeddedCurveAdd serde::Deserializable<Program::BlackBoxFuncCall::EmbeddedCurveAdd>::deserialize(Deserializer &deserializer) {
Program::BlackBoxFuncCall::EmbeddedCurveAdd obj;
obj.input1_x = serde::Deserializable<decltype(obj.input1_x)>::deserialize(deserializer);
obj.input1_y = serde::Deserializable<decltype(obj.input1_y)>::deserialize(deserializer);
obj.input2_x = serde::Deserializable<decltype(obj.input2_x)>::deserialize(deserializer);
obj.input2_y = serde::Deserializable<decltype(obj.input2_y)>::deserialize(deserializer);
obj.input1 = serde::Deserializable<decltype(obj.input1)>::deserialize(deserializer);
obj.input2 = serde::Deserializable<decltype(obj.input2)>::deserialize(deserializer);
obj.outputs = serde::Deserializable<decltype(obj.outputs)>::deserialize(deserializer);
return obj;
}
Expand Down Expand Up @@ -3909,8 +3903,10 @@ namespace Program {
inline bool operator==(const BlackBoxOp::EmbeddedCurveAdd &lhs, const BlackBoxOp::EmbeddedCurveAdd &rhs) {
if (!(lhs.input1_x == rhs.input1_x)) { return false; }
if (!(lhs.input1_y == rhs.input1_y)) { return false; }
if (!(lhs.input1_infinite == rhs.input1_infinite)) { return false; }
if (!(lhs.input2_x == rhs.input2_x)) { return false; }
if (!(lhs.input2_y == rhs.input2_y)) { return false; }
if (!(lhs.input2_infinite == rhs.input2_infinite)) { return false; }
if (!(lhs.result == rhs.result)) { return false; }
return true;
}
Expand All @@ -3937,8 +3933,10 @@ template <typename Serializer>
void serde::Serializable<Program::BlackBoxOp::EmbeddedCurveAdd>::serialize(const Program::BlackBoxOp::EmbeddedCurveAdd &obj, Serializer &serializer) {
serde::Serializable<decltype(obj.input1_x)>::serialize(obj.input1_x, serializer);
serde::Serializable<decltype(obj.input1_y)>::serialize(obj.input1_y, serializer);
serde::Serializable<decltype(obj.input1_infinite)>::serialize(obj.input1_infinite, serializer);
serde::Serializable<decltype(obj.input2_x)>::serialize(obj.input2_x, serializer);
serde::Serializable<decltype(obj.input2_y)>::serialize(obj.input2_y, serializer);
serde::Serializable<decltype(obj.input2_infinite)>::serialize(obj.input2_infinite, serializer);
serde::Serializable<decltype(obj.result)>::serialize(obj.result, serializer);
}

Expand All @@ -3948,8 +3946,10 @@ Program::BlackBoxOp::EmbeddedCurveAdd serde::Deserializable<Program::BlackBoxOp:
Program::BlackBoxOp::EmbeddedCurveAdd obj;
obj.input1_x = serde::Deserializable<decltype(obj.input1_x)>::deserialize(deserializer);
obj.input1_y = serde::Deserializable<decltype(obj.input1_y)>::deserialize(deserializer);
obj.input1_infinite = serde::Deserializable<decltype(obj.input1_infinite)>::deserialize(deserializer);
obj.input2_x = serde::Deserializable<decltype(obj.input2_x)>::deserialize(deserializer);
obj.input2_y = serde::Deserializable<decltype(obj.input2_y)>::deserialize(deserializer);
obj.input2_infinite = serde::Deserializable<decltype(obj.input2_infinite)>::deserialize(deserializer);
obj.result = serde::Deserializable<decltype(obj.result)>::deserialize(deserializer);
return obj;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,9 @@ pub enum BlackBoxFuncCall {
outputs: (Witness, Witness),
},
EmbeddedCurveAdd {
input1_x: FunctionInput,
input1_y: FunctionInput,
input2_x: FunctionInput,
input2_y: FunctionInput,
outputs: (Witness, Witness),
input1: Box<[FunctionInput; 3]>,
input2: Box<[FunctionInput; 3]>,
outputs: (Witness, Witness, Witness),
},
Keccak256 {
inputs: Vec<FunctionInput>,
Expand Down Expand Up @@ -245,9 +243,9 @@ impl BlackBoxFuncCall {
inputs.extend(scalars.iter().copied());
inputs
}
BlackBoxFuncCall::EmbeddedCurveAdd {
input1_x, input1_y, input2_x, input2_y, ..
} => vec![*input1_x, *input1_y, *input2_x, *input2_y],
BlackBoxFuncCall::EmbeddedCurveAdd { input1, input2, .. } => {
vec![input1[0], input1[1], input2[0], input2[1]]
}
BlackBoxFuncCall::RANGE { input } => vec![*input],
BlackBoxFuncCall::SchnorrVerify {
public_key_x,
Expand Down Expand Up @@ -344,8 +342,10 @@ impl BlackBoxFuncCall {
| BlackBoxFuncCall::PedersenHash { output, .. }
| BlackBoxFuncCall::EcdsaSecp256r1 { output, .. } => vec![*output],
BlackBoxFuncCall::MultiScalarMul { outputs, .. }
| BlackBoxFuncCall::PedersenCommitment { outputs, .. }
| BlackBoxFuncCall::EmbeddedCurveAdd { outputs, .. } => vec![outputs.0, outputs.1],
| BlackBoxFuncCall::PedersenCommitment { outputs, .. } => vec![outputs.0, outputs.1],
BlackBoxFuncCall::EmbeddedCurveAdd { outputs, .. } => {
vec![outputs.0, outputs.1, outputs.2]
}
BlackBoxFuncCall::RANGE { .. }
| BlackBoxFuncCall::RecursiveAggregation { .. }
| BlackBoxFuncCall::BigIntFromLeBytes { .. }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,21 @@ pub(super) fn multi_scalar_mul(
pub(super) fn embedded_curve_add(
backend: &impl BlackBoxFunctionSolver,
initial_witness: &mut WitnessMap,
input1_x: FunctionInput,
input1_y: FunctionInput,
input2_x: FunctionInput,
input2_y: FunctionInput,
outputs: (Witness, Witness),
input1: [FunctionInput; 3],
input2: [FunctionInput; 3],
outputs: (Witness, Witness, Witness),
) -> Result<(), OpcodeResolutionError> {
let input1_x = witness_to_value(initial_witness, input1_x.witness)?;
let input1_y = witness_to_value(initial_witness, input1_y.witness)?;
let input2_x = witness_to_value(initial_witness, input2_x.witness)?;
let input2_y = witness_to_value(initial_witness, input2_y.witness)?;
let (res_x, res_y) = backend.ec_add(input1_x, input1_y, input2_x, input2_y)?;
let input1_x = witness_to_value(initial_witness, input1[0].witness)?;
let input1_y = witness_to_value(initial_witness, input1[1].witness)?;
let input1_infinite = witness_to_value(initial_witness, input1[2].witness)?;
let input2_x = witness_to_value(initial_witness, input2[0].witness)?;
let input2_y = witness_to_value(initial_witness, input2[1].witness)?;
let input2_infinite = witness_to_value(initial_witness, input2[2].witness)?;
let (res_x, res_y, res_infinite) =
backend.ec_add(input1_x, input1_y, input1_infinite, input2_x, input2_y, input2_infinite)?;

insert_value(&outputs.0, res_x, initial_witness)?;
insert_value(&outputs.1, res_y, initial_witness)?;

insert_value(&outputs.2, res_infinite, initial_witness)?;
Ok(())
}
Loading
Loading