Consider making `hash_string_to_word` a `const fn`
- Langage dominant
- Rust
- Étoiles
- 772
- Forks
- 352
- Merge moyen
- 1 j 12 h
- PR mergées (30 j)
- 93
Description
`hash_string_to_word` essentially, blake3-hashes its input and converts the result into a `Word`.
The `blake3` crate doesn't offer a `const` implementation, afaict, but there is https://github.com/triblespace/const-BLAKE3 as an alternative. We may want to look into that to enable deriving hashes in `const` contexts.
I think the main question is how trustworthy the implementation is.
This would be useful in miden-base to bring back `StorageSlotName::from_static_str`, which is no longer possible now that we have included the derived `StorageSlotId` into the slot name itself.
Instead of defining slot names like this:
```rust
static FALCON_PUBKEY_SLOT_NAME: LazyLock = LazyLock::new(|| {
StorageSlotName::new("miden::standards::auth::rpo_falcon512::public_key")
.expect("storage slot name should be valid")
});
impl AuthRpoFalcon512 {
pub fn public_key_slot() -> &'static StorageSlotName {
&FALCON_PUBKEY_SLOT_NAME
}
}
```
It would allow us to guarantee compile-time slot name validation and expose a nicer API for users:
```rust
impl AuthRpoFalcon512 {
pub const FALCON_PUBKEY_SLOT: StorageSlotName = StorageSlotName::from_static_str(
"miden::standards::auth::rpo_falcon512::public_key"
);
}
```
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.