#ecies #x25519 #ecdh #rsa

arcanum-asymmetric

Asymmetric cryptography: RSA, ECIES, key exchange

3 releases

Uses new Rust 2024

0.1.2 Jan 26, 2026
0.1.1 Jan 23, 2026
0.1.0 Jan 22, 2026

#2224 in Cryptography

39 downloads per month
Used in 4 crates (3 directly)

MIT/Apache

220KB
4K SLoC

Arcanum Asymmetric Cryptography

Asymmetric (public-key) cryptography algorithms for encryption, key exchange, and key agreement.

RSA

RSA encryption and signatures with modern padding schemes:

  • RSA-OAEP: Optimal Asymmetric Encryption Padding
  • RSA-PSS: Probabilistic Signature Scheme
  • RSA-PKCS#1: Legacy padding (use OAEP/PSS for new applications)

ECIES

Elliptic Curve Integrated Encryption Scheme:

  • ECIES-P256: Using NIST P-256 curve
  • ECIES-P384: Using NIST P-384 curve
  • ECIES-secp256k1: Using Bitcoin's curve

Key Exchange

  • X25519: Curve25519 Diffie-Hellman (recommended)
  • X448: Curve448 Diffie-Hellman (higher security)
  • ECDH: Elliptic Curve Diffie-Hellman (P-256, P-384, secp256k1)

Example

use arcanum_asymmetric::prelude::*;

// X25519 key exchange
let alice_secret = X25519SecretKey::generate();
let alice_public = alice_secret.public_key();

let bob_secret = X25519SecretKey::generate();
let bob_public = bob_secret.public_key();

let alice_shared = alice_secret.diffie_hellman(&bob_public);
let bob_shared = bob_secret.diffie_hellman(&alice_public);
assert_eq!(alice_shared.as_bytes(), bob_shared.as_bytes());

// RSA encryption
let (private_key, public_key) = RsaKeyPair::generate(2048)?;
let ciphertext = public_key.encrypt_oaep(b"secret message")?;
let plaintext = private_key.decrypt_oaep(&ciphertext)?;

Dependencies

~17MB
~329K SLoC