Skip to main content

Module crypto

Module crypto 

Source
Expand description

In-tree cryptography (the engine may only link the four ecosystem crates). Implemented from scratch, no_std, unsafe-free, pinned against standard test vectors:

  • sha1 — FIPS 180-1 (BitTorrent v1)
  • sha256 — FIPS 180-4 (BitTorrent v2 / BEP-52, receipts)
  • sha512 — FIPS 180-4 (Ed25519)
  • ed25519 — RFC 8032 signatures (provable receipts)
  • chacha20 / rng — ChaCha20 CSPRNG (peer ids, DHT ids, nonces)
  • hmac_sha256 — HMAC-SHA256 (DHT announce tokens, keyed receipts)

Re-exports§

pub use base32::decode as base32_decode;
pub use base32::encode as base32_encode;
pub use base58::decode as base58_decode;
pub use base58::encode as base58_encode;
pub use base64::decode as base64_decode;
pub use base64::encode as base64_encode;
pub use base64::Variant;
pub use md4::Md4;
pub use rng::Rng;
pub use sha1::Sha1;
pub use sha256::Sha256;
pub use sha512::Sha512;

Modules§

base32
Base32 codec (RFC 4648), no_std + alloc.
base58
Base58 (Bitcoin/IPFS alphabet) codec, no_std + alloc.
base64
RFC 4648 Base64 codec (no_std, alloc-only): standard alphabet with = padding plus a URL-safe -/_ variant. Unwraps Base64-wrapped Thunder (thunder://), QQ-Xuanfeng (qqdl://) and FlashGet (flashget://) URLs.
chacha20
ChaCha20 stream cipher (RFC 8439, IETF 12-byte nonce variant), the deterministic PRNG core for peer ids, DHT node ids, tokens and transaction ids. Pure no_std, zero unsafe (not used for secrets).
ed25519
Ed25519 (RFC 8032) — pure no_std, zero unsafe, from scratch.
md4
MD4 (RFC 1320), no_std + alloc, for eMule file identification (ed2k://|file|<name>|<size>|<md4>|/). Broken for collision resistance; used only for eMule-link compatibility, never for receipts (those use Ed25519/SHA-256). 64-bit length field (RFC-consistent).
rng
ChaCha20-based deterministic CSPRNG.
sha1
SHA-1 (FIPS 180-1) — required by BitTorrent v1 piece hashing.
sha256
SHA-256 (FIPS 180-4) — required by BitTorrent v2 (BEP-52), receipt content commitment and Merkle helpers. Pure no_std, zero unsafe.
sha512
SHA-512 (FIPS 180-4) — used by Ed25519 (RFC 8032) for key/prefix hashing and message challenges. Pure no_std, zero unsafe.

Functions§

hmac_sha256
HMAC-SHA256 (RFC 2104). Used for DHT announce tokens and keyed receipt commitments.