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

poc: Reduce test runtime by making TurboSHAKE128 stateful #322

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

cjpatton
Copy link
Collaborator

@cjpatton cjpatton commented Dec 20, 2023

Closes #321.

The reference implementation of TurboSHAKE128 provides a one-shot API. To use this efficiently, we restrict the number of bytes required for tests so that we can pre-compute the entire output buffer. This is controlled by MAX_XOF_OUT_STREAM_BYTES.

This restriction is confusing and has side-effects for specs that use XofTurboShake128. However using the one-shot API without this optimization makes the unit tests prohibitively slow, about a minute on my machine.

Implement a stateful API for TurboSHAKE128 and use it in XofTurboShake128. This reduces the runtime to 20 seconds on my machine.

Accordingly, restore the unit tests for Poplar1 to what they were before we made this optimization.

cc/ @junyechen1996

The reference implementation of TurboSHAKE128 provides a one-shot API.
To use this efficiently, we restrict the number of bytes required for
tests so that we can pre-compute the entire output buffer. This is
controlled by MAX_XOF_OUT_STREAM_BYTES.

This restriction is confusing and has side-effects for specs that use
XofTurboShake128. However using the one-shot API without this
optimization makes the unit tests prohibitively slow, about a minute on
my machine.

Implement a stateful API for TurboSHAKE128 and use it in
XofTurboShake128. This reduces the runtime to 20 seconds on my machine.

Accordingly, restore the unit tests for Poplar1 to what they were before
we made this optimization.
@cjpatton cjpatton force-pushed the cjpatton/321-implement-stateful-turboshake branch from 827f680 to dda6990 Compare December 20, 2023 19:22
@cjpatton
Copy link
Collaborator Author

cjpatton commented Jan 9, 2024

Reviewer note: Eventually we'll be able to use PyCryptodome instead: Legrandin/pycryptodome#780

@cjpatton cjpatton merged commit 97fcdd4 into main Jan 10, 2024
6 checks passed
@cjpatton cjpatton deleted the cjpatton/321-implement-stateful-turboshake branch June 8, 2024 19:54
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.

poc: TurboSHAKE128: Replace reference implementation with a stateful version
2 participants