pub struct SignKeypair { /* private fields */ }
Expand description
Signing key (certificate).
Implementations§
Source§impl SignKeypair
impl SignKeypair
Sourcepub fn new_ed25519() -> Result<SignKeypair, ServerError>
pub fn new_ed25519() -> Result<SignKeypair, ServerError>
Generates Ed25519 keypair for signing usage.
Store your private key safely!
Sourcepub fn pack_keypair(&self) -> String
pub fn pack_keypair(&self) -> String
Packs keypair to string.
Sourcepub fn unpack_keypair(
keypair: impl AsRef<str>,
) -> Result<SignKeypair, ServerError>
pub fn unpack_keypair( keypair: impl AsRef<str>, ) -> Result<SignKeypair, ServerError>
Unpacks keypair from a string.
Sourcepub fn verify_raw(
data: &[u8],
sign: &[u8],
public_key: &[u8],
) -> Result<(), ServerError>
pub fn verify_raw( data: &[u8], sign: &[u8], public_key: &[u8], ) -> Result<(), ServerError>
Verifies data by its signature and provided public key.
Sourcepub fn sign<T>(&self, data: &T) -> Result<Vec<u8>, ServerError>where
T: Serialize,
pub fn sign<T>(&self, data: &T) -> Result<Vec<u8>, ServerError>where
T: Serialize,
Packs T
into MessagePack and signs its bytes.
Sourcepub fn verify<T>(
data: &T,
sign: &[u8],
public_key: &[u8],
) -> Result<(), ServerError>where
T: Serialize,
pub fn verify<T>(
data: &T,
sign: &[u8],
public_key: &[u8],
) -> Result<(), ServerError>where
T: Serialize,
Verifies any serializable T
by its MessagePack view’s signature and provided public key.
Sourcepub fn verify_token(
header: &[u8],
payload: &[u8],
sign: &[u8],
public_key: &[u8],
) -> Result<(), ServerError>
pub fn verify_token( header: &[u8], payload: &[u8], sign: &[u8], public_key: &[u8], ) -> Result<(), ServerError>
Verifies header and payload by their signature and provided public key.
Trait Implementations§
Source§impl Clone for SignKeypair
impl Clone for SignKeypair
Source§fn clone(&self) -> SignKeypair
fn clone(&self) -> SignKeypair
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for SignKeypair
impl RefUnwindSafe for SignKeypair
impl Send for SignKeypair
impl Sync for SignKeypair
impl Unpin for SignKeypair
impl UnwindSafe for SignKeypair
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