Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public Input length does not need to be stored in memory #2

Open
clabby opened this issue Sep 1, 2022 · 0 comments
Open

Public Input length does not need to be stored in memory #2

clabby opened this issue Sep 1, 2022 · 0 comments
Labels
good first issue Good for newcomers optimization Gas optimizations

Comments

@clabby
Copy link
Contributor

clabby commented Sep 1, 2022

Overview

huffv can set the input length as a constant instead of storing it in memory and performing a check at runtime.

What to do

Read inputs from (0x4C0 + n_ics * 0x40):(0x4C0 + n_ics * 0x40) in memory, removing the need for the input length check.

This should be safe because the verifier will always read the required number of inputs from memory. For example, if we hard code the public input length to 5 and only 2 are written to memory, the verifier will still try to load 5 between 0x640:0x6E0. If the memory is clean, the last 3 inputs would default to 0.

Should add a safety warning above VERIFY if we do this to make sure devs know that the public inputs' reserved memory should be clean when the macro is invoked.

@clabby clabby added good first issue Good for newcomers optimization Gas optimizations labels Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers optimization Gas optimizations
Projects
None yet
Development

No branches or pull requests

1 participant