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

Implement powers of alpha trick to compare strings #88

Open
mitschabaude opened this issue Dec 6, 2024 · 0 comments
Open

Implement powers of alpha trick to compare strings #88

mitschabaude opened this issue Dec 6, 2024 · 0 comments

Comments

@mitschabaude
Copy link
Member

mitschabaude commented Dec 6, 2024

found in the zk-email-verify repo:

  • absorb both strings (cheap, with Poseidon on 62 chars at a time) into "challenge" $\alpha$
    • note: it's ok to hash unconstrained pieces of the strings here as well, since we don't need the hash to be unique, it just needs to act as a sponge which commits the prover to this string
  • define $C(s) = s[0] + \alpha s[1] + ... + \alpha^{n-1} s[n-1]$ (cheap, ~3N double generic gates)
  • checking that $C(s) == C(t)$ proves that the strings $s$, $t$ are equal

How sound is this? Breaking it would mean finding a non-trivial root of $C(X) - C(s)$

with this, the cost of operations like assertContains(), concat() is O(N) with a smallish constant, compared to

  • O(N^2) for naive techniques
  • 2N hashes when doing an entire hash per char, which is 22N Poseidon gates in Kimchi
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

No branches or pull requests

1 participant