Split EcKey::mul

This commit is contained in:
Steven Fackler 2016-11-14 22:08:04 +01:00
parent e929e09216
commit 90acfaea51
1 changed files with 22 additions and 6 deletions

View File

@ -126,20 +126,36 @@ impl EcPointRef {
}
}
/// Computes `generator * n + q * m`, storing the result in `self`.
///
/// If `n` is `None`, `q * m` will be computed instead.
/// Computes `q * m`, storing the result in `self`.
pub fn mul(&mut self,
group: &EcGroupRef,
n: Option<&BigNumRef>,
q: &EcPointRef,
m: &BigNumRef,
ctx: &mut BigNumContextRef)
ctx: &BigNumContextRef)
-> Result<(), ErrorStack> {
unsafe {
cvt(ffi::EC_POINT_mul(group.as_ptr(),
self.as_ptr(),
n.map_or(ptr::null(), |n| n.as_ptr()),
ptr::null(),
q.as_ptr(),
m.as_ptr(),
ctx.as_ptr()))
.map(|_| ())
}
}
/// Computes `generator * n + q * m`, storing the result in `self`.
pub fn mul_generator(&mut self,
group: &EcGroupRef,
n: &BigNumRef,
q: &EcPointRef,
m: &BigNumRef,
ctx: &mut BigNumContextRef)
-> Result<(), ErrorStack> {
unsafe {
cvt(ffi::EC_POINT_mul(group.as_ptr(),
self.as_ptr(),
n.as_ptr(),
q.as_ptr(),
m.as_ptr(),
ctx.as_ptr()))