Skip to content

[SHA3] Panic Freedom annotation improvements#162

Open
robinhundt wants to merge 5 commits into
jonas/sha3-mod-keccakfrom
robin/sha3-fstar-proof
Open

[SHA3] Panic Freedom annotation improvements#162
robinhundt wants to merge 5 commits into
jonas/sha3-mod-keccakfrom
robin/sha3-fstar-proof

Conversation

@robinhundt

@robinhundt robinhundt commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

This reduces the number of hax-lib annotations required for the SHA-3 panic freedom prove to go through.

The main change is in the second commit, which changes an if condition in fill_buffer.

- if self.buf_len + input_len >= RATE {
+ if input_len >= RATE - self.buf_len {

With the previous version, the addition could panic on overflow which required extensive requires clauses inputs.len().to_int() + self.buf_len.to_int() <= usize::MAX.to_int() for a large part of the call stack.

By rewriting the condition to avoid the potential overflow, we can get rid of these requires.

I've also changed the panicking From<u32> impl for Algorithm a TryFrom one. Neither of which is used in libcrux-sha3 (or any downstream crates in iot as far as I can tell), but it is good practice to have fallible conversions implement TryFrom and not From.

@robinhundt robinhundt force-pushed the robin/sha3-fstar-proof branch from d625a8e to 13da43b Compare June 3, 2026 14:14
@robinhundt robinhundt force-pushed the robin/sha3-fstar-proof branch from 13da43b to ae94975 Compare June 3, 2026 14:19
@robinhundt robinhundt marked this pull request as ready for review June 3, 2026 14:25
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.

1 participant