ecies_25519 0.1.3

Elliptic Curve Integrated Encryption Scheme with X25519 curve
Documentation

Elliptic Curve Integrated Encryption Scheme using x25519 ``

Example Usage

use rand::SeedableRng;
use rand_core::{OsRng, TryRngCore};
use ecies_25519::{EciesX25519, generate_keypair, parse_openssl_25519_pubkey_der, parse_openssl_25519_privkey_der};
use rand_chacha::ChaCha8Rng;

 let mut os_rng = rand_core::OsRng::default();
 let mut seed_prod = [0u8; 32];
 os_rng.try_fill_bytes(&mut seed_prod);

let mut cha_rng = ChaCha8Rng::from_seed(seed_prod);

let recv_kp = generate_keypair(&mut cha_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(
   &recv_pub_key, 
   message.as_bytes(), 
   &mut cha_rng
).unwrap();

// Decrypt the message with the private key
let decrypted_data_bytes = ecies_inst.decrypt(
  &recv_priv_key,
  &encrypted_data
).unwrap();

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