Closed timothee-haudebourg closed 3 months ago
Also, I renamed the DIDResolver::with_default_options
function into into_vm_resolver
to make it clear that it turns a DID resolver into a verification method resolver.
I've renamed all the *Environment
traits into *Provider
, added a dedicated verify
function for each secured claim type (CompactJWS
, DecodedJWS
and DataIntegrity
), renamed Verifier
into VerificationParameters
and added more documentation about verification parameters.
Currently the
VerifiableClaims::verify
function (or more preciselyverify_with
) takes a "verifier" and an "environment". The "verifier" is in fact a public key resolver (W3C verification method resolver or JWK resolver, etc), while the environment provides any other resource required to validate the claims and signature.I realized there is no real reason to separate the resolver from the environment. Merging them into a single
verifier
allows us to remove an input argument to many functions (includingVerifiableClaims::verify
) and remove a type parameter to some traits. This is the purpose of this PR.Here is an overview of the changes:
environment
argument inVerifiableClaims::verify
, theverifier
is now the "environment".VerifiableClaims::verify_with
, now unnecessary.ResolverEnvironment
trait implemented by any type providing a public key resolver (similar to other*Environment
traits).Verifier
type, implementingResolverEnvironment
and all the commonly used*Environment
traits. This is the default built-in verifier type that works with most verifiable claims. It replaces the oldVerificationEnvironment
type.Validate
intoValidateClaims
.verifier
argument fromValidateProof
. NowValidateClaims
andValidateProof
are completely symmetrical.JWSVerifier
intoJWKResolver
. This makes the function of this trait clearer: its a type that can resolve a key id into a JWK. Just likeVerificationMethodResolver
resolves a key id into a W3C verification method.The only downside is that the
verify
function must take an actual verifier as parameter, and not just the public key resolver. A verifier can be built from a resolver usingVerifier::from_resolver
. It's one more step, but I also think it makes more sense while making customizing the verifier easier. For instance its possible to customize the JSON-LD context loader while constructing the verifier with one line:Before, you would need to construct your own verification environment and use
verify_with
instead ofverify
.