pub struct Crypto {}
Implementations
sourceimpl Crypto
impl Crypto
sourcepub fn sign(
wallet_handle: IndyHandle,
signer_vk: &str,
message: &[u8]
) -> Result<Vec<u8>, ErrorCode>
pub fn sign(
wallet_handle: IndyHandle,
signer_vk: &str,
message: &[u8]
) -> Result<Vec<u8>, ErrorCode>
sourcepub fn sign_timeout(
wallet_handle: IndyHandle,
signer_vk: &str,
message: &[u8],
timeout: Duration
) -> Result<Vec<u8>, ErrorCode>
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::newmessage
- the data to be signedtimeout
- the maximum time this function waits for a response
Returns
the signature
sourcepub fn sign_async<F: 'static>(
wallet_handle: IndyHandle,
signer_vk: &str,
message: &[u8],
closure: F
) -> ErrorCodewhere
F: FnMut(ErrorCode, Vec<u8>) + Send,
pub fn sign_async<F: 'static>(
wallet_handle: IndyHandle,
signer_vk: &str,
message: &[u8],
closure: F
) -> ErrorCodewhere
F: FnMut(ErrorCode, Vec<u8>) + Send,
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::newmessage
- the data to be signedclosure
- The closure that is called when finished
Returns
errorcode from calling ffi function
sourcepub fn verify(
signer_vk: &str,
message: &[u8],
signature: &[u8]
) -> Result<bool, ErrorCode>
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::newmessage
- the data that was signedsignature
- the signature to verify
Returns
true if signature is valid, false otherwise
sourcepub fn verify_timeout(
signer_vk: &str,
message: &[u8],
signature: &[u8],
timeout: Duration
) -> Result<bool, ErrorCode>
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::newmessage
- the data that was signedsignature
- the signature to verifytimeout
- the maximum time this function waits for a response
Returns
true if signature is valid, false otherwise
sourcepub fn verify_async<F: 'static>(
signer_vk: &str,
message: &[u8],
signature: &[u8],
closure: F
) -> ErrorCodewhere
F: FnMut(ErrorCode, bool) + Send,
pub fn verify_async<F: 'static>(
signer_vk: &str,
message: &[u8],
signature: &[u8],
closure: F
) -> ErrorCodewhere
F: FnMut(ErrorCode, bool) + Send,
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::newmessage
- the data that was signedsignature
- the signature to verifyclosure
- The closure that is called when finished
Returns
errorcode from calling ffi function
sourcepub fn auth_crypt(
wallet_handle: IndyHandle,
sender_vk: &str,
recipient_vk: &str,
message: &[u8]
) -> Result<Vec<u8>, ErrorCode>
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::newrecipient_vk
- key id or verkey of the other party’s keymessage
- the data to be encrypted
Returns
the encrypted message
sourcepub fn auth_crypt_timeout(
wallet_handle: IndyHandle,
sender_vk: &str,
recipient_vk: &str,
message: &[u8],
timeout: Duration
) -> Result<Vec<u8>, ErrorCode>
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::newrecipient_vk
- key id or verkey of the other party’s keymessage
- the data to be encryptedtimeout
- the maximum time this function waits for a response
Returns
the encrypted message
sourcepub fn auth_crypt_async<F: 'static>(
wallet_handle: IndyHandle,
sender_vk: &str,
recipient_vk: &str,
message: &[u8],
closure: F
) -> ErrorCodewhere
F: FnMut(ErrorCode, Vec<u8>) + Send,
pub fn auth_crypt_async<F: 'static>(
wallet_handle: IndyHandle,
sender_vk: &str,
recipient_vk: &str,
message: &[u8],
closure: F
) -> ErrorCodewhere
F: FnMut(ErrorCode, Vec<u8>) + Send,
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::newrecipient_vk
- key id or verkey of the other party’s keymessage
- the data to be encryptedclosure
- The closure that is called when finished
Returns
errorcode from calling ffi function
sourcepub fn auth_decrypt(
wallet_handle: IndyHandle,
recipient_vk: &str,
encrypted_message: &[u8]
) -> Result<(String, Vec<u8>), ErrorCode>
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::newencrypted_message
: the message to be decrypted
Returns
sender’s verkey and decrypted message
sourcepub fn auth_decrypt_timeout(
wallet_handle: IndyHandle,
recipient_vk: &str,
encrypted_message: &[u8],
timeout: Duration
) -> Result<(String, Vec<u8>), ErrorCode>
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::newencrypted_message
: the message to be decryptedtimeout
- the maximum time this function waits for a response
Returns
sender’s verkey and decrypted message
sourcepub fn auth_decrypt_async<F: 'static>(
wallet_handle: IndyHandle,
recipient_vk: &str,
encrypted_message: &[u8],
closure: F
) -> ErrorCodewhere
F: FnMut(ErrorCode, String, Vec<u8>) + Send,
pub fn auth_decrypt_async<F: 'static>(
wallet_handle: IndyHandle,
recipient_vk: &str,
encrypted_message: &[u8],
closure: F
) -> ErrorCodewhere
F: FnMut(ErrorCode, String, Vec<u8>) + Send,
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::newencrypted_message
: the message to be decryptedclosure
- The closure that is called when finished
Returns
errorcode from calling ffi function
sourcepub fn anon_crypt(
recipient_vk: &str,
message: &[u8]
) -> Result<Vec<u8>, ErrorCode>
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 recipientmessage
: a pointer to first byte of message that to be encrypted
Returns
the encrypted message
sourcepub fn anon_crypt_timeout(
recipient_vk: &str,
message: &[u8],
timeout: Duration
) -> Result<Vec<u8>, ErrorCode>
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 recipientmessage
: a pointer to first byte of message that to be encryptedtimeout
- the maximum time this function waits for a response
Returns
the encrypted message
sourcepub fn anon_crypt_async<F: 'static>(
recipient_vk: &str,
message: &[u8],
closure: F
) -> ErrorCodewhere
F: FnMut(ErrorCode, Vec<u8>) + Send,
pub fn anon_crypt_async<F: 'static>(
recipient_vk: &str,
message: &[u8],
closure: F
) -> ErrorCodewhere
F: FnMut(ErrorCode, Vec<u8>) + Send,
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 recipientmessage
: a pointer to first byte of message that to be encryptedclosure
- The closure that is called when finished
Returns
errorcode from calling ffi function
sourcepub fn anon_decrypt(
wallet_handle: IndyHandle,
recipient_vk: &str,
encrypted_message: &[u8]
) -> Result<Vec<u8>, ErrorCode>
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::newencrypted_message
: a pointer to first byte of message that to be decrypted
Returns
decrypted message
sourcepub fn anon_decrypt_timeout(
wallet_handle: IndyHandle,
recipient_vk: &str,
encrypted_message: &[u8],
timeout: Duration
) -> Result<Vec<u8>, ErrorCode>
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::newencrypted_message
: a pointer to first byte of message that to be decryptedtimeout
- the maximum time this function waits for a response
Returns
decrypted message
sourcepub fn anon_decrypt_async<F: 'static>(
wallet_handle: IndyHandle,
recipient_vk: &str,
encrypted_message: &[u8],
closure: F
) -> ErrorCodewhere
F: FnMut(ErrorCode, Vec<u8>) + Send,
pub fn anon_decrypt_async<F: 'static>(
wallet_handle: IndyHandle,
recipient_vk: &str,
encrypted_message: &[u8],
closure: F
) -> ErrorCodewhere
F: FnMut(ErrorCode, Vec<u8>) + Send,
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::newencrypted_message
: a pointer to first byte of message that to be decryptedclosure
- The closure that is called when finished
Returns
decrypted message