Skip to main content

vouch_core/
lib.rs

1//! Vouch Protocol canonical core.
2//!
3//! One byte-exact Rust implementation of the protocol primitives (JCS
4//! canonicalization, Ed25519 and ML-DSA proofs, did:key/multikey, Data Integrity
5//! eddsa-jcs-2022, credentials, delegation, revocation), shared by every language
6//! SDK through WASM and UniFFI/C-FFI so that no primitive is re-derived per
7//! language. Behavior MUST match the TypeScript reference SDK byte-for-byte and
8//! pass the shared interop vectors in `test-vectors/`.
9//!
10//! With the default `std` feature this is the full core. Built with
11//! `--no-default-features --features alloc` it is `no_std` (it needs only a
12//! heap), for microcontrollers: see `docs/microcontrollers.md` for what that
13//! build covers.
14
15#![cfg_attr(not(any(feature = "std", test)), no_std)]
16
17#[cfg(not(any(feature = "std", feature = "alloc")))]
18compile_error!("vouch-core needs the `std` feature (default) or the `alloc` feature");
19
20#[cfg(not(any(feature = "std", test)))]
21#[macro_use]
22extern crate alloc;
23#[cfg(any(feature = "std", test))]
24extern crate alloc;
25
26/// The heap types that `std` puts in scope by default, imported explicitly so
27/// the same source builds with and without `std`.
28#[allow(unused_imports)]
29pub(crate) mod prelude {
30    pub use alloc::borrow::ToOwned;
31    pub use alloc::boxed::Box;
32    pub use alloc::string::{String, ToString};
33    pub use alloc::vec::Vec;
34}
35
36/// The set and map types in the public API. With `std` they are the standard
37/// hash collections. Without `std` there is no hasher seeded from the OS, so
38/// they are the ordered B-tree collections, which have the same methods for
39/// everything the core does with them.
40pub mod collections {
41    #[cfg(feature = "std")]
42    pub use std::collections::{HashMap, HashSet};
43
44    #[cfg(not(feature = "std"))]
45    pub use alloc::collections::{BTreeMap as HashMap, BTreeSet as HashSet};
46}
47
48pub mod attenuation;
49pub mod authority_state;
50pub mod credentials;
51pub mod data_integrity;
52pub mod decision;
53pub mod delegation;
54pub mod did_document;
55pub mod did_web;
56pub mod did_webvh;
57pub mod error;
58pub mod fleet;
59mod float;
60pub mod grant_chain;
61pub mod hybrid;
62pub mod issuance;
63pub mod jcs;
64pub mod keys;
65pub mod lineage;
66pub mod mldsa_check;
67pub mod multikey;
68pub mod nesting;
69pub mod pq;
70pub mod proof_json;
71mod py_printable;
72mod random;
73pub mod reasoning;
74pub mod reasoning_json;
75#[cfg(feature = "std")]
76pub mod recovery;
77#[cfg(feature = "std")]
78pub mod recovery_json;
79pub mod robotics;
80pub mod robotics_call;
81pub mod robotics_domain;
82pub mod robotics_dtn;
83pub mod robotics_json;
84pub mod robotics_prepare;
85pub mod robotics_segment;
86pub mod robotics_verify;
87pub mod root_of_trust;
88pub mod session_voucher;
89pub mod slh;
90pub mod status_list;
91#[cfg(feature = "std")]
92pub mod threshold;
93#[cfg(feature = "std")]
94pub mod threshold_json;
95pub mod time;
96pub mod time_json;
97pub mod zdeflate;
98
99pub use error::{CoreError, Result};
100
101/// The serde_json this core is built with. Callers build the `Value`s they
102/// pass in with it, so a `no_std` build gets the same serde_json features.
103pub use serde_json;