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: StringFixed: "Ed25519Signature2020"
created: StringISO 8601 timestamp of when the proof was created.
verification_method: StringReference to the verification method used (e.g., did:oas:ns:hmr:a#key-1).
proof_purpose: StringThe purpose of this proof (e.g., "assertionMethod").
proof_value: StringThe multibase-encoded Ed25519 signature (base58btc with z prefix).
Implementations§
Source§impl DocumentProof
impl DocumentProof
Sourcepub fn generate(
document_json: &Value,
keypair: &OasKeyPair,
verification_method_id: &str,
created: &str,
) -> Result<Self, DocumentError>
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:
- Canonicalize the document (without proof) via JCS
- Sign the canonical bytes with the signing key
- 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.
Sourcepub fn verify(
&self,
document_json: &Value,
public_key_bytes: &[u8],
) -> Result<(), DocumentError>
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:
- Canonicalize the document (without proof) via JCS
- Decode the proof value from multibase
- 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.