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

Properly substitute trait generics #132

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Nadrieril
Copy link
Member

Recent changes in charon made method generics explicitly represented by a binder. This removes the need to manually concatenate/split lists of generics. This PR updates eurydice to make use of this. It also seemed like associated types and parent trait clauses were used with incorrect generics so I fixed that. I checked that this does not change generated code for the tests.

@msprotz
Copy link
Contributor

msprotz commented Jan 10, 2025

Yeah some weird errors in mlkem. I need to switch to something else today but can look at this early next week.

@Nadrieril
Copy link
Member Author

I'm minimizing, it's clearly a subtitution error of some sort

@Nadrieril
Copy link
Member Author

Nadrieril commented Jan 10, 2025

Minimized:

pub trait Hash<const K: usize> {
    fn PRFxN<const LEN: usize>(input: &[[u8; 33]; K]) -> [[u8; LEN]; K];
}

pub trait Variant {
    fn kdf<const K: usize, Hasher: Hash<K>>() -> [u8; 32];
}

pub fn decapsulate<Hasher: Hash<32>, Scheme: Variant>() {
    let _ = Scheme::kdf::<32, Hasher>();
}

error:

subtype mismatch:
  <N:0, CGS:1> size_t ->  uint8_t[33size_t]* -> uint8_t[$0][32size_t] (a.k.a. <N:0, CGS:1> size_t ->  uint8_t[33size_t]* -> uint8_t[$0][32size_t]) vs:
  <N:0, CGS:1> size_t ->  uint8_t[33size_t]* -> uint8_t[$0][$0] (a.k.a. <N:0, CGS:1> size_t ->  uint8_t[33size_t]* -> uint8_t[$0][$0])

the K in PRFxN is incorrectly resolved to LEN somewhere.

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.

2 participants