#[non_exhaustive]pub struct DataIntegrityProof {
pub type_: String,
pub cryptosuite: CryptoSuite,
pub created: Option<String>,
pub verification_method: String,
pub proof_purpose: String,
pub proof_value: Option<String>,
pub nonce: Option<String>,
pub context: Option<Vec<String>>,
}Expand description
Serialized Data Integrity proof.
#[non_exhaustive]: produce via DataIntegrityProof::sign or
DataIntegrityProof::new rather than a struct literal. Fields stay public
for reads.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.type_: StringMust be ‘DataIntegrityProof’
cryptosuite: CryptoSuite§created: Option<String>§verification_method: String§proof_purpose: String§proof_value: Option<String>§nonce: Option<String>The proof’s nonce (VC Data Integrity §2.1), an optional value the
proof creator supplies to reduce linkability between signatures.
It carries no verification semantics of its own, but it is part of the
proof configuration, and every cryptosuite hashes the proof
configuration. Without this field serde dropped a producer’s nonce on
deserialize, so verify re-hashed a configuration the
producer never signed and rejected a valid proof as
signature invalid. Producers that set one — affinidi-ssi-dart does on
every proof — could not be verified here at all.
This crate’s own signer does not set it.
context: Option<Vec<String>>Implementations§
Source§impl DataIntegrityProof
impl DataIntegrityProof
Sourcepub async fn sign_multi<S>(
data_doc: &S,
signers: &[&dyn Signer],
options: SignOptions,
) -> Result<Vec<DataIntegrityProof>, DataIntegrityError>where
S: Serialize,
pub async fn sign_multi<S>(
data_doc: &S,
signers: &[&dyn Signer],
options: SignOptions,
) -> Result<Vec<DataIntegrityProof>, DataIntegrityError>where
S: Serialize,
Signs data_doc with every signer in signers, producing one
DataIntegrityProof per signer.
Fail-fast: if any signer errors, no proofs are emitted and the error is returned immediately.
All signers share the same SignOptions — the per-signer
cryptosuite still defaults via Signer::cryptosuite, so a
heterogeneous list of signers (Ed25519 + ML-DSA-44) produces one
proof per suite automatically.
Source§impl DataIntegrityProof
impl DataIntegrityProof
Sourcepub fn new(
cryptosuite: CryptoSuite,
verification_method: String,
proof_purpose: String,
proof_value: Option<String>,
created: Option<String>,
context: Option<Vec<String>>,
) -> Self
pub fn new( cryptosuite: CryptoSuite, verification_method: String, proof_purpose: String, proof_value: Option<String>, created: Option<String>, context: Option<Vec<String>>, ) -> Self
Assemble a Data Integrity proof from its parts. type_ is fixed to
"DataIntegrityProof". Most callers should use DataIntegrityProof::sign;
this is for reconstructing a proof from known components (e.g. tests or
custom flows).
Sourcepub async fn sign<S>(
data_doc: &S,
signer: &dyn Signer,
options: SignOptions,
) -> Result<DataIntegrityProof, DataIntegrityError>where
S: Serialize,
pub async fn sign<S>(
data_doc: &S,
signer: &dyn Signer,
options: SignOptions,
) -> Result<DataIntegrityProof, DataIntegrityError>where
S: Serialize,
Produces a Data Integrity proof over data_doc.
The cryptosuite is picked from SignOptions::cryptosuite if
set, otherwise from Signer::cryptosuite. Canonicalization
(JCS or RDFC) is derived from the suite.
Sourcepub fn verify_with_public_key<S>(
&self,
data_doc: &S,
public_key_bytes: &[u8],
options: VerifyOptions,
) -> Result<(), DataIntegrityError>where
S: Serialize,
pub fn verify_with_public_key<S>(
&self,
data_doc: &S,
public_key_bytes: &[u8],
options: VerifyOptions,
) -> Result<(), DataIntegrityError>where
S: Serialize,
Verifies a proof against data_doc using caller-provided public
key bytes.
Sync because this is pure CPU — callers who already have the key
should not be forced into an async runtime. See verify for
the resolver-based async variant.
Sourcepub async fn verify<S, R>(
&self,
data_doc: &S,
resolver: &R,
options: VerifyOptions,
) -> Result<(), DataIntegrityError>
pub async fn verify<S, R>( &self, data_doc: &S, resolver: &R, options: VerifyOptions, ) -> Result<(), DataIntegrityError>
Verifies a proof by resolving the public key from its
verificationMethod via a VerificationMethodResolver.
Use did_vm::DidKeyResolver for did:key: URIs (no I/O); plug
in a custom resolver for did:web, did:webvh, or any other
method. The library also checks that the resolved key’s
KeyType matches the proof’s cryptosuite — a cheap guard
against “right proof, wrong key” class bugs.
Async because typical resolvers perform I/O (HTTP, cache lookups, HSM introspection).
Trait Implementations§
Source§impl Clone for DataIntegrityProof
impl Clone for DataIntegrityProof
Source§fn clone(&self) -> DataIntegrityProof
fn clone(&self) -> DataIntegrityProof
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more