Skip to content

fix: fix hax compilation of libcrux-hmac - #1642

Merged
jschneider-bensch merged 1 commit into
celabshq:mainfrom
asraa:hax-compile-sha3-types
Oct 15, 2026
Merged

jschneider-bensch merged 1 commit into
celabshq:mainfrom
asraa:hax-compile-sha3-types

Conversation

@asraa

@asraa asraa commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1641

This fixes the hax configuration build for hmac by exporting the sha3 types

[skip changelog]

@jschneider-bensch jschneider-bensch self-assigned this Oct 12, 2026
@jschneider-bensch

Copy link
Copy Markdown
Collaborator

Thanks for filing!
It looks like the approach here does not work at the moment, because you can't apply the hax_lib::exclude macro on a file-based module:

error[E0658]: file modules in proc macro input are unstable
  --> crates/algorithms/sha3/src/lib.rs:15:1
   |
15 | mod impl_digest_trait;
   | ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
   = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
   = note: this compiler was built on 2025-11-07; consider upgrading it if it is out of date

For more information about this error, try `rustc --explain E0658`.

ERROR rustc emitted an error, aborting hax custom driver.
error: could not compile `libcrux-sha3` (lib) due to 1 previous error

Would it resolve your issue if we #[cfg_attr(hax, hax_lib::exclude)]'ed the four impl_hash_traits! invocations in the impl_digest_trait module?

@asraa

asraa commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Ah thank you! Regrettably i only compiled with code with cfg hax and didn't run extraction, and now see that that was an issue.

Would it resolve your issue if we #[cfg_attr(hax, hax_lib::exclude)]'ed the four impl_hash_traits! invocations in the impl_digest_trait module?

That would also work. Do you have a preference on me excluding the length constants too? If so I'll remove the macro and add excludes in impl_digest_trait

@jschneider-bensch

Copy link
Copy Markdown
Collaborator

No worries!
I think we mainly want to avoid the trait impls in the extraction because they have mutability patterns that have historically often been an issue for hax, and probably we also don't want the Sha3_... structs in there. The const items shouldn't affect negatively any extraction (I hope), so there's no need to exclude them. So I'd be fine with excluding the impl_hash_traits invocations.

@asraa
asraa force-pushed the hax-compile-sha3-types branch from 3c3da3c to 13dbaf1 Compare October 14, 2026 15:41
Signed-off-by: asra <asra@freedom.press>

exclude the trait implementations from extraction

Signed-off-by: asra <asra@freedom.press>
@asraa
asraa force-pushed the hax-compile-sha3-types branch from 13dbaf1 to 7f24600 Compare October 15, 2026 13:38
@asraa

asraa commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Rebased & updated!

@jschneider-bensch jschneider-bensch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you!

@jschneider-bensch
jschneider-bensch added this pull request to the merge queue Oct 15, 2026
Merged via the queue into celabshq:main with commit 9d5290e Oct 15, 2026
132 of 133 checks passed
@asraa

asraa commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Awesome, thanks! If we could have a patch release for the hmac crate when convenient that would be great!

And to prevent our proof validation in the future, would it be possible to add hax extract / prove CI check for the hmac crate too? I can give it a stab

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.

libcrux-hmac 0.0.9 fails to compile with hax

2 participants