pub struct Commit {
pub did: String,
pub version: u64,
pub data: Cid,
pub rev: Tid,
pub prev: Option<Cid>,
pub sig: Vec<u8>,
/* private fields */
}Expand description
A signed commit — the unsigned commit plus its ES256 sig.
Fields§
§did: String§version: u64§data: Cid§rev: Tid§prev: Option<Cid>§sig: Vec<u8>Implementations§
Source§impl Commit
impl Commit
Sourcepub fn sign(unsigned: &UnsignedCommit, key: &SigningKey) -> Self
pub fn sign(unsigned: &UnsignedCommit, key: &SigningKey) -> Self
Sign an unsigned commit with a P-256 (#atproto) signing key,
producing a Commit.
The signature is ES256: ECDSA over SHA-256 of the unsigned commit’s
DAG-CBOR bytes. The signature is the fixed-width (64-byte) R‖V‖S
encoding — Signature::to_vec in p256 0.13 gives this form, which is
the JOSE/COSE/atproto-preferred raw concatenation (not DER).
Sourcepub fn sign_atproto(unsigned: &UnsignedCommit, key: &SigningKey) -> Result<Self>
pub fn sign_atproto(unsigned: &UnsignedCommit, key: &SigningKey) -> Result<Self>
Sign a commit using public AT Protocol canonical bytes.
Sourcepub fn from_atproto_signature(
unsigned: &UnsignedCommit,
signature: Vec<u8>,
verifying_key: &VerifyingKey,
) -> Result<Self>
pub fn from_atproto_signature( unsigned: &UnsignedCommit, signature: Vec<u8>, verifying_key: &VerifyingKey, ) -> Result<Self>
Build a public commit from a signature produced by an external signer.
The signer receives the exact canonical unsigned bytes and the supplied
verifying key is checked before the commit is marked as eligible for
public publication. This keeps private key material outside the repo
storage boundary while retaining the same signature and provenance
checks as Self::sign_atproto.
Sourcepub fn to_dag_cbor(&self) -> Vec<u8> ⓘ
pub fn to_dag_cbor(&self) -> Vec<u8> ⓘ
DAG-CBOR encode the (signed) commit. The sig field is a byte string.
Sourcepub fn to_atproto_dag_cbor(&self) -> Result<Vec<u8>>
pub fn to_atproto_dag_cbor(&self) -> Result<Vec<u8>>
Encode the signed commit using public AT Protocol canonical bytes.
pub fn to_value(&self) -> DagCbor
Classify this commit’s account DID as an accepted repo authority for our
PDS (did:web/did:plc/did:at9p), or Err if the method is not one we
host a repo for.
This is the method-level acceptance gate (#908); it is independent of and
additional to the signature check in Commit::verify. A caller ingesting
a commit should accept the authority and verify the signature.
Sourcepub fn unsigned(&self) -> UnsignedCommit
pub fn unsigned(&self) -> UnsignedCommit
The UnsignedCommit form of this commit (drops sig).
Sourcepub fn from_dag_cbor(bytes: &[u8]) -> Result<Self>
pub fn from_dag_cbor(bytes: &[u8]) -> Result<Self>
Decode a signed commit from DAG-CBOR bytes, validating structure.
pub fn from_atproto_dag_cbor(bytes: &[u8]) -> Result<Self>
pub fn from_value(value: &DagCbor) -> Result<Self>
Sourcepub fn verify_atproto_and_mark(self, vk: &VerifyingKey) -> Result<Self>
pub fn verify_atproto_and_mark(self, vk: &VerifyingKey) -> Result<Self>
Verify a decoded public commit with the account’s published
#atproto key and mark the value eligible for public CAR publication.
Canonical decoding alone is not signature provenance: a native commit can be re-encoded into the public shape, and its bytes remain perfectly canonical. This explicit key-bound verification is therefore required before a decoded value crosses the public publication boundary.
pub fn cid_atproto(&self) -> Result<Cid>
Sourcepub fn verify(&self, vk: &VerifyingKey) -> Result<()>
pub fn verify(&self, vk: &VerifyingKey) -> Result<()>
Verify the commit’s signature against a #atproto P-256 verifying key.
Re-encodes the unsigned commit, hashes with SHA-256, and verifies the
ES256 signature. Returns Ok(()) on success.
This is the core of the D5 untrusted-host posture: a host can serve any
commit it likes, but only commits signed by the account’s #atproto
key are accepted by verifiers.
For a rotated key set, use Commit::verify_against_published_keys.
That path accepts only the active key and bounded, currently-live
#atproto_drain / #atproto_lead keys published in the DID document.
pub fn verify_atproto(&self, vk: &VerifyingKey) -> Result<()>
Sourcepub fn verify_against_published_keys(
&self,
keys: &PublishedAtprotoKeys,
now: i64,
) -> Result<()>
pub fn verify_against_published_keys( &self, keys: &PublishedAtprotoKeys, now: i64, ) -> Result<()>
Verify against the bounded #atproto slot set currently published by a
DID document. This is an overlap-availability mechanism: it accepts a
pre-rotation commit under the bounded drain key, but does not establish
that a key was valid at the commit’s causal position (that is #1169).
Sourcepub fn unsigned_digest(unsigned: &UnsignedCommit) -> [u8; 32]
pub fn unsigned_digest(unsigned: &UnsignedCommit) -> [u8; 32]
Compute the SHA-256 digest of the unsigned commit’s DAG-CBOR bytes.
Exposed for callers that compose their own signing/verification flow
(e.g. using the DID’s key material from hyprstream::auth::key_rotation
directly). Standard ES256 signers hash internally, so most callers want
Commit::sign / Commit::verify instead.
Trait Implementations§
impl Eq for Commit
impl StructuralPartialEq for Commit
Auto Trait Implementations§
impl Freeze for Commit
impl RefUnwindSafe for Commit
impl Send for Commit
impl Sync for Commit
impl Unpin for Commit
impl UnsafeUnpin for Commit
impl UnwindSafe for Commit
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
key and return true if they are equal.§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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more