Skip to content

🔎 Expose lookup gates#1253

Closed
zkzoomer wants to merge 2 commits intoo1-labs:feature/expose-lookupsfrom
zkzoomer:feature/expose-lookups
Closed

🔎 Expose lookup gates#1253
zkzoomer wants to merge 2 commits intoo1-labs:feature/expose-lookupsfrom
zkzoomer:feature/expose-lookups

Conversation

@zkzoomer
Copy link
Copy Markdown

This PR makes lookup gates available from gates.ts. The intended usage is:

  • For fixed lookup tables:
  import { Gates } from 'o1js';
  ...
  let indices = [Field(0), Field(1), Field(2), Field(3), Field(4), Field(5)];
  let data = [Field(2), Field(3), Field(5), Field(7), Field(11), Field(13)];
  
  // Adding lookup table with ID = 1
  Gates.addFixedLookupTable(1, indices, data);

  // Valid lookup ✔️: at index 2 value is 5, where 1 is our table ID
  Gates.lookup(Field(1), Field(2), Field(5));

  // Invalid lookup ❌: at index 5 value is 13, not 69
  // This would raise an error—proof cannot be generated
  Gates.lookup(Field(1), Field(5), Field(69);
  • For dynamic lookup tables:
  import { Gates } from 'o1js';
  ...
  let indices = [Field(0), Field(1), Field(2), Field(3), Field(4), Field(5)];
  
  // Creating a dynamic lookup table with ID = 1
  Gates.addDynamicLookupTable(1, indices);

  // Filling in a value of 10 for index 2
 Gates.lookup(Field(1), Field(2), Field(10));

  // Valid lookup ✔️: at index 2 value is 10 (as was filled in), where 1 is our table ID
  Gates.lookup(Field(1), Field(2), Field(10));

  // Invalid lookup ❌: at index 2 value is not 69, cannot be overwritten
  // This would raise an error—proof cannot be generated
  Gates.lookup(Field(1), Field(2), Field(69);

Dynamic Tables: Issue

Although exposed, dynamic tables are not fully functional, which might be due to an error in some underlying dependency. Trying to compile a circuit making use of them results in an error, the stack trace being:

Error: Pickles cannot handle point at infinity. Commitments must be representable in affine coordinates
at Class. [as compile] (o1js/dist/node/bindings/js/proxy.js:21:62)
at file:/node_modules/o1js/dist/node/lib/proof_system.js:329:30
at withThreadPool (o1js/dist/node/bindings/js/node/node-backend.js:47:24)
at async prettifyStacktracePromise (o1js/dist/node/lib/errors.js:104:16)
at async compileProgram (o1js/dist/node/lib/proof_system.js:324:53)
at async Object.compile (o1js/dist/node/lib/proof_system.js:144:52)
at async testStatic (file:/build/src/lookup-tests.js:38:33)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants