[][src]Module xaynet_core::crypto

Wrappers around some of the sodiumoxide crypto primitives.

The wrappers provide methods defined on structs instead of the sodiumoxide functions. This is done for the C25519 encryption and Ed25519 signature key pairs and their corresponding seeds as well as the SHA256 hash function. Additionally, some methods for slicing and signature eligibility are available.

Examples

Encryption of messages

let keys = EncryptKeyPair::generate();
let message = b"Hello world!".to_vec();
let cipher = keys.public.encrypt(&message);
assert_eq!(message, keys.secret.decrypt(&cipher, &keys.public).unwrap());

Signing of messages

let keys = SigningKeyPair::generate();
let message = b"Hello world!".to_vec();
let signature = keys.secret.sign_detached(&message);
assert!(keys.public.verify_detached(&signature, &message));

Structs

EncryptKeyPair

A C25519 key pair for asymmetric authenticated encryption.

EncryptKeySeed

A seed that can be used for C25519 encryption key pair generation.

PublicEncryptKey

A C25519 public key for asymmetric authenticated encryption.

PublicSigningKey

An Ed25519 public key for signatures.

SecretEncryptKey

A C25519 secret key for asymmetric authenticated encryption.

SecretSigningKey

An Ed25519 secret key for signatures.

Sha256

A digest of the SHA256 hash function.

Signature

An Ed25519 signature detached from its message.

SigningKeyPair

A Ed25519 key pair for signatures.

SigningKeySeed

A seed that can be used for Ed25519 signing key pair generation.

Constants

SEALBYTES

Number of additional bytes in a ciphertext compared to the corresponding plaintext.

Traits

ByteObject

An interface for slicing into cryptographic byte objects.

Functions

generate_integer

Generates a secure pseudo-random integer.