pub struct SignedCommit {
commit: Commit,
signature: [u8; 64],
}Expand description
A commit and the signature over it.
Fields§
§commit: Commit§signature: [u8; 64]Implementations§
Source§impl SignedCommit
impl SignedCommit
Sourcepub fn new(commit: Commit, signature: [u8; 64]) -> Self
pub fn new(commit: Commit, signature: [u8; 64]) -> Self
Reassembles a commit and a signature that were stored apart.
Sourcepub fn decode(block: &[u8]) -> Result<Self, CommitError>
pub fn decode(block: &[u8]) -> Result<Self, CommitError>
Reads a commit block another server wrote.
The block holds exactly the six fields a version 3 commit has, prev
included even when it is null. Anything else is refused here. A
field this left out of Commit::to_sign would fail the signature
anyway, so refusing it first says why.
Sourcepub fn verify(&self, key: &VerifyingKey) -> Result<(), CommitError>
pub fn verify(&self, key: &VerifyingKey) -> Result<(), CommitError>
Checks the signature against a public key.
The key must come from somewhere other than this object for the answer
to mean anything — a DID document, in practice. Verifying with the key
that signed proves the signing code is self-consistent and nothing
else; see tests/did_document.rs, which takes the key out of a
serialised document instead.
A high-S signature fails, because k256 refuses one internally and
atproto requires low-S. That is a known jacquard defect not applying to us,
rather than something handled here.
Sourcepub fn verify_for(
&self,
did: &str,
key: &VerifyingKey,
) -> Result<(), CommitError>
pub fn verify_for( &self, did: &str, key: &VerifyingKey, ) -> Result<(), CommitError>
Checks the signature, and that the commit is for the repository asked about.
The two go together far more often than either goes alone: a
signature that verifies against the key in did:web:a’s document, on
a commit whose did is did:web:b, is a valid signature and the
wrong answer.
Sourcepub fn verify_with(&self, did: &str, key: &CommitKey) -> Result<(), CommitError>
pub fn verify_with(&self, did: &str, key: &CommitKey) -> Result<(), CommitError>
SignedCommit::verify_for, with a key of either curve.
A P-256 signature with a high s fails, as a secp256k1 one does:
[secp256r1::VerifyingKey::verify] refuses it.
Sourcefn check_repo(&self, did: &str) -> Result<(), CommitError>
fn check_repo(&self, did: &str) -> Result<(), CommitError>
Refuses a commit for any repository but did’s.
Sourcefn check_version(&self) -> Result<(), CommitError>
fn check_version(&self) -> Result<(), CommitError>
Refuses a repository format this crate does not write.
Trait Implementations§
Source§impl Clone for SignedCommit
impl Clone for SignedCommit
Source§fn clone(&self) -> SignedCommit
fn clone(&self) -> SignedCommit
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 SignedCommit
impl Debug for SignedCommit
Source§impl PartialEq for SignedCommit
impl PartialEq for SignedCommit
Source§fn eq(&self, other: &SignedCommit) -> bool
fn eq(&self, other: &SignedCommit) -> bool
self and other values to be equal, and is used by ==.impl Eq for SignedCommit
impl StructuralPartialEq for SignedCommit
Auto Trait Implementations§
impl Freeze for SignedCommit
impl RefUnwindSafe for SignedCommit
impl Send for SignedCommit
impl Sync for SignedCommit
impl Unpin for SignedCommit
impl UnsafeUnpin for SignedCommit
impl UnwindSafe for SignedCommit
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.