Skip to main content

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 jws;
17pub mod keystore;
18
19#[cfg(test)]
20mod test_support;
21
22/// Infallible OS randomness source, used for Ed25519 key generation and
23/// AES-GCM nonce/salt generation. `SysRng` is fallible (`TryCryptoRng`);
24/// `UnwrapErr` panics on the (practically unreachable) OS-entropy-source
25/// failure instead of threading a `Result` through every call site.
26pub(crate) fn os_rng() -> rand::rand_core::UnwrapErr<rand::rngs::SysRng> {
27    rand::rand_core::UnwrapErr(rand::rngs::SysRng)
28}
29
30// ── Flat re-exports — maintain stable paths for external callers ─────────────
31
32/// Compile-checks this crate's README examples.
33///
34/// A README example is a public claim about the API, and nothing else in the
35/// build compiles one. Without this, a README can advertise a function that
36/// does not exist — which is exactly what happened before this harness landed.
37#[cfg(doctest)]
38#[doc = include_str!("../README.md")]
39struct ReadmeDoctests;