Skip to content

Crate vyrn crypto

Amp edited this page Nov 18, 2026 · 1 revision

vyrn-crypto

Path: crates/engine/vyrn-crypto · Layer 1 (11 §1.4) · Pinned: yes (11 §1.3)

Purpose

vyrn-crypto is VYRN's one crypto stack: SipHash-2-4 (written in-house), BLAKE3, Ed25519 under ZIP-215 rules, X25519, and the derive_key contexts of 01 §4. The lane inlines the one-shot SipHash MAC check into its packet loop. Its Ed25519 verify is the only verify function in VYRN, and both the Rust and the Vx clients call it. The crate is #![forbid(unsafe_code)].

Spec sections it implements

  • 01 §4: BLAKE3-256 for content hashes, PktHash and the KDF; the derive_key contexts; X25519
  • 11 §2.4: SipHash-2-4, in-house
  • 11 §2.5: Ed25519 verification under ZIP-215 (canonical S, non-canonical A and R allowed, cofactored equation)
  • 09 §6 owns the exact session-key material that derive_key(SESSION_CONTEXT, …) takes

Main public types

Type Role
siphash24 One-shot SipHash-2-4 with a 128-bit key and a 64-bit Tag; the form the lane inlines
siphash::verify, tag_eq MAC check against a tag
SipHasher24, FixedState Streaming SipHash behind FixedState, for non-engine hash maps
hash::hash, hash::keyed_hash BLAKE3-256
pkt_hash PktHash: the first 8 bytes of BLAKE3-256 over a packet's header and messages
derive_key, SESSION_CONTEXT BLAKE3 KDF; the session context string is "vyrn v1 session"
ed25519::verify, sign, public_key Ed25519 under ZIP-215
x25519::public_key, shared_secret X25519 key agreement

Status on main (a9f0d61)

Implemented. Own version 0.1.0, released as vyrn-crypto-v0.1.0; publish = false. The crate docs name no missing piece or follow-up. ed25519.rs explains why it does not use ed25519-dalek's own verify: that function is cofactorless and compares encodings of R, so it rejects signatures that ZIP-215 accepts.

Tests: tests/golden.rs (5 #[test]), plus unit tests in src/hash.rs and src/siphash.rs (3). Total: 8 #[test] functions. Golden inputs such as siphash.txt, ed25519-edge.txt and blake3_test_vectors.json are in tests/golden at the repository root.

Depends on

Workspace: vyrn-types. External: blake3, curve25519-dalek, ed25519-dalek, x25519-dalek. This matches 11 §1.4 (layer 1 → vyrn-types).

Links

Clone this wiki locally