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
8 changes: 7 additions & 1 deletion noir_stdlib/src/embedded_curve_ops.nr
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,13 @@ pub fn embedded_curve_add(
) -> EmbeddedCurvePoint {
// docs:end:embedded_curve_add
if crate::runtime::is_unconstrained() {
embedded_curve_add_unsafe(point1, point2)
if point1.is_infinite {
point2
} else if point2.is_infinite {
point1
} else {
embedded_curve_add_unsafe(point1, point2)
}
} else {
// In a constrained context we need to do some black magic in order to satisfy the backend's
// expectations about the inputs to an `embedded_curve_add` opcode.
Expand Down
8 changes: 4 additions & 4 deletions test_programs/execution_success/multi_scalar_mul/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This test provides a basic implementation of a MSM in Noir, that allows us to check
// performance improvements and regressions.
use std::embedded_curve_ops::embedded_curve_add_unsafe;
use std::embedded_curve_ops::embedded_curve_add;
use std::embedded_curve_ops::EmbeddedCurvePoint;

// `main` must be marked unconstrained as the function uses `break` internally
Expand Down Expand Up @@ -40,14 +40,14 @@ unconstrained fn double_then_add_msm<let N: u32>(
// traversing from second MSB to LSB
for j in (index_of_msb + 1)..(254) {
// Double
res = embedded_curve_add_unsafe(res, res);
res = embedded_curve_add(res, res);
// Add
if full_scalar_bits[j] == 1 {
res = embedded_curve_add_unsafe(res, temp);
res = embedded_curve_add(res, temp);
}
}

acc = embedded_curve_add_unsafe(acc, res);
acc = embedded_curve_add(acc, res);
}
acc
}
Loading