Skip to content

Commit f47dc94

Browse files
committed
fix: guard debug pairing point validation against off-curve points in PairingPoints
1 parent cf1a239 commit f47dc94

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

barretenberg/cpp/src/barretenberg/stdlib/primitives/pairing_points.hpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,14 @@ template <typename Curve> struct PairingPoints {
5454
}
5555

5656
#ifndef NDEBUG
57-
bb::PairingPoints<typename Curve::NativeCurve> native_pp(P0().get_value(), P1().get_value());
58-
info("Are Pairing Points with tag ", tag_index, " valid? ", native_pp.check() ? "true" : "false");
57+
auto p0_val = P0().get_value();
58+
auto p1_val = P1().get_value();
59+
if (p0_val.on_curve() && p1_val.on_curve()) {
60+
bb::PairingPoints<typename Curve::NativeCurve> native_pp(p0_val, p1_val);
61+
info("Are Pairing Points with tag ", tag_index, " valid? ", native_pp.check() ? "true" : "false");
62+
} else {
63+
info("Are Pairing Points with tag ", tag_index, " valid? false (point not on curve)");
64+
}
5965
#endif
6066
}
6167

@@ -210,8 +216,15 @@ template <typename Curve> struct PairingPoints {
210216
}
211217

212218
#ifndef NDEBUG
213-
bb::PairingPoints<typename Curve::NativeCurve> native_pp(P0().get_value(), P1().get_value());
214-
info("Are aggregated Pairing Points with tag ", tag_index, " valid? ", native_pp.check() ? "true" : "false");
219+
auto p0_val = P0().get_value();
220+
auto p1_val = P1().get_value();
221+
if (p0_val.on_curve() && p1_val.on_curve()) {
222+
bb::PairingPoints<typename Curve::NativeCurve> native_pp(p0_val, p1_val);
223+
info(
224+
"Are aggregated Pairing Points with tag ", tag_index, " valid? ", native_pp.check() ? "true" : "false");
225+
} else {
226+
info("Are aggregated Pairing Points with tag ", tag_index, " valid? false (point not on curve)");
227+
}
215228
#endif
216229
}
217230

0 commit comments

Comments
 (0)