spruceid / ssi

Core library for decentralized identity.
https://spruceid.dev
Apache License 2.0
180 stars 54 forks source link

One step signature and verification #552

Closed timothee-haudebourg closed 4 weeks ago

timothee-haudebourg commented 4 weeks ago

This PR is about simplifying how ssi process a set of claims for signature and/or verification.

How it works currently

Currently signature and verification are both done in two steps.

Signature

Verification

The Verifiable type

The Verifiable<T, P> type is here to hold the "prepared" proof. The preparation holds all the intermediate data common to signature and verification. For instance for Data-Integrity suites using Linked-Data, preparing the proof will mean doing the JSON-LD expansion and RDF canonicalization, required by both signature and verification.

In theory this has a number of advantages:

The issue

After using this design for a while, I've found a lot of issue that I think are not worth the benefits:

Solution

The solution implemented by this PR is as follows:

timothee-haudebourg commented 4 weeks ago

is CryptographicSuite the correct term? I know "cryptosuite" is often used in specs, should we use that instead?

I often ask myself the same question. "Cryptographic Suite" is clearly the official name as you can see here, but "cryptosuite" is used everywhere as a shorthand, so much that its starting to feel like the de facto name. I don't have a strong opinion on which one we should use. My only argument is that my spell checker doesn't recognize "cryptosuite".

how does one provide the context loader now? Is it as part of the VM/DID resolver?

Instead of CruptographicSuite::sign you can use sign_with to provide a custom environment. The environment can be any type that provides a JSON-LD loader. The default type is SignatureEnvironment that you could reuse with a custom loader.

timothee-haudebourg commented 4 weeks ago

I used the opportunity to remove the todo!() in ssi-status.