affinidi-rdf-encoding
RDF Dataset Canonicalization (RDFC-1.0) and JSON-LD expansion for W3C Verifiable Credentials. A minimal-dependency implementation.
Features
- RDF data model —
NamedNode,BlankNode,Literal,Quad,Dataset - N-Quads parser/serializer — W3C spec-compliant with proper escaping
- RDFC-1.0 canonicalization — Full W3C RDF Dataset Canonicalization algorithm
- JSON-LD expansion + to-RDF — Focused on VC/DID contexts with bundled W3C context documents
Installation
[]
= "0.1"
Usage
use ;
// JSON-LD -> RDF -> Canonical N-Quads
let document: Value = from_str?;
let dataset = expand_and_to_rdf?;
let canonical_nquads = canonicalize?;
// Or use the convenience function for the full pipeline + SHA-256 hash:
let hash = expand_canonicalize_and_hash?;
Bundled Contexts
The following W3C JSON-LD contexts are embedded (no network requests needed):
https://www.w3.org/ns/credentials/v2https://www.w3.org/ns/credentials/examples/v2https://w3id.org/security/data-integrity/v2
Related Crates
affinidi-data-integrity— W3C Data Integrity proofs (uses this crate)