Git Product home page Git Product logo

ecies-ed25519's Introduction

ecies-ed25519

docs crates.io checks codecov

ECIES on Twisted Edwards Curve25519 using AES-GCM and HKDF-SHA256.

ECIES can be used to encrypt data using a public key such that it can only be decrypted by the holder of the corresponding private key.

This project has not undergone a security audit. A 1.0 release will not happen until it does.

Backends

It uses the excellent curve25519-dalek library for ECC operations, and provides two different backends for HKDF-SHA256 / AES-GCM operation operations.

  1. The pure_rust backend (default). It uses a collection of pure-rust implementations of SHA2, HKDF, AES, and AEAD.

  2. The ring backend uses ring. It uses rock solid primitives based on BoringSSL, but cannot run on all platforms. For example it won't work on WASM. To activate this backend add this to your Cargo.toml file:

    ecies-ed25519 = { version = "0.3", features = ["ring"] }

Example Usage

let mut csprng = rand::thread_rng();
let (secret, public) = ecies_ed25519::generate_keypair(&mut csprng);

let message = "I ๐Ÿ’–๐Ÿ”’";

// Encrypt the message with the public key such that only the holder of the secret key can decrypt.
let encrypted = ecies_ed25519::encrypt(&public, message.as_bytes(), &mut csprng).unwrap();

// Decrypt the message with the secret key
let decrypted = ecies_ed25519::decrypt(&secret, &encrypted);

serde Support

The serde feature is provided for serializing / deserializing private and public keys.

Running Tests

You should run tests on both backends:

cargo test --no-default-features --features "ring serde"
cargo test --no-default-features --features "pure_rust serde"

Performance

If using the pure_rust backend, by default this crate's dependencies will use software implementations of both AES and the POLYVAL universal hash function.

When targeting modern x86/x86_64 CPUs, use the following RUSTFLAGS to take advantage of high performance AES-NI and CLMUL CPU intrinsics:

RUSTFLAGS="-Ctarget-cpu=sandybridge -Ctarget-feature=+aes,+sse2,+sse4.1,+ssse3"

Future Plans

  • I will be making this crate generic over both the AEAD and HKDF implementation once const-generics is resolved.

  • Add support for AVX2 and AVX512

Security Audits

This project has not undergone a security audit. A 1.0 release will not happen until it does. Please contact me if you would like to fund or perform a security audit.

While this library has not undergone a security audit, some of its dependencies have. Dependency audits:

ecies-ed25519's People

Contributors

phayes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.