Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

ZK-634: Constrain token index #40

Merged
merged 12 commits into from
Jan 23, 2025
Merged

ZK-634: Constrain token index #40

merged 12 commits into from
Jan 23, 2025

Conversation

guspiel
Copy link
Contributor

@guspiel guspiel commented Jan 21, 2025

No description provided.

Copy link

github-actions bot commented Jan 21, 2025

Circuit Metric Main branch New code % Change
Deposit max_advice_rows $${\color{green}794}$$ $${\color{red}795}$$ $${\color{red}0.13\%}$$
Deposit max_fixed_rows $${\color{green}794}$$ $${\color{red}795}$$ $${\color{red}0.13\%}$$
Deposit max_rows $${\color{green}794}$$ $${\color{red}795}$$ $${\color{red}0.13\%}$$
Deposit proving key size $${\color{green}12.3 MB}$$ $${\color{red}12.6 MB}$$ $${\color{red}2.44\%}$$
Deposit verification key size $${\color{green}2.2 KB}$$ $${\color{red}2.3 KB}$$ $${\color{red}4.55\%}$$

@guspiel guspiel changed the title ZK-634: draft: Constrain token index ZK-634: Constrain token index Jan 21, 2025
@guspiel guspiel marked this pull request as ready for review January 21, 2025 21:37
pub fn constrain_index<Constraints: From<TokenIndexConstraints> + Ord + IntoEnumIterator>(
&self,
layouter: &mut impl Layouter<Fr>,
advice_pool: &ColumnPool<Advice, SynthesisPhase>,
indicators: &[AssignedCell; NUM_TOKENS],
todo: &mut Todo<Constraints>,
) -> Result<(), Error> {
let values = array::from_fn(|i| indicators[i].value().cloned());
let index = off_circuit::index_from_indicator_values(&values);
let indicator_values = array::from_fn(|i| indicators[i].value().cloned());
Copy link
Member

Choose a reason for hiding this comment

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

nit: probably indicators.map(|v|v.cloned()) would do

Copy link
Contributor Author

@guspiel guspiel Jan 23, 2025

Choose a reason for hiding this comment

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

almost:) replaced with something as close to what you suggested as I could

Comment on lines 165 to 166
pub type IndexGate = LinearEquationGate<NUM_INDEX_GATE_COLUMNS, IndexGateConfig>;
pub type IndexGateInput = LinearEquationGateInput<AssignedCell, NUM_INDEX_GATE_COLUMNS>;
Copy link
Member

Choose a reason for hiding this comment

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

stylistic nit: it would be a tad better to have const generics always either first or last

Copy link
Contributor Author

Choose a reason for hiding this comment

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

definitely, done

@guspiel guspiel merged commit 33876b5 into main Jan 23, 2025
6 checks passed
@guspiel guspiel deleted the token-constraints branch January 23, 2025 22:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants