-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add support for multiple signatures. #23
Conversation
Thinking through how this will be used... It may be odd if you had to inspect the number of signatures in the data you were verifying before you could know what the output would look like. Similarly, it may be odd to have to check for two different types of output after calling I wonder if it would be better to add a |
@dlongley I like the idea of telling verify to always return a hash. However the unusual/possibly unexpected detail about the What occurred to me in reference to this conundrum is that we could release a breaking/major release that always returns a hash (at least by default) and does not return errors in any case as now, but adds the error to the hash as implemented here in the multisignatures algorithm. |
If we're going to do a major breaking change to always return something other than a boolean, then I think we should make it more friendly for the single signature case, namely, the output should have some meta data at the top level and then have a hash for individual signatures. For example: {
verified: true, // true if all signatures passed, false otherwise
// the detailed hash
keyResults: {
}
} |
I also think the verify output, regardless of type or types of signatures, should have a single flag to indicate success or failure. |
lib/jsonld-signatures.js
Outdated
@@ -151,6 +151,10 @@ api.sign = function(input, options, callback) { | |||
var nonce = options.nonce || null; | |||
var algorithm = options.algorithm || 'GraphSignature2012'; | |||
|
|||
// save any previous signatures for later | |||
var previousSignature = input.signature || null; | |||
delete input.signature; |
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.
This processing should happen after the normalize()
call:
- The input might be using some alias other than "signature" for the signature property (or even no alias).
- It would be better to leave the input unmodified and do manipulations on the new object that
normalize()
creates.
The README will need updates. It might be easier to discuss and review the API and proposed error handling method if that was updated earlier rather than later. |
@dlongley @davidlehn ready for another pass. |
Looking at the
Advantages are:
The code for this is simple but could probably be reused for each option or in other APIs. Does it make sense to use that sort of style here? |
- "jsonldjs" is not the global name anymore. - Use jsonld value from require. - Adjust jsonld require to use browser bundle. - Fix up jsigs use of jsonld and promises.
- Add option for customizing dropped term behavior. - Fix up promise-based tests.
- Fix and enable public key owner promise-based fetch test.
- Split suites into separate libs. - Split utility and helper functions out.
- Update travis tests. - Remove grunt support. - Update README. - Add karma support. - Add webpack support. - Build browser bundles in `dist` dir. - Add Node.js 6 support with babel output in `dist` dir. - Add top level index file to use node6 support as needed. - Remove old bind and setImmediate test support. - Move to node and karma test setup files that use a common test file.
Avoid webpack issue with dynamic require pulling all files in suite directory.
- Use jws lib. - Use specific header params. - Use JWS Compact Serialization with Detached Content.
- Start transitioning to use of `proof` over `signature` for unification with LD Proofs. - This library should shift toward an LD-Proof design and rename of `ld-proofs`.
Nothing changes for documents with single signatures. There is a boolean return or an error. The existing test suite passes without any modifications.
In the case when
verify
is called on a document with multiple signatures, the return value will look like this, where thesignature.creator
is the key for the map.Currently, there are some tests that exercise this new functionality in
bedrock-ledger-authz-multisignature
. If the general concept presented here is approved, I will add additional tests to the test suite in this module.