hacspec / hax

A Rust verification tool
https://hacspec.org/blog
Apache License 2.0
190 stars 20 forks source link

Frontend: support nightly feature `generic_const_exprs` #871

Open EschericHya opened 2 months ago

EschericHya commented 2 months ago

Hello,

I was trying to run Charon on libcrux and got the following error:

error[E9999]: Supposely unreachable place in the Rust AST. The label is "TranslateUneval".
              This error report happend because some assumption about the Rust AST was broken.

              Context:
               - self: UnevaluatedConst { def: libcrux::kem::kyber::hash_functions::G::{constant#0}, args: [] }
               - ucv: UnevaluatedConst {
                  def: libcrux::kem::kyber::hash_functions::G::{constant#0},
                  args: [],
              }
  |
  = note: ⚠ This is a bug in Hax's frontend.
          Please report this error to https://github.com/hacspec/hax/issues with some context (e.g. the current crate)!

The function is

pub(crate) fn G(input: &[u8]) -> [u8; digest_size(Algorithm::Sha3_512)] {
    digest::sha3_512(input)
}

from https://github.com/cryspen/libcrux/blob/a6286d7d5652264175cb1c2a184d8e00c169d463/src/kem/kyber/hash_functions.rs

The problem seems to happen because it cannot evaluate digest_size(Algorithm::Sha3_512).

W95Psp commented 2 months ago

Hi!

I think this is because the crate you're looking at uses the generic_const_exprs nightly feature, which is not yet supported by the frontend of hax.

(clearly digest_size(...) is nightly)

I'm gonna label correctly the issue, if this is needed for you we can schedule when to spend time on that. The faulty code is there: https://github.com/hacspec/hax/blob/b285b13ff2ca0a508c4f35c849a11612c3d1f2a4/frontend/exporter/src/constant_utils.rs#L375C37-L378.

We should

github-actions[bot] commented 1 day ago

This issue has been marked as stale due to a lack of activity for 60 days. If you believe this issue is still relevant, please provide an update or comment to keep it open. Otherwise, it will be closed in 7 days.