mirror of
https://github.com/arnaucube/miden-crypto.git
synced 2026-01-10 16:11:30 +01:00
docs: add module descriptions
This commit is contained in:
@@ -1 +1,3 @@
|
||||
//! Digital signature schemes supported by default in the Miden VM.
|
||||
|
||||
pub mod rpo_falcon512;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Cryptographic hash functions used by the Miden VM and the Miden rollup.
|
||||
|
||||
use super::{Felt, FieldElement, StarkField, ONE, ZERO};
|
||||
|
||||
pub mod blake;
|
||||
|
||||
@@ -7,12 +7,12 @@ extern crate alloc;
|
||||
pub mod dsa;
|
||||
pub mod hash;
|
||||
pub mod merkle;
|
||||
pub mod rand;
|
||||
pub mod utils;
|
||||
|
||||
// RE-EXPORTS
|
||||
// ================================================================================================
|
||||
|
||||
pub use winter_crypto::{RandomCoin, RandomCoinError};
|
||||
pub use winter_math::{fields::f64::BaseElement as Felt, FieldElement, StarkField};
|
||||
|
||||
// TYPE ALIASES
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Data structures related to Merkle trees based on RPO256 hash function.
|
||||
|
||||
use super::{
|
||||
hash::rpo::{Rpo256, RpoDigest},
|
||||
utils::collections::{vec, BTreeMap, BTreeSet, KvMap, RecordingMap, TryApplyDiff, Vec},
|
||||
|
||||
3
src/rand/mod.rs
Normal file
3
src/rand/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
//! Pseudo-random element generation.
|
||||
|
||||
pub use winter_crypto::{RandomCoin, RandomCoinError};
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Utilities used in this crate which can also be generally useful downstream.
|
||||
|
||||
use super::{utils::string::String, Word};
|
||||
use core::fmt::{self, Display, Write};
|
||||
|
||||
@@ -49,9 +51,10 @@ pub fn bytes_to_hex_string<const N: usize>(data: [u8; N]) -> String {
|
||||
s
|
||||
}
|
||||
|
||||
/// Defines errors which can occur during parsing of hexadecimal strings.
|
||||
#[derive(Debug)]
|
||||
pub enum HexParseError {
|
||||
InvalidLength { expected: usize, got: usize },
|
||||
InvalidLength { expected: usize, actual: usize },
|
||||
MissingPrefix,
|
||||
InvalidChar,
|
||||
OutOfRange,
|
||||
@@ -60,8 +63,8 @@ pub enum HexParseError {
|
||||
impl Display for HexParseError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
HexParseError::InvalidLength { expected, got } => {
|
||||
write!(f, "Hex encoded RpoDigest must have length 66, including the 0x prefix. expected {expected} got {got}")
|
||||
HexParseError::InvalidLength { expected, actual } => {
|
||||
write!(f, "Hex encoded RpoDigest must have length 66, including the 0x prefix. expected {expected} got {actual}")
|
||||
}
|
||||
HexParseError::MissingPrefix => {
|
||||
write!(f, "Hex encoded RpoDigest must start with 0x prefix")
|
||||
@@ -83,7 +86,7 @@ impl std::error::Error for HexParseError {}
|
||||
pub fn hex_to_bytes<const N: usize>(value: &str) -> Result<[u8; N], HexParseError> {
|
||||
let expected: usize = (N * 2) + 2;
|
||||
if value.len() != expected {
|
||||
return Err(HexParseError::InvalidLength { expected, got: value.len() });
|
||||
return Err(HexParseError::InvalidLength { expected, actual: value.len() });
|
||||
}
|
||||
|
||||
if !value.starts_with("0x") {
|
||||
|
||||
Reference in New Issue
Block a user