Skip to main content

Witness

Struct Witness 

Source
pub struct Witness {
    pub key_id: String,
    pub signature: Vec<u8>,
    pub scheme: Option<u16>,
    pub authenticator_data: Option<Vec<u8>>,
    pub client_data_json: Option<Vec<u8>>,
    pub credential_key: Option<Vec<u8>>,
}
Expand description

A cosignature: a witness cosignature (never populated here, D67) or, in OpEntry::author_sig, the author’s own. Present in the format from the first persisted byte so adding witnessing never rewrites history.

The scheme and WebAuthn fields are additive (serde(default) plus skip_serializing_if), so a signature written before D39 serializes to exactly the bytes it always did and every entry hash containing one is unchanged.

Fields§

§key_id: String

Identifier of the witness key that produced Witness::signature.

§signature: Vec<u8>

Signature over the entry’s content hash.

§scheme: Option<u16>

Which scheme produced Witness::signature, from scheme.

Absent means scheme::ED25519: entries written before D39 carry no tag, and giving them one would change their bytes and therefore their hash. An unrecognised value decodes fine on purpose — an old reader must be able to replay a log containing a scheme it cannot verify, so the refusal belongs at verification rather than at decode.

§authenticator_data: Option<Vec<u8>>

WebAuthn authenticator data, the first half of what a scheme::WEBAUTHN_ES256 signature covers. Absent for every other scheme.

§client_data_json: Option<Vec<u8>>

WebAuthn client data JSON, whose challenge member carries the OpEntry::signing_hash the human approved. Absent for every other scheme.

§credential_key: Option<Vec<u8>>

The credential’s public key as SubjectPublicKeyInfo DER, so a scheme::WEBAUTHN_ES256 signature can be checked by someone holding nothing but the log (D45). Absent for every other scheme, and absent from entries written before D45.

The other two WebAuthn fields are inside what the authenticator signed, so altering them breaks the signature. This one is the key the signature is checked against, so altering it forges nothing — it stops a good entry from verifying. It is covered by OpEntry::content_hash and therefore by the chain, which is what makes that substitution detectable; it is not covered by OpEntry::signing_hash, and calling it signed would be wrong.

Written by the node from the credential it just verified against, never by the client: getPublicKey() exists on a WebAuthn registration response only, so a browser holding an assertion does not have this value to send.

Implementations§

Source§

impl Witness

Source

pub fn ed25519(key_id: impl Into<String>, signature: Vec<u8>) -> Self

An ed25519 cosignature, the shape every caller before D39 wrote as a struct literal.

Source

pub fn webauthn_es256( key_id: impl Into<String>, signature: Vec<u8>, authenticator_data: Vec<u8>, client_data_json: Vec<u8>, ) -> Self

A WebAuthn ES256 cosignature (D39), carrying the two byte strings a verifier needs and cannot reconstruct: the authenticator data, and the client data JSON whose challenge binds the signature to one OpEntry::signing_hash.

Source

pub fn with_credential_key(self, spki_der: Vec<u8>) -> Self

Attaches the credential public key a verifier needs (D45).

A builder rather than a fifth argument to Witness::webauthn_es256, because the two values arrive at different moments: the browser sends the assertion, and the node adds the key after looking it up to verify against.

Source

pub fn scheme_id(&self) -> u16

The scheme this signature claims, resolving the pre-D39 absence to scheme::ED25519. Verifiers should match on this rather than on Witness::scheme directly, so the two spellings of ed25519 never diverge.

Trait Implementations§

Source§

impl Clone for Witness

Source§

fn clone(&self) -> Witness

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Witness

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Witness

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Witness

Source§

fn eq(&self, other: &Witness) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Witness

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Witness

Source§

impl StructuralPartialEq for Witness

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,