Trait oasis_contract_sdk::env::Crypto
source · pub trait Crypto {
// Required methods
fn ecdsa_recover(&self, input: &[u8]) -> [u8; 65];
fn signature_verify_ed25519(
&self,
key: &[u8],
message: &[u8],
signature: &[u8],
) -> bool;
fn signature_verify_secp256k1(
&self,
key: &[u8],
message: &[u8],
signature: &[u8],
) -> bool;
fn signature_verify_sr25519(
&self,
key: &[u8],
context: &[u8],
message: &[u8],
signature: &[u8],
) -> bool;
fn x25519_derive_symmetric(
&self,
public_key: &[u8],
private_key: &[u8],
) -> [u8; 32];
fn deoxysii_seal(
&self,
key: &[u8],
nonce: &[u8],
message: &[u8],
additional_data: &[u8],
) -> Result<Vec<u8>, CryptoError>;
fn deoxysii_open(
&self,
key: &[u8],
nonce: &[u8],
message: &[u8],
additional_data: &[u8],
) -> Result<Vec<u8>, CryptoError>;
fn random_bytes(&self, pers: &[u8], dst: &mut [u8]) -> usize;
}
Expand description
Crypto helpers trait.
Required Methods§
sourcefn ecdsa_recover(&self, input: &[u8]) -> [u8; 65]
fn ecdsa_recover(&self, input: &[u8]) -> [u8; 65]
ECDSA public key recovery function.
sourcefn signature_verify_ed25519(
&self,
key: &[u8],
message: &[u8],
signature: &[u8],
) -> bool
fn signature_verify_ed25519( &self, key: &[u8], message: &[u8], signature: &[u8], ) -> bool
Verify an ed25519 message signature.
sourcefn signature_verify_secp256k1(
&self,
key: &[u8],
message: &[u8],
signature: &[u8],
) -> bool
fn signature_verify_secp256k1( &self, key: &[u8], message: &[u8], signature: &[u8], ) -> bool
Verify a secp256k1 message signature.
sourcefn signature_verify_sr25519(
&self,
key: &[u8],
context: &[u8],
message: &[u8],
signature: &[u8],
) -> bool
fn signature_verify_sr25519( &self, key: &[u8], context: &[u8], message: &[u8], signature: &[u8], ) -> bool
Verify an sr25519 message signature.
sourcefn x25519_derive_symmetric(
&self,
public_key: &[u8],
private_key: &[u8],
) -> [u8; 32]
fn x25519_derive_symmetric( &self, public_key: &[u8], private_key: &[u8], ) -> [u8; 32]
Derive a symmetric key from a public/private key pair.
sourcefn deoxysii_seal(
&self,
key: &[u8],
nonce: &[u8],
message: &[u8],
additional_data: &[u8],
) -> Result<Vec<u8>, CryptoError>
fn deoxysii_seal( &self, key: &[u8], nonce: &[u8], message: &[u8], additional_data: &[u8], ) -> Result<Vec<u8>, CryptoError>
Encrypt and authenticate a message and authenticate additional data using DeoxysII.
sourcefn deoxysii_open(
&self,
key: &[u8],
nonce: &[u8],
message: &[u8],
additional_data: &[u8],
) -> Result<Vec<u8>, CryptoError>
fn deoxysii_open( &self, key: &[u8], nonce: &[u8], message: &[u8], additional_data: &[u8], ) -> Result<Vec<u8>, CryptoError>
Decrypt and authenticate a message and authenticate additional data using DeoxysII.
sourcefn random_bytes(&self, pers: &[u8], dst: &mut [u8]) -> usize
fn random_bytes(&self, pers: &[u8], dst: &mut [u8]) -> usize
Fills dst
with cryptographically secure random bytes.
Returns the number of bytes written.
If the optional personalization string (pers
) is provided, it will be mixed into the RNG to provide additional domain separation.