-
Notifications
You must be signed in to change notification settings - Fork 201
Protected term redefinition Ed25519Signature2018
when adding custom ldp-bbs 2020 contexts
#402
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
Comments
The "Unsigned Presentation" in your logging output contains a proof that embeds a "proof": {
"type": "BbsBlsSignatureProof2020",
"@context": "https://w3id.org/security/v2",
"created": "2020-07-14T20:45:15Z",
"verificationMethod": "did:example:489398593#test",
"proofPurpose": "assertionMethod",
"proofValue": "AAsH/7IHSzIRNz0ONPtqDp+D73PkpZFMsC9P8n01kpA2PQum2sv9mEAktuQXkVE9Y3UI4rSSYLgq6kbE3ikBK0w8Th7aACAl3oHMeIGgcDCXkX7Q5TCiwdj+/DBOznMW9b6PO5PrbNqeZvXgeE/9qs9Bwr1iZDxT7C/s3RPU8i3JwJF9lfDXXh7MqvpnvmCuymdLiwAAAHSpyVOVSAPX5DM87MSgZT/26Sf6LiFTr0W4RPidQbVfQjjtC0Wg3+raGzwcFJl+WsMAAAACES4CUcaRFh7M5Md3Rvv3stGFqneDZ5fnmtqXkw+m1MFlZA6g8OaU5mY4aM2zVFGym4IalWQCCTAwIQyJfUSnz7KhAr0YeY+TJCnVNFe35ClWH5BZJLCtBhzJC38uQQgkYLf5mERShB1sw4TdBCBE3QAAAAIcI7MQ2n3Rx6bBh4O/M3cxZOGH3y9ApR8AqDU0AutAMUj1BGGEI2Y+6joC2xPC1IjVSWvai7I5mf29EEczyrPi",
"nonce": "lhYISjY0vn7TYRnLuAb8W3WTTKna3WtP3of9curWD74/LdckH3zb4Em3yfq64d52mCw="
} So -- I presume that somewhere along the line that security context should not be getting injected into the proof. |
Looks like And then the suite includes that proof wholesale: Without consideration of the document's (on which the proof is attached) context. In jsonld-signatures, the https://github.com/digitalbazaar/jsonld-signatures/blob/master/lib/ProofSet.js#L107-L149 In short, if a flag ( |
@dlongley thanks for the clarification, the logic you reference from jsonld-signatures-bbs is to ensure the proof has an associated context when you canonicalize it, but this in general needs to be reviewed including how to drop this on the output. To be clear are you saying because some of the terms we are using are not in the security context vocab we need to be compacting the proof always i.e using the documents context? Currently in jsonld-signatures it appears in either case (compactProof or not) when you are verifying a proof you always attach the security context? https://github.com/digitalbazaar/jsonld-signatures/blob/master/lib/ProofSet.js#L304-L306 |
The So, how can contexts be incompatible? By default, JSON-LD allows terms to be redefined, simply by introducing a new Specifically, if someone reads the VC data model spec and implements to it, their software will interpret the terms according to the spec. They can get utility out of VCs without having to care about JSON-LD transformations (such as compacting to a different If another party, that is more familiar with JSON-LD, wants to consume data that happens to use the VC context, they can do so -- and even transform the data into an The So, your software can do one of three things to ensure a valid merge.
As noted above, jsonld-signatures can do option 2 or 3 -- and offers a flag to let the developer declare that option 2 is ok, if they have the knowledge that it is. If the developer doesn't set that flag, it will use option 3 to ensure a valid merge.
By the way, make sure that your
This is essentially the reverse situation from the above. Here we're plucking a https://github.com/digitalbazaar/jsonld-signatures/blob/master/lib/ProofSet.js#L286-L292 If that flag is set to false, then the developer is explicitly calling out that every term in Over time, new security context versions come out (version 3 is in the works) that aggregate more terms to enable these optimizations for more cases. Once version 3 is ready, it will be incorporated into a major revision release of jsonld-signatures to enable the optimization to happen when its terms are used. It's also possible that we could come up with a more clever API pattern to make this sort of optimization easier for custom suites -- so we're open to changes there that would simplify the process. |
Thanks for the detailed explanation @dlongley
Just to be clear, the compacting operation shown here would have to be against a different context than V2 so that all the terms for the BbsBlsSignatureProof2020 were caught correctly? It appears all compact operations in jsonld-signatures are against a hardcoded context (v2), would it be dangerous or invalid to instead allow supplying this context through the api, so that signature suites that are not in the formal security context behave correctly? |
Im also confused as to why compacting is required, is this because a JSON-LD linked data proof could be attached to a JSON-LD document that it does not feature the security context in its root context? If not then is it not equally valid to use the documents context for the compacting operation, is that not done to just ensure term-redefinition is not occurring? |
No, applications and libraries are written against particular contexts they understand. The jsonld-signatures library is written against the security/v2 context. This means that when data comes into jsonld-signatures library, it should be compacted to that context so that the code will operate properly. Once data is in that context, the library code doesn't need to do any special transforms -- it just assumes the data is organized using the terms it understands. This is because the "compact" operation will transform all the terms in a JSON-LD document from whatever context they are presently in into the context that is passed to the compact API. If there are any plugins to jsonld-signatures, they will receive the data in the security/v2 context. Those plugins may recompact data/use other contexts as they please, but if those plugins need to send data back into jsonld-signatures, they should send it in using the security/v2 context. Similarly, when data leaves jsonld-signatures (is handed back to the caller of its APIs), jsonld-signatures will transform the data back into whatever context the caller is expecting. This context comes from the
JSON-LD compaction "round trip safe". If you start with a valid document using context A and compact it to context B -- you can go back again to context A -- provided that all of the terms used in the JSON-LD document are actually defined by whatever context it started with. If not, you will have other problems anyway -- and jsonld-signatures will throw an error in these cases. As explained above, the context that jsonld-signatures compacts to is, in fact, hard-coded to security/v2 because that's the context that the code is written against. This is how applications consuming JSON-LD work generally; they have a context against which they are written such that they can accept data in any other context, and then they can compact to their native context to use it. If they need to add anything to the data or hand it back, they can compact back to the originating context so that the caller gets data using the terms definitions they prefer.
Compacting is required because the context being used by the caller is a parameter; from the perspective of jsonld-signatures, it is entirely up to them what they want to use. It is designed for fully decentralized use.
Per above, the conditional question here doesn't apply (because the context could be something else). However, when the caller knows that the terms definitions won't change, they may pass Also, note that compacting to another context (in this case the security/v2) is not what triggers an error. If you change contexts, you may redefine terms as you please, because if the incoming terms don't match, they will be transformed into full URLs which will unambiguously differentiate them for the consuming code. The error is triggered when the JSON-LD processor notices that the document you passed in is invalid. The document itself uses contexts in a way that would redefine |
This issue has been resolved in jsonld-signatures-bbs where it stemmed from with this PR, propose closing it @haardikk21 ? |
When using a custom document loader to swap the unregistered BBS context (PR open w3c/vc-di-bbs#33) with a local copy and trying to sign a verifiable presentation,
jsonld
gives an error sayingProtected term redefinition
andterm: Ed25519Signature2018
The bbs context has no mention of Ed25519 anywhere, so I'm not sure what's causing the issue.
BBS context:
REPL for error - https://repl.it/@HardikKumar/BBS-Signatures-VP-Signatures
cc @tplooker
The text was updated successfully, but these errors were encountered: