pub struct Keyring { /* private fields */ }Expand description
Verification keyring: key id → public key. Old receipts stay verifiable after rotation as long as their key remains in the ring.
Implementations§
Source§impl Keyring
impl Keyring
Sourcepub fn add_key_bytes(&mut self, bytes: &[u8; 32]) -> Result<String, KeyError>
pub fn add_key_bytes(&mut self, bytes: &[u8; 32]) -> Result<String, KeyError>
Add a key by raw public bytes; returns its derived key id.
If the derived id already exists with a different public key, refuses
silently overwriting it and returns KeyMismatch — otherwise an
attacker who found a 128-bit collision could substitute their key for
an honest signer’s.
Refuses small-order (weak) public keys — the identity point and the
order-2/order-4 torsion elements. Keyring::verify already routes
through verify_strict, which denies them at verification time; this
is defense-in-depth so a poisoned ring cannot even be constructed
and so no other consumer of the ring (e.g. Receipt::verify_embedded)
can be tricked by relying on a non-strict verify. See ed25519-dalek
3.0 VerifyingKey::is_weak / verify_strict.
Sourcepub fn add_signer(&mut self, signer: &dyn Signer) -> Result<String, KeyError>
pub fn add_signer(&mut self, signer: &dyn Signer) -> Result<String, KeyError>
Add the public half of a signer.
Sourcepub fn verify(
&self,
key_id: &str,
msg: &[u8],
sig: &[u8],
) -> Result<(), KeyError>
pub fn verify( &self, key_id: &str, msg: &[u8], sig: &[u8], ) -> Result<(), KeyError>
Verify sig over msg with the key identified by key_id.
Uses verify_strict (ed25519-dalek), NOT verify:
non-strict verify accepts signatures whose R component or the
verifying key itself is a small-order Curve25519 point. In that
regime a single signature can validate against multiple distinct
messages, so a mutated receipt body whose signature is untouched
can still verify. verify_strict rejects small-order R AND
small-order pubkeys (dalek verifying.rs:367-390 in 3.0.0) and is
the documented recommendation for new protocols.