Crates.io | wedpr_ecies |
lib.rs | wedpr_ecies |
version | 0.2.1 |
source | src |
created_at | 2021-08-25 08:46:49.615413 |
updated_at | 2021-08-25 08:46:49.615413 |
description | Elliptic Curve Integrated Encryption Scheme for secp256k1 in Rust |
homepage | https://ecies.org/rs/ |
repository | https://github.com/ecies/rs |
max_upload_size | |
id | 442040 |
size | 30,560 |
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.
This library can be compiled to the WASM target at your option, see WASM compatibility.
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. This would be no longer necessary when aes-gcm
supports automatic CPU detection.
It's also possible to build to 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: