pub struct SignedAuditEvent {
pub event: AuditEvent,
pub signature: Vec<u8>,
}Expand description
A signed audit event: an AuditEvent plus PQC signature bytes.
Produced by AuditEvent::sign. Verify with SignedAuditEvent::verify.
§Examples
use okami::identity::AgentIdentity;
use okami::audit::{AuditEvent, SignedAuditEvent};
let identity = AgentIdentity::new("example.com", "agent/worker").unwrap();
let vk_bytes = identity.credential().verifying_key_bytes.clone();
let ev = AuditEvent::new(
identity.spiffe_id().clone(),
"key.rotated",
serde_json::json!({}),
None,
);
let signed: SignedAuditEvent = ev.sign(&identity).unwrap();
// Signature is valid with the correct key.
assert!(signed.verify(&vk_bytes).unwrap());
// Round-trip through bytes.
let bytes = signed.to_bytes().unwrap();
let signed2 = SignedAuditEvent::from_bytes(&bytes).unwrap();
assert!(signed2.verify(&vk_bytes).unwrap());Fields§
§event: AuditEventThe audit event payload.
signature: Vec<u8>PQC signature over the bincode-serialized event bytes.
Implementations§
Source§impl SignedAuditEvent
impl SignedAuditEvent
Sourcepub fn verify(&self, verifying_key_bytes: &[u8]) -> Result<bool>
pub fn verify(&self, verifying_key_bytes: &[u8]) -> Result<bool>
Verify the PQC signature on this event.
Serializes the event to bincode and verifies the signature against the provided verifying key.
Returns Ok(true) if the signature is valid, Ok(false) if not.
§Errors
Returns Error::Serialization if the event cannot be re-serialized,
or Error::Crypto if the verifying key is structurally invalid.
Sourcepub fn hash_hex(&self) -> Result<String>
pub fn hash_hex(&self) -> Result<String>
Compute the SHA-256 hex digest of this signed event’s bincode bytes.
Pass the result as previous_event_hash to the next AuditEvent::new
call to link the chain.
§Errors
Returns Error::Serialization if serialization fails.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Deserialize from bytes (bincode).
Enforces a MAX_SIGNED_AUDIT_EVENT_BYTES allocation cap to prevent DoS
via crafted length-prefix fields. See /cso audit Finding #4 (fingerprint
30a553fc).
§Errors
Returns Error::Serialization if the input exceeds MAX_SIGNED_AUDIT_EVENT_BYTES or
if bincode decoding fails.
Trait Implementations§
Source§impl Clone for SignedAuditEvent
impl Clone for SignedAuditEvent
Source§fn clone(&self) -> SignedAuditEvent
fn clone(&self) -> SignedAuditEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more