Crate ecies_25519[][src]

Expand description

Elliptic Curve Integrated Encryption Scheme using x25519

Example Usage

use rand_core::{OsRng};
use ecies_25519::{EciesX25519, generate_keypair, parse_openssl_25519_pubkey_der, parse_openssl_25519_privkey_der};

let mut os_rng = OsRng::default();

let recv_kp = generate_keypair(&mut os_rng).unwrap();
let recv_pub_key = parse_openssl_25519_pubkey_der(&recv_kp.public_der).unwrap();
let recv_priv_key = parse_openssl_25519_privkey_der(&recv_kp.private_der).unwrap();

let message = "I 💖🔒";

let ecies_inst = EciesX25519::new();

// Encrypt the message with the public key
let encrypted_data = ecies_inst.encrypt(
   &mut os_rng

// Decrypt the message with the private key
let decrypted_data_bytes = ecies_inst.decrypt(

println!("Decrypted data is {}", String::from_utf8(decrypted_data_bytes.clone()).unwrap());


A Diffie-Hellman public key, corresponding to an EphemeralSecret or StaticSecret key.

A Diffie-Hellman secret key that can be used to compute multiple SharedSecrets.



Generate a keypair, ready for use in ECIES

Parse a DER ED25519 or X25519 private key, and return the corresponding x25519_dalek::StaticSecret

Parse a DER Ed25519 or X25519 public key, and return the corresponding x25519_dalek::PublicKey