Skip to content

Remove legacy wildcard key support#512

Open
robknight wants to merge 2 commits into
mainfrom
record_key_issue
Open

Remove legacy wildcard key support#512
robknight wants to merge 2 commits into
mainfrom
record_key_issue

Conversation

@robknight
Copy link
Copy Markdown
Collaborator

This PR removes legacy support for wildcard keys, which was interfering with the new integer "index" keys.

@robknight robknight requested a review from ed255 May 12, 2026 14:35
Copy link
Copy Markdown
Collaborator

@ed255 ed255 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding this! I'm afraid that this fix is not enough.

This is the encoding of StatementArg:

/// Encoding:
/// - None => `[0, 0, 0, 0, 0, 0, 0, 0]`
/// - Literal(v) => `[[v], 0, 0, 0, 0]`
/// - Key(root, key) => `[[root], [key]]`

Since the key in AnchoredKey can now be an integer, it could be 0. And then we can have an AnchoredKey that is encoded like a Literal.

The circuit uses this function to determine whether a StatementArg is a literal, and would treat an anchored key with key=0 as a literal

fn statement_arg_is_value(&mut self, arg: &StatementArgTarget) -> BoolTarget {
let zeros = iter::repeat(self.zero())
.take(STATEMENT_ARG_F_LEN - VALUE_SIZE)
.collect::<Vec<_>>();
self.is_equal_slice(&arg.elements[VALUE_SIZE..], &zeros)
}

We need to figure out a way to distinguish the encoding of StatementArg::Literal and StatementArg::Key with ak.key = integer.
One option is to add a new field element to store a tag. But will affect performance, as it grows the number of fields required to encode a statement :(

Perhaps changing the encoding of integers isn't a bad idea after all.

Update: I've just seen you opened an issue about this #513

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