Skip to content

Commit

Permalink
Merge pull request #1886 from zksecurity/fix/array-get
Browse files Browse the repository at this point in the history
  • Loading branch information
Trivo25 authored Oct 25, 2024
2 parents 3d33cb4 + 4123a24 commit 90743e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased](https://github.com/o1-labs/o1js/compare/b04520d...HEAD)

### Fixed

- Witness generation error in `Gadgets.arrayGet()` when accessing out-of-bounds indices https://github.com/o1-labs/o1js/pull/1886

## [2.0.0](https://github.com/o1-labs/o1js/compare/7e9394...b04520d)

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion src/lib/provable/gadgets/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function arrayGet(array: Field[], index: Field) {
let i = toVar(index);

// witness result
let a = existsOne(() => array[Number(i.toBigInt())].toBigInt() ?? 0n);
let a = existsOne(() => array[Number(i.toBigInt())]?.toBigInt() ?? 0n);

// we prove a === array[j] + z[j]*(i - j) for some z[j], for all j.
// setting j = i, this implies a === array[i]
Expand Down

0 comments on commit 90743e1

Please sign in to comment.