Skip to content

Commit 3e9bba3

Browse files
committed
EC_POINT_is_at_infinity
1 parent 53f5b0d commit 3e9bba3

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

boring/src/ec.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,31 @@ impl EcPointRef {
452452
}
453453
}
454454

455+
/// Returns `true` if `self` is the point at infinity and `false` otherwise.
456+
#[corresponds(EC_POINT_is_at_infinity)]
457+
#[must_use]
458+
pub fn is_infinity(&self, group: &EcGroupRef) -> bool {
459+
unsafe { ffi::EC_POINT_is_at_infinity(group.as_ptr(), self.as_ptr()) == 1 }
460+
}
461+
462+
/// Returns `Ok(true)` if `self` is an element of `group` and `Ok(false)` otherwise.
463+
/// `ctx` is ignored. This method exists for rust-openssl interoperability.
464+
#[corresponds(EC_POINT_is_on_curve)]
465+
#[doc(hidden)]
466+
pub fn is_on_curve(
467+
&self,
468+
group: &EcGroupRef,
469+
ctx: &mut BigNumContextRef,
470+
) -> Result<bool, ErrorStack> {
471+
unsafe {
472+
let res = cvt_n(ffi::EC_POINT_is_on_curve(
473+
group.as_ptr(),
474+
self.as_ptr(),
475+
ctx.as_ptr(),
476+
))?;
477+
Ok(res == 1)
478+
}
479+
}
455480
}
456481

457482
impl EcPoint {

0 commit comments

Comments
 (0)