Crates.io | ecies-ed25519-morus |
lib.rs | ecies-ed25519-morus |
version | 0.2.0 |
source | src |
created_at | 2023-06-30 16:56:16.626007 |
updated_at | 2023-07-01 03:30:26.144877 |
description | Experimental Integrated Encryption Scheme on Ed25519 using MORUS-1280-128 and Blake3 |
homepage | |
repository | https://github.com/ujang360/ecies-ed25519-morus |
max_upload_size | |
id | 904777 |
size | 40,276 |
Experimental ECIES on Twisted Edwards Curve25519 and MORUS-1280-128
sign & verify
keypair in the ed25519
scheme for accomplishing ECIES
. We call this, a perversion because we should only use the ephemeral ones
(except for the recipient).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);
no-std
environment (for example: wasm):cargo add ecies-ed25519-morus --no-default-features --features="pure"
std
environment (default):cargo add ecies-ed25519-morus
std
and aarch64
environment (for example: Apple Silicon)cargo add ecies-ed25519-morus --features="aarch64-optimizations"
This work is heavily inspired by:
no-std
(see: these lines)python
and c/c++
wrappers