Repository navigation
fix: read boundary sentinel values from the sorted keys - #26
Open
iAmMichaelConnor wants to merge 1 commit into
Open
iAmMichaelConnor wants to merge 1 commit into
iAmMichaelConnor wants to merge 1 commit into
Conversation
iAmMichaelConnor
force-pushed
the
mike/03-fix-boundary-values
branch
from
November 2, 2026 18:16
4c6d696 to
2a1cb29
Compare
create() copied the value of key 0 into the start sentinel only when 0 was the first input key, and the value of `maximum` into the end sentinel only when it was the last input key. Otherwise the sentinel held the default value, so get(0) returned 0 and a prover could choose the sentinel slot to read `maximum` as 0. After sorting, those keys can only be keys[1] and keys[M], so check those instead.
TomAFrench
force-pushed
the
mike/03-fix-boundary-values
branch
from
November 3, 2026 03:53
2a1cb29 to
2ad0621
Compare
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
Key 0 and
maximumare also the start and end sentinels, which must hold the same values asthe input entries for those keys.
createcopied the value for key 0 only when 0 was thefirst input key, and the value for
maximumonly when it was the last input key. Otherwisethe sentinel held the default value, so:
get(0)returned 0 when key 0 was not first in the input (honest lookups find thesentinel first);
maximumat the end sentinel and read 0.After sorting, those keys can only be
keys[1]andkeys[M], so check those instead. Thisis cheaper than scanning the inputs and applies to both array types.
Testing
New
test_sparse_lookup_unsorted_boundary_keys(create([9, 5, 0], ...)) checks bothlookups and both sentinel values;
get(0)fails onmaster.nargo test(Noir 1.0.0):18/18 passed.