Repository navigation
codecs: dudect's bech32 cases prepare their texts by the constant-time conversion - #4
Merged
Merged
Conversation
…e conversion bech32_stream_decode read |t| 104 and 132 in two of three runs on an AMD EPYC 9V74 (codecs#2's run) and passed elsewhere. A probe on seven 9V74 runners, eight fresh processes each, measured the program as the lane builds it in five variants. As it is, 23 of 56 processes read over 10 (up to 122). With the stream decoder changed to write its data apart from its hold, 54 of 56. Without its wipe, 32 of 56. Without address randomisation, 50 of 56. With the class's text encoded by the constant-time conversion of a secure::secret<32>, as base58's cases already are, 0 of 56 (1 to 4). So the decode is not where the classes differ: its x86-64 code (Clang 18, -O3) has no branch or table read on the text, and the A/A control was clean. What differs is what the preparation leaves behind. The public conversion of the public bytes runs the same instructions for both classes but leaves their values, unwiped, in memory the measured operation reuses. The secret conversion wipes them. Every bech32 case shares the one preparation, which now goes through the secret conversion. The library is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bech32_stream_decoderead |t| 132 and 104 in two of three runs on an AMD EPYC 9V74 (codecs#2's run). It passed on every other runner model.Cause: the harness, not the library. A probe on seven 9V74 hosted runners (eight fresh processes each, Clang 18 -O3 as the lane builds it) measured five variants of the program:
setarch -R)secure::secret<32>(constant-time conversion)Changing the decode does not help. The decode's x86-64 code has no branch or table read on the text (disassembled), and the A/A control was clean. Changing only the unmeasured preparation removes the signal. The public conversion of the public bytes runs the same instructions for both classes, but it leaves their values unwiped in memory that the measured operation reuses. The secret conversion wipes them. This is the remedy base58's cases already use (codecs#2).
Fix: every bech32 case's shared preparation now encodes through a
secure::secret<32>. The library is unchanged.Verified: the program builds and runs (Clang 18, x86-64), and the lint (macOS half and the Linux amd64 lint) is clean. The probe branch has been deleted.
🤖 Generated with Claude Code