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

Perform single key hash in key registry read #7825

Closed
nventuro opened this issue Aug 7, 2024 · 1 comment
Closed

Perform single key hash in key registry read #7825

nventuro opened this issue Aug 7, 2024 · 1 comment

Comments

@nventuro
Copy link
Contributor

nventuro commented Aug 7, 2024

The new key registry introduced in #7523 hashes keys twice, once for the hinted registry keys, and once for the hinted canonical keys. This results in an extra ~400 gates per set of keys read.

We can simplify this to a single hash if the unconstrained hint always returns the correct hint (either the registry or canonical set depending on the registry value) and so remove these extra gates:

let hinted_keys = get_keys_hint(); // unconstrained
let hinted_keys_hash = hinted_keys.hash();

let registry_key_hash = historical_read();
if registry_key_hash != 0 {
 assert_eq(registry_key_hash, hinted_keys_hash);
} else {
 let partial_address = get_partial_address() // unconstrained
 assert_eq(account, Address::compute(hinted_keys_hash, partial_address));
}

hinted_keys
@nventuro
Copy link
Contributor Author

We're dropping key rotation as of #8613, so we only ever hash the address preimage once, meaning we don't need this.

@github-project-automation github-project-automation bot moved this from Todo to Done in A3 Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant