Struct Crypto

Source
pub struct Crypto {}

Implementations§

Source§

impl Crypto

Source

pub fn sign( wallet_handle: IndyHandle, signer_vk: &str, message: &[u8], ) -> Result<Vec<u8>, ErrorCode>

Signs a message with a key

§Arguments
  • wallet_handle - wallet handle (created by Wallet::open)
  • signer_vk - key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • message - the data to be signed
§Returns

the signature

Source

pub fn sign_timeout( wallet_handle: IndyHandle, signer_vk: &str, message: &[u8], timeout: Duration, ) -> Result<Vec<u8>, ErrorCode>

Signs a message with a key

§Arguments
  • wallet_handle - wallet handle (created by Wallet::open)
  • signer_vk - key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • message - the data to be signed
  • timeout - the maximum time this function waits for a response
§Returns

the signature

Source

pub fn sign_async<F>( wallet_handle: IndyHandle, signer_vk: &str, message: &[u8], closure: F, ) -> ErrorCode
where F: FnMut(ErrorCode, Vec<u8>) + Send + 'static,

Signs a message with a key

§Arguments
  • wallet_handle - wallet handle (created by Wallet::open)
  • signer_vk - key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • message - the data to be signed
  • closure - The closure that is called when finished
§Returns

errorcode from calling ffi function

Source

pub fn verify( signer_vk: &str, message: &[u8], signature: &[u8], ) -> Result<bool, ErrorCode>

Verify a signature with a verkey

§Arguments
  • wallet_handle - wallet handle (created by Wallet::open)
  • signer_vk - key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • message - the data that was signed
  • signature - the signature to verify
§Returns

true if signature is valid, false otherwise

Source

pub fn verify_timeout( signer_vk: &str, message: &[u8], signature: &[u8], timeout: Duration, ) -> Result<bool, ErrorCode>

Verify a signature with a verkey

§Arguments
  • wallet_handle - wallet handle (created by Wallet::open)
  • signer_vk - key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • message - the data that was signed
  • signature - the signature to verify
  • timeout - the maximum time this function waits for a response
§Returns

true if signature is valid, false otherwise

Source

pub fn verify_async<F>( signer_vk: &str, message: &[u8], signature: &[u8], closure: F, ) -> ErrorCode
where F: FnMut(ErrorCode, bool) + Send + 'static,

Verify a signature with a verkey

§Arguments
  • wallet_handle - wallet handle (created by Wallet::open)
  • signer_vk - key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • message - the data that was signed
  • signature - the signature to verify
  • closure - The closure that is called when finished
§Returns

errorcode from calling ffi function

Source

pub fn auth_crypt( wallet_handle: IndyHandle, sender_vk: &str, recipient_vk: &str, message: &[u8], ) -> Result<Vec<u8>, ErrorCode>

Encrypt a message by authenticated-encryption scheme.

Sender can encrypt a confidential message specifically for Recipient, using Sender’s public key. Using Recipient’s public key, Sender can compute a shared secret key. Using Sender’s public key and his secret key, Recipient can compute the exact same shared secret key. That shared secret key can be used to verify that the encrypted message was not tampered with, before eventually decrypting it.

Note to use DID keys with this function you can call Did::get_ver_key to get key id (verkey) for specific DID.

§Arguments
  • wallet_handle - wallet handle (created by Wallet::open)
  • signer_vk - key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • recipient_vk - key id or verkey of the other party’s key
  • message - the data to be encrypted
§Returns

the encrypted message

Source

pub fn auth_crypt_timeout( wallet_handle: IndyHandle, sender_vk: &str, recipient_vk: &str, message: &[u8], timeout: Duration, ) -> Result<Vec<u8>, ErrorCode>

Encrypt a message by authenticated-encryption scheme.

Sender can encrypt a confidential message specifically for Recipient, using Sender’s public key. Using Recipient’s public key, Sender can compute a shared secret key. Using Sender’s public key and his secret key, Recipient can compute the exact same shared secret key. That shared secret key can be used to verify that the encrypted message was not tampered with, before eventually decrypting it.

Note to use DID keys with this function you can call Did::get_ver_key to get key id (verkey) for specific DID.

§Arguments
  • wallet_handle - wallet handle (created by Wallet::open)
  • signer_vk - key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • recipient_vk - key id or verkey of the other party’s key
  • message - the data to be encrypted
  • timeout - the maximum time this function waits for a response
§Returns

the encrypted message

Source

pub fn auth_crypt_async<F>( wallet_handle: IndyHandle, sender_vk: &str, recipient_vk: &str, message: &[u8], closure: F, ) -> ErrorCode
where F: FnMut(ErrorCode, Vec<u8>) + Send + 'static,

Encrypt a message by authenticated-encryption scheme.

Sender can encrypt a confidential message specifically for Recipient, using Sender’s public key. Using Recipient’s public key, Sender can compute a shared secret key. Using Sender’s public key and his secret key, Recipient can compute the exact same shared secret key. That shared secret key can be used to verify that the encrypted message was not tampered with, before eventually decrypting it.

Note to use DID keys with this function you can call Did::get_ver_key to get key id (verkey) for specific DID.

§Arguments
  • wallet_handle - wallet handle (created by Wallet::open)
  • signer_vk - key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • recipient_vk - key id or verkey of the other party’s key
  • message - the data to be encrypted
  • closure - The closure that is called when finished
§Returns

errorcode from calling ffi function

Source

pub fn auth_decrypt( wallet_handle: IndyHandle, recipient_vk: &str, encrypted_message: &[u8], ) -> Result<(String, Vec<u8>), ErrorCode>

Decrypt a message by authenticated-encryption scheme.

Sender can encrypt a confidential message specifically for Recipient, using Sender’s public key. Using Recipient’s public key, Sender can compute a shared secret key. Using Sender’s public key and his secret key, Recipient can compute the exact same shared secret key. That shared secret key can be used to verify that the encrypted message was not tampered with, before eventually decrypting it.

Note to use DID keys with this function you can call Did::get_ver_key to get key id (verkey) for specific DID.

§Arguments
  • wallet_handle: wallet handle (created by Wallet::open)
  • recipient_vk: key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • encrypted_message: the message to be decrypted
§Returns

sender’s verkey and decrypted message

Source

pub fn auth_decrypt_timeout( wallet_handle: IndyHandle, recipient_vk: &str, encrypted_message: &[u8], timeout: Duration, ) -> Result<(String, Vec<u8>), ErrorCode>

Decrypt a message by authenticated-encryption scheme.

Sender can encrypt a confidential message specifically for Recipient, using Sender’s public key. Using Recipient’s public key, Sender can compute a shared secret key. Using Sender’s public key and his secret key, Recipient can compute the exact same shared secret key. That shared secret key can be used to verify that the encrypted message was not tampered with, before eventually decrypting it.

Note to use DID keys with this function you can call Did::get_ver_key to get key id (verkey) for specific DID.

§Arguments
  • wallet_handle: wallet handle (created by Wallet::open)
  • recipient_vk: key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • encrypted_message: the message to be decrypted
  • timeout - the maximum time this function waits for a response
§Returns

sender’s verkey and decrypted message

Source

pub fn auth_decrypt_async<F>( wallet_handle: IndyHandle, recipient_vk: &str, encrypted_message: &[u8], closure: F, ) -> ErrorCode
where F: FnMut(ErrorCode, String, Vec<u8>) + Send + 'static,

Decrypt a message by authenticated-encryption scheme.

Sender can encrypt a confidential message specifically for Recipient, using Sender’s public key. Using Recipient’s public key, Sender can compute a shared secret key. Using Sender’s public key and his secret key, Recipient can compute the exact same shared secret key. That shared secret key can be used to verify that the encrypted message was not tampered with, before eventually decrypting it.

Note to use DID keys with this function you can call Did::get_ver_key to get key id (verkey) for specific DID.

§Arguments
  • wallet_handle: wallet handle (created by Wallet::open)
  • recipient_vk: key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • encrypted_message: the message to be decrypted
  • closure - The closure that is called when finished
§Returns

errorcode from calling ffi function

Source

pub fn anon_crypt( recipient_vk: &str, message: &[u8], ) -> Result<Vec<u8>, ErrorCode>

Encrypts a message by anonymous-encryption scheme.

Sealed boxes are designed to anonymously send messages to a Recipient given its public key. Only the Recipient can decrypt these messages, using its private key. While the Recipient can verify the integrity of the message, it cannot verify the identity of the Sender.

Note to use DID keys with this function you can call Did::get_ver_key to get key id (verkey) for specific DID.

§Arguments
  • wallet_handle: wallet handle (created by Wallet::open)
  • recipient_vk: verkey of message recipient
  • message: a pointer to first byte of message that to be encrypted
§Returns

the encrypted message

Source

pub fn anon_crypt_timeout( recipient_vk: &str, message: &[u8], timeout: Duration, ) -> Result<Vec<u8>, ErrorCode>

Encrypts a message by anonymous-encryption scheme.

Sealed boxes are designed to anonymously send messages to a Recipient given its public key. Only the Recipient can decrypt these messages, using its private key. While the Recipient can verify the integrity of the message, it cannot verify the identity of the Sender.

Note to use DID keys with this function you can call Did::get_ver_key to get key id (verkey) for specific DID.

§Arguments
  • wallet_handle: wallet handle (created by Wallet::open)
  • recipient_vk: verkey of message recipient
  • message: a pointer to first byte of message that to be encrypted
  • timeout - the maximum time this function waits for a response
§Returns

the encrypted message

Source

pub fn anon_crypt_async<F>( recipient_vk: &str, message: &[u8], closure: F, ) -> ErrorCode
where F: FnMut(ErrorCode, Vec<u8>) + Send + 'static,

Encrypts a message by anonymous-encryption scheme.

Sealed boxes are designed to anonymously send messages to a Recipient given its public key. Only the Recipient can decrypt these messages, using its private key. While the Recipient can verify the integrity of the message, it cannot verify the identity of the Sender.

Note to use DID keys with this function you can call Did::get_ver_key to get key id (verkey) for specific DID.

§Arguments
  • wallet_handle: wallet handle (created by Wallet::open)
  • recipient_vk: verkey of message recipient
  • message: a pointer to first byte of message that to be encrypted
  • closure - The closure that is called when finished
§Returns

errorcode from calling ffi function

Source

pub fn anon_decrypt( wallet_handle: IndyHandle, recipient_vk: &str, encrypted_message: &[u8], ) -> Result<Vec<u8>, ErrorCode>

Decrypts a message by anonymous-encryption scheme.

Sealed boxes are designed to anonymously send messages to a Recipient given its public key. Only the Recipient can decrypt these messages, using its private key. While the Recipient can verify the integrity of the message, it cannot verify the identity of the Sender.

Note to use DID keys with this function you can call Did::get_ver_key to get key id (verkey) for specific DID.

§Arguments
  • wallet_handle: wallet handle (created by Wallet::open).
  • recipient_vk: key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • encrypted_message: a pointer to first byte of message that to be decrypted
§Returns

decrypted message

Source

pub fn anon_decrypt_timeout( wallet_handle: IndyHandle, recipient_vk: &str, encrypted_message: &[u8], timeout: Duration, ) -> Result<Vec<u8>, ErrorCode>

Decrypts a message by anonymous-encryption scheme.

Sealed boxes are designed to anonymously send messages to a Recipient given its public key. Only the Recipient can decrypt these messages, using its private key. While the Recipient can verify the integrity of the message, it cannot verify the identity of the Sender.

Note to use DID keys with this function you can call Did::get_ver_key to get key id (verkey) for specific DID.

§Arguments
  • wallet_handle: wallet handle (created by Wallet::open).
  • recipient_vk: key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • encrypted_message: a pointer to first byte of message that to be decrypted
  • timeout - the maximum time this function waits for a response
§Returns

decrypted message

Source

pub fn anon_decrypt_async<F>( wallet_handle: IndyHandle, recipient_vk: &str, encrypted_message: &[u8], closure: F, ) -> ErrorCode
where F: FnMut(ErrorCode, Vec<u8>) + Send + 'static,

Decrypts a message by anonymous-encryption scheme.

Sealed boxes are designed to anonymously send messages to a Recipient given its public key. Only the Recipient can decrypt these messages, using its private key. While the Recipient can verify the integrity of the message, it cannot verify the identity of the Sender.

Note to use DID keys with this function you can call Did::get_ver_key to get key id (verkey) for specific DID.

§Arguments
  • wallet_handle: wallet handle (created by Wallet::open).
  • recipient_vk: key id or verkey of my key. The key must be created by calling Key::create or Did::new
  • encrypted_message: a pointer to first byte of message that to be decrypted
  • closure - The closure that is called when finished
§Returns

decrypted message

Auto Trait Implementations§

§

impl Freeze for Crypto

§

impl RefUnwindSafe for Crypto

§

impl Send for Crypto

§

impl Sync for Crypto

§

impl Unpin for Crypto

§

impl UnwindSafe for Crypto

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.