pub struct SignedNote { /* private fields */ }Expand description
A parsed signed note: the signed text plus its (still unverified) signature lines.
Implementations§
Source§impl SignedNote
impl SignedNote
Sourcepub fn new(text: String, signatures: Vec<Signature>) -> Result<Self>
pub fn new(text: String, signatures: Vec<Signature>) -> Result<Self>
Create a signed note from text and signatures.
§Errors
Returns Error::MalformedNote if text does not end in a newline.
Sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
The note text (including its final newline; excluding the separating blank line). This is the exact byte string signatures are computed over.
Sourcepub fn signatures(&self) -> &[Signature]
pub fn signatures(&self) -> &[Signature]
The parsed signature lines.
Sourcepub fn parse(msg: &str) -> Result<Self>
pub fn parse(msg: &str) -> Result<Self>
Parse a complete signed-note byte string.
Mirrors the reference Go note.Open structural parse: validates UTF-8
and the no-control-characters rule, splits the text from the trailing
signature block at the last blank line, and parses each signature
line. Signatures are not verified here; call SignedNote::verify.
§Errors
Returns Error::MalformedNote for any structural violation.
Sourcepub fn marshal(&self) -> String
pub fn marshal(&self) -> String
Serialize this signed note to its canonical byte string:
text || "\n" || signature lines.
Sourcepub fn verify<'a>(
&'a self,
trusted: &[VerifierKey],
) -> Result<Vec<&'a Signature>>
pub fn verify<'a>( &'a self, trusted: &[VerifierKey], ) -> Result<Vec<&'a Signature>>
Verify the note against a set of trusted verifier keys.
Following the C2SP signed-note rules:
- signatures whose
(name, key id)match no trusted key are ignored; - if a signature from a known key fails to verify, the whole note is
rejected (
Error::InvalidSignature); - if no signature from a trusted key verifies, the note is rejected
(
Error::NoTrustedSignature).
On success returns references to the signatures that verified.
§Errors
Error::InvalidSignature or Error::NoTrustedSignature as above.
Trait Implementations§
Source§impl Clone for SignedNote
impl Clone for SignedNote
Source§fn clone(&self) -> SignedNote
fn clone(&self) -> SignedNote
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SignedNote
impl Debug for SignedNote
impl Eq for SignedNote
Source§impl PartialEq for SignedNote
impl PartialEq for SignedNote
Source§fn eq(&self, other: &SignedNote) -> bool
fn eq(&self, other: &SignedNote) -> bool
self and other values to be equal, and is used by ==.