vox_trust_core/lib.rs
1//! Core of the Vox Trust protocol (pre-alpha, API unstable, not audited).
2//!
3//! - [`seal`]: the 102-bit in-band seal layout.
4//! - [`circle`]: the circle-mode authentication tag (shared secret, HMAC-SHA-256).
5//! - [`pairing`]: the text exchanged in person (for example in a QR code) to share a key.
6//! - [`policy`]: the trust-policy decision table.
7//! - [`replay`]: replay detection and failure rate limiting for verifiers.
8//! - [`wav`] and [`mod@file`]: *file mode*, a signed manifest that travels inside a WAV
9//! file and shows which chunks of audio were altered.
10//!
11//! There is **no audio watermark** here yet: file mode only survives bit-exact copies.
12//! See the specification and threat model in the repository before relying on any of it.
13
14#![forbid(unsafe_code)]
15#![deny(missing_docs)]
16
17pub mod circle;
18mod crypto;
19pub mod file;
20pub mod pairing;
21pub mod policy;
22pub mod replay;
23pub mod seal;
24pub mod wav;
25
26pub use policy::{decide, ContactState, SealCheck, Verdict};
27pub use seal::{coarse_time, DecodeError, EncodeError, Mode, Seal, SEAL_BITS, SEAL_BYTES};
28
29/// Lower-case hexadecimal encoding, used by reports and test vectors.
30pub fn to_hex(bytes: &[u8]) -> String {
31 const DIGITS: &[u8; 16] = b"0123456789abcdef";
32 let mut out = String::with_capacity(bytes.len() * 2);
33 for &b in bytes {
34 out.push(DIGITS[(b >> 4) as usize] as char);
35 out.push(DIGITS[(b & 0x0F) as usize] as char);
36 }
37 out
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn hex_encoding() {
46 assert_eq!(to_hex(&[]), "");
47 assert_eq!(to_hex(&[0x00, 0x0f, 0xa5, 0xff]), "000fa5ff");
48 }
49}