Skip to content
Merged
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
21 changes: 16 additions & 5 deletions ecdsa/src/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ where
&self.secret_scalar
}

/// Get the [`VerifyingKey`] which corresponds to this [`SigningKey`]
// TODO(tarcieri): make this return `&VerifyingKey<C>` in the next breaking release
/// Get the [`VerifyingKey`] which corresponds to this [`SigningKey`].
#[cfg(feature = "verify")]
#[cfg_attr(docsrs, doc(cfg(feature = "verify")))]
pub fn verifying_key(&self) -> VerifyingKey<C> {
self.verifying_key
pub fn verifying_key(&self) -> &VerifyingKey<C> {
&self.verifying_key
}
}

Expand Down Expand Up @@ -350,6 +349,18 @@ where
}
}

#[cfg(feature = "verify")]
impl<C> From<SigningKey<C>> for VerifyingKey<C>
where
C: PrimeCurve + ProjectiveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + Reduce<C::UInt> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
{
fn from(signing_key: SigningKey<C>) -> VerifyingKey<C> {
signing_key.verifying_key
}
}

#[cfg(feature = "verify")]
impl<C> From<&SigningKey<C>> for VerifyingKey<C>
where
Expand All @@ -358,7 +369,7 @@ where
SignatureSize<C>: ArrayLength<u8>,
{
fn from(signing_key: &SigningKey<C>) -> VerifyingKey<C> {
signing_key.verifying_key()
signing_key.verifying_key
}
}

Expand Down