pub struct Signed {
pub domain: Domain,
pub payload: Vec<u8>,
pub signatures: Vec<SignatureEntry>,
}Expand description
A record’s CBOR bytes plus signatures.
Fields§
§domain: DomainWhat the record is.
payload: Vec<u8>The record’s exact CBOR encoding.
signatures: Vec<SignatureEntry>Signatures, in any order.
Implementations§
Source§impl Signed
impl Signed
Sourcepub fn sign<T: Serialize>(
domain: Domain,
value: &T,
keys: &[&SigningKey],
) -> Result<Self>
pub fn sign<T: Serialize>( domain: Domain, value: &T, keys: &[&SigningKey], ) -> Result<Self>
Encodes value and signs it with each key (k-of-n signers may also add theirs later
with Signed::add_signature).
Sourcepub fn add_signature(&mut self, key: &SigningKey)
pub fn add_signature(&mut self, key: &SigningKey)
Adds (or replaces) key’s signature.
Sourcepub fn verify_threshold(
&self,
domain: Domain,
trusted: &[PublicKey],
threshold: usize,
) -> Result<()>
pub fn verify_threshold( &self, domain: Domain, trusted: &[PublicKey], threshold: usize, ) -> Result<()>
Checks that at least threshold distinct keys from trusted made valid signatures.
Signatures from other keys, and repeated signatures from one key, don’t count.
Sourcepub fn decode<T: DeserializeOwned>(&self) -> Result<T>
pub fn decode<T: DeserializeOwned>(&self) -> Result<T>
Decodes the payload. Call only after Signed::verify_threshold, or on data whose
trust is checked another way (an initial root is checked against its pin).
Sourcepub fn payload_hash(&self) -> Hash32
pub fn payload_hash(&self) -> Hash32
BLAKE3 of the payload; freshness records name a manifest by it.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Parses an envelope, refusing anything over MAX_ENVELOPE_BYTES.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Signed
impl<'de> Deserialize<'de> for Signed
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Signed
impl StructuralPartialEq for Signed
Auto Trait Implementations§
impl Forget for Signed
impl Freeze for Signed
impl Move for Signed
impl RefUnwindSafe for Signed
impl Send for Signed
impl Sync for Signed
impl Unpin for Signed
impl UnsafeUnpin for Signed
impl UnwindSafe for Signed
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more