Trait diem_crypto::traits::SigningKey
source · pub trait SigningKey: PrivateKey<PublicKeyMaterial = Self::VerifyingKeyMaterial> + ValidCryptoMaterial + Sealed {
type VerifyingKeyMaterial: VerifyingKey<SigningKeyMaterial = Self>;
type SignatureMaterial: Signature<SigningKeyMaterial = Self>;
// Required methods
fn sign<T: CryptoHash + Serialize>(
&self,
message: &T
) -> Self::SignatureMaterial;
fn sign_arbitrary_message(&self, message: &[u8]) -> Self::SignatureMaterial;
// Provided method
fn verifying_key(&self) -> Self::VerifyingKeyMaterial { ... }
}
Expand description
A type family of valid keys that know how to sign.
This trait has a requirement on a pub(crate)
marker trait meant to
specifically limit its implementations to the present crate.
A trait for a ValidCryptoMaterial
which knows how to sign a
message, and return an associated Signature
type.
Required Associated Types§
sourcetype VerifyingKeyMaterial: VerifyingKey<SigningKeyMaterial = Self>
type VerifyingKeyMaterial: VerifyingKey<SigningKeyMaterial = Self>
The associated verifying key type for this signing key.
sourcetype SignatureMaterial: Signature<SigningKeyMaterial = Self>
type SignatureMaterial: Signature<SigningKeyMaterial = Self>
The associated signature type for this signing key.
Required Methods§
sourcefn sign<T: CryptoHash + Serialize>(&self, message: &T) -> Self::SignatureMaterial
fn sign<T: CryptoHash + Serialize>(&self, message: &T) -> Self::SignatureMaterial
Signs an object that has an distinct domain-separation hasher and
that we know how to serialize. There is no pre-hashing into a
HashValue
to be done by the caller.
Note: this assumes serialization is unfaillible. See diem_common::bcs::ser for a discussion of this assumption.
sourcefn sign_arbitrary_message(&self, message: &[u8]) -> Self::SignatureMaterial
fn sign_arbitrary_message(&self, message: &[u8]) -> Self::SignatureMaterial
Signs a non-hash input message. For testing only.
Provided Methods§
sourcefn verifying_key(&self) -> Self::VerifyingKeyMaterial
fn verifying_key(&self) -> Self::VerifyingKeyMaterial
Returns the associated verifying key