Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,8 @@ impl<'f> Context<'f> {
call_stack: CallStackId,
) -> (ValueId, ValueId) {
let index = !abscissa as usize;
if inputs[3 + index] == inputs[index] {
if inputs[3] == inputs[0] && inputs[4] == inputs[1] {
// Point doubling
let predicated_value =
self.var_or(inputs[index], condition, generators[index], call_stack);
(predicated_value, predicated_value)
Expand Down
54 changes: 53 additions & 1 deletion test_programs/execution_success/embedded_curve_ops/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ops::Add;
use std::{embedded_curve_ops::embedded_curve_add_unsafe, ops::Add};

fn main(priv_key: Field, pub_x: pub Field, pub_y: pub Field) {
let g1 = std::embedded_curve_ops::EmbeddedCurvePoint::generator();
Expand Down Expand Up @@ -39,4 +39,56 @@ fn main(priv_key: Field, pub_x: pub Field, pub_y: pub Field) {
[scalar, const_zero, scalar],
);
assert(partial_mul == g1);

// Additional tests for validating embedded_curve_add_unsafe under a conditional
if pub_x == pub_y {
let a1 = std::embedded_curve_ops::EmbeddedCurvePoint { x: 1, y: 2, is_infinite: false };
let a2 = std::embedded_curve_ops::EmbeddedCurvePoint { x: 1, y: 3, is_infinite: false };
let doubling = a1.double();
assert(doubling.x == 1);
let res = embedded_curve_add_unsafe(a1, a2);
assert(res.x == 1);

let a1 = std::embedded_curve_ops::EmbeddedCurvePoint {
x: pub_x + 1,
y: pub_y,
is_infinite: false,
};
let a2 = std::embedded_curve_ops::EmbeddedCurvePoint {
x: pub_x + 1,
y: pub_y + 1,
is_infinite: false,
};
let doubling = a1.double();
assert(doubling.x == 1);
let res = embedded_curve_add_unsafe(a1, a2);
assert(res.x == 1);

let a1 = std::embedded_curve_ops::EmbeddedCurvePoint { x: 2, y: 3, is_infinite: false };
let a2 = std::embedded_curve_ops::EmbeddedCurvePoint {
x: pub_x,
y: pub_y + 1 as Field,
is_infinite: false,
};
let res = embedded_curve_add_unsafe(a1, a2);
assert(res.x == 1);

let a1 = std::embedded_curve_ops::EmbeddedCurvePoint { x: 2, y: 3, is_infinite: false };
let a2 = std::embedded_curve_ops::EmbeddedCurvePoint { x: 2, y: 4, is_infinite: false };
let res = embedded_curve_add_unsafe(a1, a2);
assert(res.x == 1);

let a1 = std::embedded_curve_ops::EmbeddedCurvePoint { x: 2, y: 3, is_infinite: false };
let a2 = std::embedded_curve_ops::EmbeddedCurvePoint { x: 2, y: 3, is_infinite: false };
let res = embedded_curve_add_unsafe(a1, a2);
assert(res.x == 1);
let a1 = std::embedded_curve_ops::EmbeddedCurvePoint { x: 1, y: 3, is_infinite: false };
let a2 = std::embedded_curve_ops::EmbeddedCurvePoint { x: 1, y: 3, is_infinite: false };
let res = embedded_curve_add_unsafe(a1, a2);
assert(res.x == 1);
let a1 = std::embedded_curve_ops::EmbeddedCurvePoint { x: pub_x, y: 3, is_infinite: false };
let a2 = std::embedded_curve_ops::EmbeddedCurvePoint { x: pub_x, y: 2, is_infinite: false };
let res = embedded_curve_add_unsafe(a1, a2);
assert(res.x == 1);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading