pub fn calculate_signature(
ctx: &Context,
private: &PrivateKey,
message: &[u8],
) -> Result<Buffer, Error>
Expand description
Calculate the signature for a message.
ยงExamples
This is the counterpart to PublicKey::verify_signature
.
// the `Crypto` here is a type alias to one of `OpenSSLCrypto` or `DefaultCrypto`.
let ctx = Context::new(Crypto::default()).unwrap();
let key_pair = libsignal_protocol::generate_key_pair(&ctx)?;
let msg = "Hello, World!";
let private_key = key_pair.private();
let signature = libsignal_protocol::calculate_signature(
&ctx,
&private_key,
msg.as_bytes(),
)?;
let public = key_pair.public();
let got = public.verify_signature(msg.as_bytes(), signature.as_slice());
assert!(got.is_ok());