lys_core/lib.rs
1//! `lys-core` — domain-agnostic cryptographic trust primitives.
2//!
3//! A focused library of trust primitives: certificate authority operations,
4//! Merkle transparency-log operations, signed attestations, sealed payload
5//! transport, and Ed25519 key management. Consumers compose domain meaning
6//! on top — this crate knows nothing about any higher-level concepts.
7//!
8//! The foundation laid here is [`TrustError`], [`TrustResult`], and
9//! [`Ed25519Identity`]. The [`ca`], [`merkle`], [`attestation`], [`receipt`],
10//! [`bundle`], [`seal`], [`checkpoint`], and [`tlog`] modules are implemented on top of
11//! these primitives.
12//!
13//! ```
14//! use lys_core::TrustResult;
15//!
16//! fn fallible_op() -> TrustResult<()> {
17//! Ok(())
18//! }
19//!
20//! assert!(fallible_op().is_ok());
21//! ```
22
23// Library code contains no unsafe whatsoever. Test builds relax `forbid` to
24// the workspace-level `deny` because the env-backed tests must call
25// `std::env::set_var` (unsafe in edition 2024) under `#[allow(unsafe_code)]`,
26// which a crate-level `forbid` would reject outright.
27#![cfg_attr(not(test), forbid(unsafe_code))]
28
29pub mod attestation;
30#[cfg(feature = "unstable-anchor")]
31pub mod bundle;
32pub mod ca;
33mod cbor;
34pub mod checkpoint;
35pub mod error;
36pub mod keys;
37pub mod merkle;
38#[cfg(feature = "unstable-anchor")]
39pub mod receipt;
40pub mod seal;
41pub mod tlog;
42
43pub use error::{TrustError, TrustResult};
44pub use keys::Ed25519Identity;
45
46/// Lowercase hex encoding of a byte slice.
47pub(crate) fn hex_lower(bytes: &[u8]) -> String {
48 use std::fmt::Write;
49 let mut s = String::with_capacity(bytes.len() * 2);
50 for b in bytes {
51 // Deliberate discard: `fmt::Write` for `String` is infallible —
52 // writing to an in-memory String can never return an error.
53 let _ = s.write_fmt(format_args!("{b:02x}"));
54 }
55 s
56}