chore: migrate to Winterfell v0.10.0 release (#338)

This commit is contained in:
Al-Kindi-0
2024-10-29 23:02:46 +01:00
committed by GitHub
parent 689cc93ed1
commit 0d75e3593b
8 changed files with 98 additions and 55 deletions

View File

@@ -1,5 +1,5 @@
use alloc::string::String;
use core::{cmp::Ordering, fmt::Display, ops::Deref};
use core::{cmp::Ordering, fmt::Display, ops::Deref, slice};
use super::{Digest, Felt, StarkField, DIGEST_BYTES, DIGEST_SIZE, ZERO};
use crate::{
@@ -34,13 +34,19 @@ impl RpxDigest {
<Self as Digest>::as_bytes(self)
}
pub fn digests_as_elements<'a, I>(digests: I) -> impl Iterator<Item = &'a Felt>
pub fn digests_as_elements_iter<'a, I>(digests: I) -> impl Iterator<Item = &'a Felt>
where
I: Iterator<Item = &'a Self>,
{
digests.flat_map(|d| d.0.iter())
}
pub fn digests_as_elements(digests: &[Self]) -> &[Felt] {
let p = digests.as_ptr();
let len = digests.len() * DIGEST_SIZE;
unsafe { slice::from_raw_parts(p as *const Felt, len) }
}
/// Returns hexadecimal representation of this digest prefixed with `0x`.
pub fn to_hex(&self) -> String {
bytes_to_hex_string(self.as_bytes())