pub struct Keypair {
pub secret: SecretKey,
pub public: PublicKey,
}
Expand description
An WOTS keypair.
Fields§
§secret: SecretKey
The secret half of this keypair.
public: PublicKey
The public half of this keypair.
Implementations§
Source§impl Keypair
impl Keypair
Sourcepub fn sign(&self, message: &[u8]) -> Signature
pub fn sign(&self, message: &[u8]) -> Signature
Sign a message
with this Keypair
using the
WOTS algorithm.
§Inputs
message
in bytes representation.
§Returns
An WOTS Signature
on the message
.
§Example
use rand::rngs::OsRng;
use wots_rs::Keypair;
let mut csprng = OsRng{};
let keypair: Keypair = Keypair::generate(&mut csprng);
let message = b"hello";
let signature = keypair.sign(message);
Sourcepub fn verify(&self, message: &[u8], signature: Signature) -> bool
pub fn verify(&self, message: &[u8], signature: Signature) -> bool
Verify a signature
on a message
using the WOTS algorithm.
§Inputs
message
in bytes representation.signature
is a purported WOTSSignature
on themessage
.
§Returns
Returns true
if the signature
was a valid signature created by this
Keypair
on the message
.
§Example
use rand::rngs::OsRng;
use wots_rs::Keypair;
let mut csprng = OsRng{};
let keypair: Keypair = Keypair::generate(&mut csprng);
let message = b"hello";
let signature = keypair.sign(message);
assert!(keypair.verify(message, signature));
Auto Trait Implementations§
impl Freeze for Keypair
impl RefUnwindSafe for Keypair
impl Send for Keypair
impl Sync for Keypair
impl Unpin for Keypair
impl UnwindSafe for Keypair
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more