Expand description
§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)?;Re-exports§
pub use ecies::EciesCiphertext;pub use ecies::EciesP256;pub use ecies::EciesP384;pub use ecies::EciesSecp256k1;pub use x25519::X25519PublicKey;pub use x25519::X25519SecretKey;pub use x448_impl::X448PublicKey;pub use x448_impl::X448SecretKey;pub use ecdh::EcdhP256;pub use ecdh::EcdhP384;pub use ecdh::EcdhSecp256k1;pub use ecdh::P256PublicKey;pub use ecdh::P256SecretKey;pub use ecdh::P384PublicKey;pub use ecdh::P384SecretKey;pub use ecdh::Secp256k1PublicKey;pub use ecdh::Secp256k1SecretKey;
Modules§
- ecdh
- Elliptic Curve Diffie-Hellman (ECDH).
- ecies
- ECIES (Elliptic Curve Integrated Encryption Scheme).
- prelude
- Prelude for convenient imports.
- x448_
impl - X448 key exchange.
- x25519
- X25519 key exchange.
Enums§
- Elliptic
Curve - Elliptic curve types.
- RsaKey
Size - Key sizes for RSA.
Traits§
- Asymmetric
Decrypt - Trait for asymmetric decryption.
- Asymmetric
Encrypt - Trait for asymmetric encryption.
- Diffie
Hellman - Trait for Diffie-Hellman key exchange.
- Integrated
Encryption - Trait for ECIES (Elliptic Curve Integrated Encryption Scheme).
- KeyAgreement
- Trait for key agreement protocols.