voided_core/lib.rs
1//! # voided-core
2//!
3//! Core cryptographic primitives for the Voided encryption library.
4//!
5//! This crate provides the source-of-truth implementation for all crypto operations,
6//! ensuring identical behavior across Node.js (native binding) and browser (WASM) targets.
7//!
8//! ## Features
9//!
10//! - `backend` - Full feature set for Node.js backend (default)
11//! - `browser` - Browser-compatible subset for WASM
12//! - `compression` - Brotli and Gzip compression
13//! - `signing` - Digital signatures (Ed25519, ECDSA, RSA-PSS)
14//!
15//! ## Example
16//!
17//! ```rust
18//! use voided_core::encryption;
19//!
20//! // Generate a key
21//! let key = encryption::generate_key();
22//!
23//! // Encrypt some data
24//! let plaintext = b"Hello, World!";
25//! let encrypted = encryption::encrypt(plaintext, &key, None).unwrap();
26//!
27//! // Decrypt it back
28//! let decrypted = encryption::decrypt(&encrypted, &key).unwrap();
29//! assert_eq!(plaintext, &decrypted[..]);
30//! ```
31
32#![cfg_attr(not(feature = "std"), no_std)]
33#![deny(unsafe_code)]
34#![warn(missing_docs)]
35#![warn(clippy::all)]
36
37extern crate alloc;
38
39pub mod encryption;
40pub mod formats;
41pub mod hash;
42pub mod shell;
43pub mod util;
44
45#[cfg(feature = "compression")]
46pub mod compression;
47
48#[cfg(feature = "signing")]
49pub mod signing;
50
51#[cfg(feature = "signing")]
52pub use signing::{generate_ed25519_key_pair, sign_ed25519, verify_ed25519};
53
54mod error;
55pub use error::{Error, Result};
56
57/// Library version
58pub const VERSION: &str = env!("CARGO_PKG_VERSION");
59
60/// Wire format version
61pub const FORMAT_VERSION: u8 = 0x01;
62
63/// Magic bytes for encrypted payloads
64pub const MAGIC_ENCRYPTED: &[u8; 4] = b"VOI1";
65
66/// Magic bytes for signatures
67pub const MAGIC_SIGNATURE: &[u8; 4] = b"VOIS";
68
69/// Magic bytes for compression header
70pub const MAGIC_COMPRESSED: &[u8; 2] = b"VC";