You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a bug in the wallet library's VerifiedIdPartialRequest class. (2.0.1-prerelease) replaceRequirement() method not working as expected.
Symptom
Assume that a VerifiedIdPartialRequest request has a GroupRequirement which contains 2 VerifiedIdRequirement requirements. (id="1", "2").
Try to call request.replaceRequirement("2", ....)
This call will fail (return false) because no VerifiedIdRequirement with id="2" can be found.
Root cause
This method seems to use DFS to support nested GroupRequirement, but the implementation of DFS is wrong:
In the loop "L52: for (i in 0 till requirement.requirements.size)", if requirement[0] is not what we want, it will recursively call replaceRequirement("2", requirement[0], ...) to try to find and replace the target requirement from the child requirement (requirement[0]).
However, if the child call still fails (because requirement[0] is not a GroupRequirement), the function will directly return failure (L58) without continuing to search for the next candidate - requirement[1].
I believe this behavior is not by design.
How to fix
Assuming id is unique or we just need to replace the first one.
Replace L58 with:
There seems to be a bug in the wallet library's VerifiedIdPartialRequest class. (2.0.1-prerelease)
replaceRequirement() method not working as expected.
Symptom
Root cause
This method seems to use DFS to support nested GroupRequirement, but the implementation of DFS is wrong:
In the loop "L52: for (i in 0 till requirement.requirements.size)", if requirement[0] is not what we want, it will recursively call replaceRequirement("2", requirement[0], ...) to try to find and replace the target requirement from the child requirement (requirement[0]).
However, if the child call still fails (because requirement[0] is not a GroupRequirement), the function will directly return failure (L58) without continuing to search for the next candidate - requirement[1].
I believe this behavior is not by design.
How to fix
Assuming id is unique or we just need to replace the first one.
Replace L58 with:
The text was updated successfully, but these errors were encountered: