baseid_vc/proof.rs
1//! Data Integrity proof types.
2
3use serde::{Deserialize, Serialize};
4
5/// Supported Data Integrity cryptosuites.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7pub enum Cryptosuite {
8 /// Ed25519 signature with JCS canonicalization.
9 ///
10 /// Note: This implementation uses JCS (RFC 8785) for canonicalization
11 /// rather than full RDFC-1.0 (JSON-LD RDF Dataset Canonicalization).
12 /// Full RDFC-1.0 support is planned for a future release.
13 #[serde(rename = "eddsa-rdfc-2022")]
14 EddsaRdfc2022,
15}
16
17impl Cryptosuite {
18 /// String representation per W3C Data Integrity spec.
19 pub fn as_str(&self) -> &'static str {
20 match self {
21 Self::EddsaRdfc2022 => "eddsa-rdfc-2022",
22 }
23 }
24
25 /// Parse from string.
26 pub fn parse_str(s: &str) -> Option<Self> {
27 match s {
28 "eddsa-rdfc-2022" => Some(Self::EddsaRdfc2022),
29 _ => None,
30 }
31 }
32}
33
34/// A Data Integrity proof on a Verifiable Credential or Presentation.
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(rename_all = "camelCase")]
37pub struct DataIntegrityProof {
38 /// Proof type (always "DataIntegrityProof").
39 pub r#type: String,
40 /// The cryptosuite used.
41 pub cryptosuite: String,
42 /// When the proof was created (RFC 3339).
43 pub created: String,
44 /// The verification method (key) used.
45 pub verification_method: String,
46 /// The purpose of the proof (e.g., "assertionMethod").
47 pub proof_purpose: String,
48 /// The proof value (multibase-encoded signature).
49 pub proof_value: String,
50}