3 releases
0.1.2 | Feb 16, 2024 |
---|---|
0.1.1 | Jan 9, 2024 |
0.1.0 | Nov 25, 2021 |
#1975 in Cryptography
Used in c5store
11KB
177 lines
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(
&recv_pub_key,
message.as_bytes(),
&mut os_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());
Dependencies
~5–6.5MB
~124K SLoC