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

setup chacha circuit for NIVC folding #63

Merged
merged 4 commits into from
Dec 3, 2024
Merged

setup chacha circuit for NIVC folding #63

merged 4 commits into from
Dec 3, 2024

Conversation

lonerapier
Copy link
Collaborator

fixes ChaCha circuit for folding setup.

  • add public step_in
  • formatting

@lonerapier
Copy link
Collaborator Author

Couple of questions:

  1. Can we move chacha inputs to bytes and then convert to 32 bits, just to be consistent with AES, but it will obviously add many constraints that can be saved by doing outside the circuit?
  2. How does ChaCha handle plaintext padding? Do we need to compute ciphertext again when padded to 512/1024? In this case, isn't the ciphertext passed to circuit incorrect?

@0xJepsen
Copy link
Contributor

0xJepsen commented Dec 3, 2024

2. How does ChaCha handle plaintext padding? Do we need to compute ciphertext again when padded to 512/1024? In this case, isn't the ciphertext passed to circuit incorrect?

since chacha is a stream cipher it technically doesn't need to do any padding. We could pad with zeros and then cut them after if we need maybe. You can decrypt symmetrically if you have all the same params since the encrypt and decrypt are just an XOR for the keystream. I Might need a little more context on the cipher text question you have here.

For the bytes to bits I added a helper the i referenced here with a test.
#58
When i tried to put it in the circuit i was breaking things so i think something might be wrong there just not sure what exactly.

Copy link
Contributor

@0xJepsen 0xJepsen left a comment

Choose a reason for hiding this comment

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

Nice work

@0xJepsen 0xJepsen merged commit e7c4ec9 into main Dec 3, 2024
3 checks passed
@lonerapier lonerapier deleted the fix/chacha-circuit branch December 3, 2024 18:04
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