#ed25519 #ecies #curve25519 #encryption #no-alloc #random #morus

no-std ecies-ed25519-morus

Experimental Integrated Encryption Scheme on Ed25519 using MORUS-1280-128 and Blake3

2 unstable releases

0.2.0 Jul 1, 2023
0.1.0 Jun 30, 2023

#2145 in Cryptography

MIT license

40KB
688 lines

ecies-ed25519-morus

Crates.io docs.rs GitHub

Experimental ECIES on Twisted Edwards Curve25519 and MORUS-1280-128

Notes

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-std environment (for example: wasm):
cargo add ecies-ed25519-morus --no-default-features --features="pure"
  • std environment (default):
cargo add ecies-ed25519-morus
cargo add ecies-ed25519-morus --features="aarch64-optimizations"

Inspirations

This work is heavily inspired by:

Future Works

  • Encrypt & Decrypt with associated data
  • Improve tests with fuzzers & harnesses
  • Add benchmark information
  • Add example and diagrams to elaborate use cases
  • Implement python and c/c++ wrappers

Dependencies

~3.5–5.5MB
~123K SLoC