use crate::prelude::*;
pub fn sign<K, D>(key: K, data: D) -> ExternResult<Signature>
where
K: Into<AgentPubKey>,
D: serde::Serialize + std::fmt::Debug,
{
host_call::<Sign, Signature>(__sign, Sign::new(key.into(), data)?)
}
pub fn sign_raw<K>(key: K, data: Vec<u8>) -> ExternResult<Signature>
where
K: Into<AgentPubKey>,
{
host_call::<Sign, Signature>(__sign, Sign::new_raw(key.into(), data))
}
pub fn verify_signature<K, S, D>(key: K, signature: S, data: D) -> ExternResult<bool>
where
K: Into<AgentPubKey>,
S: Into<Signature>,
D: serde::Serialize + std::fmt::Debug,
{
host_call::<VerifySignature, bool>(
__verify_signature,
VerifySignature::new(key.into(), signature.into(), data)?,
)
}
pub fn verify_signature_raw<K, S>(key: K, signature: S, data: Vec<u8>) -> ExternResult<bool>
where
K: Into<AgentPubKey>,
S: Into<Signature>,
{
host_call::<VerifySignature, bool>(
__verify_signature,
VerifySignature::new_raw(key.into(), signature.into(), data),
)
}