Merge pull request #243 from pinkforest/fix-signingkey-docs-coverage

Fix `SigningKey` from/to_bytes docs +coverage
This commit is contained in:
Tony Arcieri 2022-12-18 12:51:02 -07:00 committed by GitHub
commit c01cab0d19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,9 +58,6 @@ pub struct SigningKey {
pub(crate) verifying_key: VerifyingKey, pub(crate) verifying_key: VerifyingKey,
} }
impl SigningKey {
/// Construct a [`SigningKey`] from a slice of bytes.
///
/// # Example /// # Example
/// ///
/// ``` /// ```
@ -78,7 +75,8 @@ impl SigningKey {
/// 112, 059, 172, 003, 028, 174, 127, 096, ]; /// 112, 059, 172, 003, 028, 174, 127, 096, ];
/// ///
/// let signing_key: SigningKey = SigningKey::from_bytes(&secret_key_bytes); /// let signing_key: SigningKey = SigningKey::from_bytes(&secret_key_bytes);
/// # /// assert_eq!(signing_key.to_bytes(), secret_key_bytes);
///
/// # Ok(signing_key) /// # Ok(signing_key)
/// # } /// # }
/// # /// #
@ -87,11 +85,9 @@ impl SigningKey {
/// # assert!(result.is_ok()); /// # assert!(result.is_ok());
/// # } /// # }
/// ``` /// ```
impl SigningKey {
/// Construct a [`SigningKey`] from a [`SecretKey`]
/// ///
/// # Returns
///
/// A `Result` whose okay value is an EdDSA `SecretKey` or whose error value
/// is an `SignatureError` wrapping the internal error that occurred.
#[inline] #[inline]
pub fn from_bytes(secret_key: &SecretKey) -> Self { pub fn from_bytes(secret_key: &SecretKey) -> Self {
let verifying_key = VerifyingKey::from(&ExpandedSecretKey::from(secret_key)); let verifying_key = VerifyingKey::from(&ExpandedSecretKey::from(secret_key));
@ -101,7 +97,7 @@ impl SigningKey {
} }
} }
/// Convert this secret key to a byte array. /// Convert this [`SigningKey`] into a [`SecretKey`]
#[inline] #[inline]
pub fn to_bytes(&self) -> SecretKey { pub fn to_bytes(&self) -> SecretKey {
self.secret_key self.secret_key