Skip to main content

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`], [`seal`],
10//! [`checkpoint`], and [`tlog`] modules are implemented on top of these
11//! 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;
30pub mod ca;
31pub mod checkpoint;
32pub mod error;
33pub mod keys;
34pub mod merkle;
35pub mod seal;
36pub mod tlog;
37
38pub use error::{TrustError, TrustResult};
39pub use keys::Ed25519Identity;
40
41/// Lowercase hex encoding of a byte slice.
42pub(crate) fn hex_lower(bytes: &[u8]) -> String {
43    use std::fmt::Write;
44    let mut s = String::with_capacity(bytes.len() * 2);
45    for b in bytes {
46        // Deliberate discard: `fmt::Write` for `String` is infallible —
47        // writing to an in-memory String can never return an error.
48        let _ = s.write_fmt(format_args!("{b:02x}"));
49    }
50    s
51}