2 unstable releases
| 0.2.0 | Jul 1, 2023 |
|---|---|
| 0.1.0 | Jun 30, 2023 |
#7 in #ecies
40KB
688 lines
ecies-ed25519-morus
Experimental ECIES on Twisted Edwards Curve25519 and MORUS-1280-128
Notes
- Flexible Symmetric Cryptography - Impractical plaintext recovery attack.
- This work misuses the
sign & verifykeypair in theed25519scheme for accomplishingECIES. We call this, a perversion because we should only use theephemeral ones(except for the recipient). - No security audits, and perhaps will not happen.
Example
use rand_core::RngCore;
use ecies_ed25519_morus::{encrypt_into, decrypt_into};
const BUFFER_SIZE: usize = 512 * 1024; // avoid higher than this to prevent stackoverflow
let mut rng = rand_core::OsRng::default();
let sender_keypair = ed25519_dalek::SigningKey::generate(&mut rng);
let receiver_keypair = ed25519_dalek::SigningKey::generate(&mut rng);
let sender_public = sender_keypair.verifying_key();
let receiver_public = receiver_keypair.verifying_key();
let mut random_message = [0u8; BUFFER_SIZE];
let mut decrypted_message = [0u8; BUFFER_SIZE];
let mut ciphertext = [0u8; BUFFER_SIZE];
rng.fill_bytes(&mut random_message);
let decrypt_materials = encrypt_into(
&mut rng,
&sender_keypair,
&receiver_public,
&[],
&random_message[..],
&mut ciphertext[..],
)
.unwrap();
decrypt_into(
&decrypt_materials,
&receiver_keypair,
&sender_public,
&[],
&ciphertext[..],
&mut decrypted_message[..],
)
.unwrap();
assert_eq!(random_message, decrypted_message);
assert_ne!(sender_public, receiver_public);
Features
no-stdenvironment (for example: wasm):
cargo add ecies-ed25519-morus --no-default-features --features="pure"
stdenvironment (default):
cargo add ecies-ed25519-morus
stdandaarch64environment (for example: Apple Silicon)
cargo add ecies-ed25519-morus --features="aarch64-optimizations"
Inspirations
This work is heavily inspired by:
- ecies-ed25519, which uses AES-GCM and ephemeral keypairs (see: notes)
- rust-morus, modified for pure
no-std(see: these lines)
Future Works
- Encrypt & Decrypt with associated data
- Improve tests with fuzzers & harnesses
- Add benchmark information
- Add example and diagrams to elaborate use cases
- Implement
pythonandc/c++wrappers
Dependencies
~5–7MB
~159K SLoC