warrant_verify/lib.rs
1//! # warrant-verify (Rust)
2//!
3//! An independent, from-scratch implementation of the
4//! [Warrant](https://github.com/s0fractal/warrant) decision-record format: a
5//! decision is a small JSON body naming the policy it was made under, its
6//! reasons and evidence, its actor and its prior decisions; its identity
7//! (WarrantID) is the SHA-256 of the body's RFC 8785 canonical bytes, and it is
8//! signed with Ed25519 over a domain-separated message.
9//!
10//! This crate is held to the reference implementation (`impl/warrant.py`,
11//! published on PyPI as `warrant-verify`) by differential tests that compare
12//! output byte for byte: the same store gives the same report, the same counts,
13//! the same exit status, and the same written records.
14//!
15//! It has **no dependencies**: SHA-256, SHA-512, Ed25519 and the JSON parser
16//! are written here, so that agreeing with the reference is evidence about the
17//! specification rather than about a shared library.
18//!
19//! ```
20//! use warrant_verify::{json, schema, store};
21//!
22//! let body = json::parse_ijson(br#"{"warrant":"0.2","decision":"propose",
23//! "subject":{"hash":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
24//! "under":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],
25//! "because":[],"evidence":[],"actor":{"id":"a@example"},"prior":[],"ts":1}"#).unwrap();
26//! assert!(schema::validate_body(&body).is_empty());
27//! let wid = store::warrant_id(&body).unwrap();
28//! assert_eq!(wid.len(), 64);
29//! ```
30//!
31//! Modules, in the order the format builds on them: [`hash`], [`json`]
32//! (I-JSON parsing and canonicalization, SPEC §4), [`schema`] (§2/§3),
33//! [`sig`] and [`ed25519`] (§5), [`ski`] (the `ski@v1` evaluator, §3.1),
34//! [`store`], [`settlement`] (§5.1/§7/§9), [`verify`] (§6 and the §11 report),
35//! [`ops`] (filing, `why`, `resign`, `settle`), [`conformance`] (§8 and the
36//! `warrant-conformance/1` probe) and [`cli`].
37
38#![forbid(unsafe_code)]
39
40pub mod cli;
41pub mod conformance;
42pub mod ed25519;
43pub mod hash;
44pub mod json;
45pub mod ops;
46pub mod p256;
47pub mod schema;
48pub mod settlement;
49pub mod sig;
50pub mod ski;
51pub mod store;
52pub mod verify;