pub struct ProvenanceSigner { /* private fields */ }Expand description
Provenance signer for UDM events.
Each signed event gets the next sequence number and this signer’s boot epoch in its provenance block. Clones share one sequence counter.
Implementations§
Source§impl ProvenanceSigner
impl ProvenanceSigner
Sourcepub fn from_config(config: &ProvenanceConfig) -> PhyTraceResult<Self>
pub fn from_config(config: &ProvenanceConfig) -> PhyTraceResult<Self>
Create an HMAC signer from configuration.
Hardware signers are not configured here; build one (e.g.
phytrace_tpm::TpmSigner) and pass it to Self::with_signer.
Fails if signed_fields is set: signatures always cover the whole
event, and silently ignoring a field list would misstate what is
signed. Also fails if sequence_path names an unreadable state file.
Sourcepub fn with_signer(
signer: Arc<dyn Signer>,
sequence_path: Option<&str>,
) -> PhyTraceResult<Self>
pub fn with_signer( signer: Arc<dyn Signer>, sequence_path: Option<&str>, ) -> PhyTraceResult<Self>
Create a provenance signer around any Signer, such as a TPM
signer. sequence_path is the sequence state file (see
ProvenanceConfig::sequence_path); None keeps the counter in
memory.
Sourcepub fn with_attestation(self, provider: Arc<dyn AttestationProvider>) -> Self
pub fn with_attestation(self, provider: Arc<dyn AttestationProvider>) -> Self
Put provider’s block in each event’s provenance.device_attestation
(signed with the rest of the provenance).
Sourcepub fn new(key_id: impl Into<String>, secret_key: Vec<u8>) -> Self
pub fn new(key_id: impl Into<String>, secret_key: Vec<u8>) -> Self
Create a new signer with raw key bytes and an in-memory sequence counter.
Sourcepub fn sign(&self, event: &mut UdmEvent) -> PhyTraceResult<()>
pub fn sign(&self, event: &mut UdmEvent) -> PhyTraceResult<()>
Sign an event and add provenance information.
The provenance block (signer class, key id, algorithm, signing time, sequence number, boot epoch) is attached first and signed together with the event; only the signature itself is outside the signed payload. Anything that changes the event or its provenance afterwards invalidates the signature.
Sourcepub fn sign_batch(&self, events: &mut [UdmEvent]) -> PhyTraceResult<()>
pub fn sign_batch(&self, events: &mut [UdmEvent]) -> PhyTraceResult<()>
Sign events as one Merkle batch (issue #392): number each event,
hash them into a Merkle tree, sign the batch statement (root,
sequence range, boot epoch and counter, key, attestation) once, and
give each event the statement, signature and its inclusion proof in
provenance.batch. One signer operation for the whole batch.
Sourcepub fn verify_batch_value(&self, event: &Value) -> PhyTraceResult<bool>
pub fn verify_batch_value(&self, event: &Value) -> PhyTraceResult<bool>
Verify a batch-signed event in JSON form: the statement’s signature and the event’s inclusion proof against the statement’s root.
Sourcepub fn verify(&self, event: &UdmEvent) -> PhyTraceResult<bool>
pub fn verify(&self, event: &UdmEvent) -> PhyTraceResult<bool>
Verify an event’s provenance signature.
Sourcepub fn signature_for_value(&self, event: &Value) -> PhyTraceResult<String>
pub fn signature_for_value(&self, event: &Value) -> PhyTraceResult<String>
Signature for an event in JSON form, e.g. as received over the wire.
Any provenance.signature in event is ignored; the rest of the
provenance block is signed. ES256 signatures are randomised, so
compare them with Self::verify_value, not by equality.
Sourcepub fn verify_value(&self, event: &Value) -> PhyTraceResult<bool>
pub fn verify_value(&self, event: &Value) -> PhyTraceResult<bool>
Verify an event in JSON form against its provenance.signature,
without deserialising it into SDK types (so unknown fields are
still covered).
Sourcepub fn close(&self) -> PhyTraceResult<()>
pub fn close(&self) -> PhyTraceResult<()>
Record the sequence counter’s exact position (clean shutdown), so a restart continues without a gap.
Sourcepub fn boot_epoch(&self) -> &str
pub fn boot_epoch(&self) -> &str
The random ID of this signer’s run, sent as provenance.boot_epoch.
Sourcepub fn sequence(&self) -> &SequenceCounter
pub fn sequence(&self) -> &SequenceCounter
The sequence counter that numbers signed events.