Looking at https://bots.grilledcheese.social/ap/post/17u8fu93k5tq51kg4g15 I see no reason that https://w3id.org/security/v1 should be included at all. You’re not using any properties on the Note from that context. Every property on that document is from https://www.w3.org/ns/activitystreams except for proof, which comes from https://w3id.org/security/data-integrity/v2. Within the proof sub-document, you are not using any properties from https://www.w3.org/ns/activitystreams either. So I think the document should actually look like this:
{
"@context": [
"https://w3id.org/security/data-integrity/v2",
"https://www.w3.org/ns/activitystreams"
],
"proof": {
"@context": "https://w3id.org/security/data-integrity/v2",
"//": "the proof"
},
"//": "the rest of the document"
}
It can be simplified even further by taking out the @context on the proof, since this is all one document and you already imported it at the top-level (with no need for any overrides):
{
"@context": [
"https://w3id.org/security/data-integrity/v2",
"https://www.w3.org/ns/activitystreams"
],
"proof": {
"//": "the proof"
},
"//": "the rest of the document"
}
The https://w3id.org/security/v1 context only matters when using terms from that context, such as publicKey, publicKeyPem, owner, signature, signatureValue, and so on. (A lot of these properties have been deprecated or removed from the Security Vocabulary, but are still used in current fedi implementations like Mastodon et al.)
Regarding the requirement from eddsa-jcs-2022, the order is important because later context declarations override earlier declarations.
For example, if the document declares ["https://w3id.org/security/data-integrity/v2", "https://www.w3.org/ns/activitystreams"] then it is possible that terms defined in https://w3id.org/security/data-integrity/v2 may be redefined in https://www.w3.org/ns/activitystreams, which would override the earlier term definitions and change the semantics of the proof. if the proof re-declares https://w3id.org/security/data-integrity/v2 then it ensures that the terms used within the proof are not semantically confused – any potential re-definitions within https://www.w3.org/ns/activitystreams would be overridden back to whatever is defined in https://w3id.org/security/data-integrity/v2.
A bit of a contrived example: suppose that the activitystreams context defined created to be a boolean of whether the current object was created or not. AS2 processors are required to inject the normative activitystreams context if it is missing. Doing so would cause the proof options created to map to whatever is defined in the activitystreams context (our hypothetical boolean here) instead of what is defined in the data-integrity/v2 context (dc:created, the timestamp of when the proof was created). Rather than requiring eddsa-jcs-2022 implementers to understand JSON-LD and re-inject the data-integrity/v2 context into the proof options, the algorithm simply asks eddsa-jcs-2022 verifiers to check that no terms were overridden like this. The order is important for ensuring this check. (In practice the data-integrity/v2 context is @protected, so terms defined there cannot be redefined/overridden later. JSON-LD processors will catch this and throw an error, but JSON processors will not.)