-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Verifier simplification. #559
Conversation
Also, I renamed the |
@@ -98,3 +93,135 @@ pub enum Invalid { | |||
#[error("invalid proof: {0}")] | |||
Proof(#[from] InvalidProof), | |||
} | |||
|
|||
/// Public key resolver environment. | |||
pub trait ResolverEnvironment { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if environment is the right term. In SIWE for example, you provide "verification parameters" which can include a different time from now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's the same idea with the *Environment
traits. For now we have DateTimeEnvironment
, ResolverEnvironment
, ContextLoaderEnvironment
and Eip712TypesEnvironment
, and probably more in the future. I agree "Environment" may not be the best term, but I couldn't come up with a better one yet. Maybe "Provider".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After talking about it with Jacob, we decided to use Provider
instead of Environment
ed0c7a0
to
c67ad8c
Compare
Add `ResolverEnvironment`. Rename `Validate` into `ValidateClaims` trait.
Rename `Verifier` type into `VerificationParameters`. Add dedicated `verify` methods for secured claims types (`CompactJWS`, `DecodedJWS` and `DataIntegrity`). Add documentation.
51d7a90
to
d22cb27
Compare
I've renamed all the |
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
.