[][src]Crate ecies_ed25519

ECIES-ed25519: An Integrated Encryption Scheme on Twisted Edwards Curve25519.

ECIES can be used to encrypt data using a public key such that it can only be decrypted by the holder of the corresponding private key. It is based on curve25519-dalek.

There are two different backends for HKDF-SHA256 / AES-GCM operations:

  • The pure_rust backend (default). It uses a collection of pure-rust implementations of SHA2, HKDF, AES, and AEAD.

  • The ring backend uses ring. It uses rock solid primitives based on BoringSSL, but cannot run on all platforms. For example it won't work in web assembly. To enable it add the following to your Cargo.toml:

    ecies-ed25519 = { version = "0.3", features = ["ring"] }

Example Usage

let mut csprng = rand::thread_rng();
let (secret, public) = ecies_ed25519::generate_keypair(&mut csprng);

let message = "I 💖🔒";

// Encrypt the message with the public key such that only the holder of the secret key can decrypt.
let encrypted = ecies_ed25519::encrypt(&public, message.as_bytes(), &mut csprng).unwrap();

// Decrypt the message with the secret key
let decrypted = ecies_ed25519::decrypt(&secret, &encrypted);

serde support

The serde feature is provided for serializing / deserializing private and public keys.

Structs

PublicKey

Public Key

SecretKey

Secret Key

Enums

Error

Error types

Constants

PUBLIC_KEY_LENGTH

The length of a PublicKey, in bytes.

SECRET_KEY_LENGTH

The length of a SecretKey, in bytes.

Functions

decrypt

Decrypt a ECIES encrypted ciphertext using the receiver's SecretKey.

encrypt

Encrypt a message using ECIES, it can only be decrypted by the receiver's SecretKey.

generate_keypair

Generate a keypair, ready for use in ECIES