Elliptic Curve Integrated Encryption Scheme for secp256k1 in Rust, based on pure Rust implementation of secp256k1.
ECIES functionalities are built upon AES-GCM-256 and HKDF-SHA256.
This is the Rust version of eciespy.
use ecies::{decrypt, encrypt, utils::generate_keypair};
const MSG: &str = "helloworld";
let (sk, pk) = generate_keypair();
let (sk, pk) = (&sk.serialize(), &pk.serialize());
let msg = MSG.as_bytes();
assert_eq!(
msg,
decrypt(sk, &encrypt(pk, msg).unwrap()).unwrap().as_slice()
);
You can choose to use OpenSSL implementation or pure Rust implementation of AES-256-GCM:
ecies = {version = "0.2", default-features = false, features = ["pure"]}
Due to some performance problem, OpenSSL is the default backend.
Pure Rust implementation is sometimes useful, such as building on WASM:
cargo build --no-default-features --features pure --target=wasm32-unknown-unknown
If you select the pure Rust backend on modern CPUs, consider building with RUSTFLAGS="-Ctarget-cpu=sandybridge -Ctarget-feature=+aes,+sse2,+sse4.1,+ssse3"
to speed up AES encryption/decryption.
It's also possible to build on the wasm32-unknown-unknown
target with the pure Rust backend. Check out this repo for more details.
AEAD scheme like AES-GCM-256 should be your first option for symmetric ciphers, with unique IVs in each encryption.
For key derivation functions on shared points between two asymmetric keys, HKDFs are proven to be more secure than simple hash functions like SHA256.
All functionalities are mutually checked among different languages: Python, Rust, JavaScript and Golang.
Following dependencies are audited:
- Revamp documentations
- Optional pure Rust AES backend
- Bump dependencies
- Update documentation
- Fix error handling
- First beta version release