[−][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 |
EncryptKeySeed | A seed that can be used for |
PublicEncryptKey | A |
PublicSigningKey | An |
SecretEncryptKey | A |
SecretSigningKey | An |
Sha256 | A digest of the |
Signature | An |
SigningKeyPair | A |
SigningKeySeed | A seed that can be used for |
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. |