Fix BBS derived proof message ordering - #704
Open
lcy1317 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes BBS-2023 derived proof creation for credentials whose canonicalized RDF dataset order differs from the internal canonicalization map/index order.
The issue shows up in the W3C BBS test suite under:
https://w3c.github.io/vc-di-bbs-test-suite/#bbs-2023%20(issuers)%20VC%20Version%202.0
In the published W3C report, SpruceID currently fails this issuer VC 2.0 test:
Root Cause
BBS signs and proves over an ordered list of messages. In the
bbs-2023cryptosuite, those messages are canonical N-Quads lines.The base proof signing path already builds BBS messages using sorted N-Quads line order via
into_nquads_lines(). The derived proof verification path also interprets disclosed messages in that sorted N-Quads line order.However, the derived proof creation path computed:
mandatory_indexesselective_indexesbbs_messagesusing the internal canonicalization map/index order.
For simple credentials these orders can happen to match. For credentials with blank nodes or nested JSON-LD structures, such as the W3C license VC fixture, the internal canonicalization order can differ from the sorted N-Quads line order. This causes the generated BBS proof to disclose indexes for the wrong messages, and downstream verification fails with an invalid signature / derived proof verification error.
In short:
This PR makes derived proof creation use the same sorted N-Quads line order as signing and verification.
Fix
The derive path now computes
mandatory_indexes,selective_indexes, andbbs_messagesfrominto_nquads_lines()output.This aligns holder-side proof generation with the message order already used by base proof signing and derived proof verification.
Existing base proofs remain valid; the change only affects newly generated BBS-2023 derived proofs.
Impact
This primarily affects:
It should not affect:
Tested
Both passed locally.
I also built a minimal VC API-compatible HTTP service for this branch and ran the W3C
vc-di-bbs-test-suiteagainst it. The suite completed successfully, including the previously failingbbs-2023 (issuers) VC Version 2.0conforming proof test.