dpp_crypto/lib.rs
1//! `dpp-crypto` — cryptographic primitives: Ed25519 signing, JWS compact
2//! serialisation, and the encrypted keystore.
3//!
4//! All modules are pure (no I/O, no network). The crate compiles to `std` for
5//! the node and to `wasm32` (where conditional) for plugin guests.
6//!
7//! Verifiable Credentials, `did:web` documents and status lists are
8//! [`dpp-vc`]; the per-field disclosure contract is `dpp_domain::access`.
9//! Signing bytes is a different job from deciding whose signature means what,
10//! and a different job again from deciding which fields a role may see.
11//!
12//! With those gone this crate has **no workspace dependencies** — it is a leaf.
13//!
14//! [`dpp-vc`]: https://docs.rs/dpp-vc
15
16pub mod jades;
17pub mod jws;
18pub mod keystore;
19pub mod sd_jwt;
20
21#[cfg(test)]
22mod test_support;
23
24/// Infallible OS randomness source, used for Ed25519 key generation and
25/// AES-GCM nonce/salt generation. `SysRng` is fallible (`TryCryptoRng`);
26/// `UnwrapErr` panics on the (practically unreachable) OS-entropy-source
27/// failure instead of threading a `Result` through every call site.
28pub(crate) fn os_rng() -> rand::rand_core::UnwrapErr<rand::rngs::SysRng> {
29 rand::rand_core::UnwrapErr(rand::rngs::SysRng)
30}
31
32// ── Flat re-exports — maintain stable paths for external callers ─────────────
33
34/// Compile-checks this crate's README examples.
35///
36/// A README example is a public claim about the API, and nothing else in the
37/// build compiles one. Without this, a README can advertise a function that
38/// does not exist — which is exactly what happened before this harness landed.
39#[cfg(doctest)]
40#[doc = include_str!("../README.md")]
41struct ReadmeDoctests;