rvf-crypto

February 27, 2026 ยท View on GitHub

Crates.io License: MIT OR Apache-2.0

Tamper-proof hashing and signing for every RVF segment -- SHA-3 digests, Ed25519 signatures, and lineage witness chains.

rvf-crypto = "0.1"

Every operation on an RVF file gets recorded in a cryptographic witness chain. rvf-crypto provides the primitives that make this possible: SHA-3 (SHAKE-256) content hashing for segment identity, Ed25519 digital signatures for provenance, and lineage verification functions that ensure no record in the chain has been altered. If you are building tools that read, write, or transform .rvf files, this crate handles all the cryptography so you do not have to.

rvf-cryptoManual hashing + signingNo integrity checks
Segment identitySHAKE-256-256 content-addressable IDsRoll your own digest schemeRely on filenames
ProvenanceEd25519 signatures on every segmentIntegrate a signing library yourselfTrust the source blindly
Lineage verificationOne function call validates an entire chainWrite chain-walking logic from scratchNo verification possible
no_std / WASMHashing works without std; signing is feature-gatedVaries by libraryN/A

Quick Start

use rvf_crypto::lineage::{lineage_record_to_bytes, lineage_record_from_bytes, verify_lineage_chain};
use rvf_types::{LineageRecord, DerivationType, FileIdentity};

// Serialize a lineage record to a fixed 128-byte array
let record = LineageRecord::new(
    [1u8; 16], [2u8; 16], [3u8; 32],
    DerivationType::Filter, 5, 1_700_000_000_000_000_000,
    "filtered by category",
);
let bytes = lineage_record_to_bytes(&record);
let decoded = lineage_record_from_bytes(&bytes).unwrap();
assert_eq!(decoded.description_str(), "filtered by category");

// Verify a parent-child lineage chain
let root = FileIdentity::new_root([1u8; 16]);
let root_hash = [0xAAu8; 32];
let child = FileIdentity {
    file_id: [2u8; 16],
    parent_id: [1u8; 16],
    parent_hash: root_hash,
    lineage_depth: 1,
};
verify_lineage_chain(&[(root, root_hash), (child, [0xBBu8; 32])]).unwrap();

Key Features

FeatureWhat It DoesWhy It Matters
SHA-3 (SHAKE-256)Content-addressable hashing for segment identifiersEvery segment gets a unique, collision-resistant ID
Ed25519 signingSegment-level digital signatures via ed25519-dalekProves who created or modified a segment
Lineage witness chainsCryptographic chain linking parent and child segmentsDetects tampering anywhere in the derivation history
Record serializationFixed 128-byte binary codec for LineageRecordCompact, deterministic encoding for witness entries
Manifest hashingSHAKE-256-256 over 4096-byte manifestsAnchors FileIdentity parent references to real data
Chain verificationverify_lineage_chain() validates root-to-leaf integrityOne call proves the entire history is intact

Feature Flags

FlagDefaultWhat It Enables
stdYesStandard library support
ed25519YesEd25519 signing via ed25519-dalek

For no_std or WASM targets that only need hashing and witness chains (no signing), disable defaults:

[dependencies]
rvf-crypto = { version = "0.1", default-features = false }

API Reference

FunctionDescription
lineage_record_to_bytes(record)Serialize a LineageRecord to a fixed 128-byte array
lineage_record_from_bytes(bytes)Deserialize a LineageRecord from 128 bytes
lineage_witness_entry(record, prev_hash)Create a WitnessEntry (type 0x09) for a derivation event
compute_manifest_hash(manifest)SHAKE-256-256 digest over a 4096-byte manifest
verify_lineage_chain(chain)Validate parent-child integrity from root to leaf

License

MIT OR Apache-2.0


Part of RuVector -- the self-learning vector database.