Skip to main content

DocumentProof

Struct DocumentProof 

Source
pub struct DocumentProof {
    pub proof_type: String,
    pub created: String,
    pub verification_method: String,
    pub proof_purpose: String,
    pub proof_value: String,
}
Expand description

An Ed25519Signature2020 document proof.

See OAS Specification §5.5 for the complete format.

Fields§

§proof_type: String

Fixed: "Ed25519Signature2020"

§created: String

ISO 8601 timestamp of when the proof was created.

§verification_method: String

Reference to the verification method used (e.g., did:oas:ns:hmr:a#key-1).

§proof_purpose: String

The purpose of this proof (e.g., "assertionMethod").

§proof_value: String

The multibase-encoded Ed25519 signature (base58btc with z prefix).

Implementations§

Source§

impl DocumentProof

Source

pub fn generate( document_json: &Value, keypair: &OasKeyPair, verification_method_id: &str, created: &str, ) -> Result<Self, DocumentError>

Generates a document proof by signing the canonical document bytes.

Implements OAS Specification §5.5:

  1. Canonicalize the document (without proof) via JCS
  2. Sign the canonical bytes with the signing key
  3. Encode as multibase base58btc
§Arguments
  • document_json - The document as a JSON value (proof field MUST be absent/null).
  • keypair - The signing keypair.
  • verification_method_id - Full ID of the verification method (e.g., did:oas:ns:hmr:a#key-1).
  • created - ISO 8601 timestamp for the proof.
§Returns

A DocumentProof containing the signature.

§Errors

Returns DocumentError::ProofGenerationFailed if canonicalization or signing fails.

Source

pub fn verify( &self, document_json: &Value, public_key_bytes: &[u8], ) -> Result<(), DocumentError>

Verifies this document proof against the canonical document bytes.

Implements OAS Specification §5.5 verification:

  1. Canonicalize the document (without proof) via JCS
  2. Decode the proof value from multibase
  3. Verify the Ed25519 signature
§Arguments
  • document_json - The document as a JSON value (proof field MUST be absent/null).
  • public_key_bytes - The 32-byte Ed25519 public key.
§Returns

Ok(()) if the proof is valid.

§Errors

Returns DocumentError::ProofVerificationFailed if verification fails.

Trait Implementations§

Source§

impl Clone for DocumentProof

Source§

fn clone(&self) -> Self

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 DocumentProof

Source§

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

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

impl<'de> Deserialize<'de> for DocumentProof

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 Eq for DocumentProof

Source§

impl PartialEq for DocumentProof

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for DocumentProof

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 StructuralPartialEq for DocumentProof

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V