pub trait Signer:
Specification
+ Clone
+ Send
+ Sync
+ 'static {
type PrivateKey: Array;
// Required methods
fn new<R: Rng + CryptoRng>(rng: &mut R) -> Self;
fn sign(
&mut self,
namespace: Option<&[u8]>,
message: &[u8],
) -> Self::Signature;
fn from(private_key: Self::PrivateKey) -> Option<Self>;
fn private_key(&self) -> Self::PrivateKey;
fn public_key(&self) -> Self::PublicKey;
// Provided method
fn from_seed(seed: u64) -> Self { ... }
}
Expand description
Implementation that can sign a message with a PrivateKey
.
Required Associated Types§
Sourcetype PrivateKey: Array
type PrivateKey: Array
Private key used for signing.
Required Methods§
Sourcefn sign(&mut self, namespace: Option<&[u8]>, message: &[u8]) -> Self::Signature
fn sign(&mut self, namespace: Option<&[u8]>, message: &[u8]) -> Self::Signature
Sign the given message.
The message should not be hashed prior to calling this function. If a particular scheme requires a payload to be hashed before it is signed, it will be done internally.
A namespace should be used to prevent replay attacks. It will be prepended to the message so that a signature meant for one context cannot be used unexpectedly in another (i.e. signing a message on the network layer can’t accidentally spend funds on the execution layer). See union_unique for details.
Sourcefn from(private_key: Self::PrivateKey) -> Option<Self>
fn from(private_key: Self::PrivateKey) -> Option<Self>
Returns a new instance of the scheme from a secret key.
Sourcefn private_key(&self) -> Self::PrivateKey
fn private_key(&self) -> Self::PrivateKey
Returns the private key of the signer.
Sourcefn public_key(&self) -> Self::PublicKey
fn public_key(&self) -> Self::PublicKey
Returns the public key of the signer.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.