Repository navigation
fix(delegation): a present non-integer depth makes a legacy record invalid - #26
Merged
Merged
Conversation
…valid verify_delegation skipped the depth comparison for a signed maxDepth or currentDepth that is not a number, so the record verified at any depth, while the TypeScript verifier coerced "1" to 1 and rejected it. A present maxDepth or currentDepth that is not a non-negative integer is now invalid, with no depth result reported. Integer-valued floats are compared as before. An absent or None member is not compared, matching the TypeScript verifier. Refs agent-passport-system/agent-passport-system#223. Signed-off-by: Tymofii Pidlisnyi <tima@aeoess.com>
…ejects create_delegation signed a max_depth such as -1 or 1.5 that verify_delegation now reports malformed. It now raises ValueError for any value that is not a non-negative integer up to 2**53 - 1. None is unchanged: it signs as no maxDepth member, which verifies with no ceiling. Refs agent-passport-system/agent-passport-system#223. Signed-off-by: Tymofii Pidlisnyi <tima@aeoess.com>
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.
What problem this solves
agent-passport-system/agent-passport-system#223.
verify_delegationskipped the depth comparison for a signedmaxDepthorcurrentDepththat is not a number, so the record verified at any depth. The TypeScript verifier coerced"1"to 1 and rejected the same record.Why this change was made
A verifier should not report a depth result it did not establish, and the two SDKs should agree on validity for the same signed bytes.
User impact
maxDepthorcurrentDepthmust be a non-negative integer no greater than2**53 - 1, matching the TypeScript safe-integer limit. Anything else makes the record invalid, with aMalformed maxDepthorMalformed currentDeptherror.depthExceededstays False because no comparison was made.2.0remain accepted, since they sign to the same bytes as2.Nonemember is not compared, matching the TypeScript verifier._is_depthmoves to module level, soverify_delegation,sub_delegateandcreate_delegationshare one depth rule.create_delegationnow raisesValueErrorfor amax_depthits verifier would reject, so the SDK cannot return a signed record its own verifier rejects.Noneis unchanged: it signs as nomaxDepthmember, which verifies with no ceiling.Evidence
tests/test_legacy_maxdepth_absent.py: the test that pinned the old skip is replaced. MalformedmaxDepthat depth 0 and 2, malformedcurrentDepthwith and without a ceiling, integer-valued floats,Noneand absent members. With the verifier change reverted, the new cases fail.1.5,-1,2**53, NaN, infinity,"1"andTrueraise, and0,1,2.0,2**53 - 1andNonesign and verify. With the writer guard reverted, the refusal test fails.maxDepth2**53is malformed and2**53 - 1is accepted, in both SDKs.pytest: 2756 passed, 6 skipped.Boundaries
maxDepthreading from fix(delegation): no depth ceiling for an absent maxDepth, refuse minting without a ceiling #25.