Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[profile.default]
failure-output = "immediate-final"
fail-fast = false
default-filter = 'not test(merkle::smt::full::concurrent)'
fail-fast = false
failure-output = "immediate-final"

[profile.smt-concurrent]
failure-output = "immediate-final"
fail-fast = false
default-filter = 'test(merkle::smt::full::concurrent)'
fail-fast = false
failure-output = "immediate-final"
34 changes: 2 additions & 32 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,5 @@ on:
types: [opened, reopened, synchronize]

jobs:
clippy:
name: clippy nightly on ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Clippy
run: |
rustup update --no-self-update nightly
rustup +nightly component add clippy
make clippy

rustfmt:
name: rustfmt check nightly on ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Rustfmt
run: |
rustup update --no-self-update nightly
rustup default ${{ matrix.toolchain }}
rustup +nightly component add rustfmt
make format-check

doc:
name: doc stable on ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Build docs
run: |
rustup update --no-self-update
make doc
lint:
uses: 0xMiden/.github/.github/workflows/lint.yml@main
6 changes: 6 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[formatting]
align_entries = true
column_width = 120
reorder_arrays = true
reorder_inline_tables = true
reorder_keys = true
25 changes: 12 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
[workspace]
members = [
"miden-crypto"
]
exclude = [
"miden-crypto-fuzz"
]
resolver = "3" # Use the edition 2024 dependency resolver
exclude = ["miden-crypto-fuzz"]
members = ["miden-crypto"]
resolver = "3" # Use the edition 2024 dependency resolver

[workspace.package]
authors = ["miden contributors"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/0xMiden/crypto"
categories = ["cryptography", "no-std"]
keywords = ["miden", "crypto", "hash", "merkle"]
edition = "2024"
authors = ["miden contributors"]
categories = ["cryptography", "no-std"]
edition = "2024"
keywords = ["crypto", "hash", "merkle", "miden"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/0xMiden/crypto"
rust-version = "1.88"

[workspace.lints.rust]
# Suppress warnings about `cfg(fuzzing)`, which is automatically set when using `cargo-fuzz`.unexpected_cfgs = { check-cfg = ['cfg(fuzzing)'], level = "warn" }
23 changes: 21 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ DEBUG_OVERFLOW_INFO=RUSTFLAGS="-C debug-assertions -C overflow-checks -C debugin

.PHONY: clippy
clippy: ## Run Clippy with configs
$(WARNINGS) cargo +nightly clippy --workspace --all-targets --all-features
$(WARNINGS) cargo clippy --workspace --all-targets --all-features


.PHONY: fix
Expand All @@ -30,9 +30,28 @@ format: ## Run Format using nightly toolchain
format-check: ## Run Format using nightly toolchain but only in check mode
cargo +nightly fmt --all --check

.PHONY: machete
machete: ## Runs machete to find unused dependencies
cargo machete

.PHONY: toml
toml: ## Runs Format for all TOML files
taplo fmt

.PHONY: toml-check
toml-check: ## Runs Format for all TOML files but only in check mode
taplo fmt --check --verbose

.PHONY: typos-check
typos-check: ## Runs spellchecker
typos

.PHONY: workspace-check
workspace-check: ## Runs a check that all packages have `lints.workspace = true`
cargo workspace-lints

.PHONY: lint
lint: format fix clippy ## Run all linting tasks at once (Clippy, fixing, formatting)
lint: format fix clippy toml typos-check machete ## Run all linting tasks at once (Clippy, fixing, formatting, machete)

# --- docs ----------------------------------------------------------------------------------------

Expand Down
21 changes: 12 additions & 9 deletions miden-crypto-fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
[package]
name = "miden-crypto-fuzz"
version = "0.0.0"
publish = false
edition = "2024"
name = "miden-crypto-fuzz"
publish = false
version = "0.0.0"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"
miden-crypto = { path = "../miden-crypto", features = ["concurrent"] }
rand = { version = "0.9", default-features = false }
miden-crypto = { features = ["concurrent"], path = "../miden-crypto" }
rand = { default-features = false, version = "0.9" }

[[bin]]
name = "smt"
path = "fuzz_targets/smt.rs"
test = false
doc = false
bench = false
doc = false
name = "smt"
path = "fuzz_targets/smt.rs"
test = false

[lints]
workspace = true
125 changes: 62 additions & 63 deletions miden-crypto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,112 +1,111 @@
[package]
name = "miden-crypto"
version = "0.17.0"
description = "Miden Cryptographic primitives"
authors.workspace = true
readme = "../README.md"
license.workspace = true
repository.workspace = true
documentation = "https://docs.rs/miden-crypto/0.17.0"
categories.workspace = true
keywords.workspace = true
edition.workspace = true
authors.workspace = true
categories.workspace = true
description = "Miden Cryptographic primitives"
documentation = "https://docs.rs/miden-crypto/0.17.0"
edition.workspace = true
keywords.workspace = true
license.workspace = true
name = "miden-crypto"
readme = "../README.md"
repository.workspace = true
rust-version.workspace = true
version = "0.17.0"

[[bin]]
name = "miden-crypto"
path = "src/main.rs"
bench = false
doctest = false
bench = false
doctest = false
name = "miden-crypto"
path = "src/main.rs"
required-features = ["executable"]

[[bench]]
name = "hash"
harness = false
name = "hash"

[[bench]]
name = "smt"
harness = false
name = "smt"

[[bench]]
name = "smt-subtree"
harness = false
harness = false
name = "smt-subtree"
required-features = ["internal"]

[[bench]]
name = "merkle"
harness = false
name = "merkle"

[[bench]]
name = "smt-with-entries"
harness = false
name = "smt-with-entries"

[[bench]]
name = "store"
harness = false
name = "store"

[[bench]]
name = "dsa"
harness = false
name = "dsa"

[[bench]]
name = "word"
harness = false
name = "word"

[[bench]]
name = "rand"
harness = false
name = "rand"

[features]
concurrent = ["dep:rayon", "hashbrown?/rayon"]
default = ["std", "concurrent"]
default = ["concurrent", "std"]
executable = ["dep:clap", "dep:rand-utils", "std"]
hashmaps = ["dep:hashbrown"]
internal = []
serde = ["dep:serde", "serde?/alloc", "winter-math/serde"]
std = [
"blake3/std",
"dep:cc",
"rand/std",
"rand/thread_rng",
"winter-crypto/std",
"winter-math/std",
"winter-utils/std",
"blake3/std",
"dep:cc",
"rand/std",
"rand/thread_rng",
"winter-crypto/std",
"winter-math/std",
"winter-utils/std",
]

[dependencies]
blake3 = { version = "1.8", default-features = false }
clap = { version = "4.5", optional = true, features = ["derive"] }
hashbrown = { version = "0.15", optional = true, features = ["serde"] }
num = { version = "0.4", default-features = false, features = ["alloc", "libm"] }
num-complex = { version = "0.4", default-features = false }
rand = { version = "0.9", default-features = false }
rand_chacha = { version = "0.9", default-features = false }
rand_core = { version = "0.9", default-features = false }
rand-utils = { version = "0.13", package = "winter-rand-utils", optional = true }
rayon = { version = "1.10", optional = true }
serde = { version = "1.0", default-features = false, optional = true, features = ["derive"] }
sha3 = { version = "0.10", default-features = false }
thiserror = { version = "2.0", default-features = false }
winter-crypto = { version = "0.13", default-features = false }
winter-math = { version = "0.13", default-features = false }
winter-utils = { version = "0.13", default-features = false }
blake3 = { default-features = false, version = "1.8" }
clap = { features = ["derive"], optional = true, version = "4.5" }
hashbrown = { features = ["serde"], optional = true, version = "0.15" }
num = { default-features = false, features = ["alloc", "libm"], version = "0.4" }
num-complex = { default-features = false, version = "0.4" }
rand = { default-features = false, version = "0.9" }
rand-utils = { optional = true, package = "winter-rand-utils", version = "0.13" }
rand_chacha = { default-features = false, version = "0.9" }
rand_core = { default-features = false, version = "0.9" }
rayon = { optional = true, version = "1.10" }
serde = { default-features = false, features = ["derive"], optional = true, version = "1.0" }
sha3 = { default-features = false, version = "0.10" }
thiserror = { default-features = false, version = "2.0" }
winter-crypto = { default-features = false, version = "0.13" }
winter-math = { default-features = false, version = "0.13" }
winter-utils = { default-features = false, version = "0.13" }

[dev-dependencies]
assert_matches = { version = "1.5", default-features = false }
criterion = { version = "0.7", features = ["html_reports"] }
getrandom = { version = "0.3", default-features = false }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
itertools = { version = "0.14" }
proptest = { version = "1.7", default-features = false, features = ["alloc"] }
rand_chacha = { version = "0.9", default-features = false }
rand-utils = { version = "0.13", package = "winter-rand-utils" }
rstest = { version = "0.26" }
seq-macro = { version = "0.3" }
assert_matches = { default-features = false, version = "1.5" }
criterion = { features = ["html_reports"], version = "0.7" }
getrandom = { default-features = false, version = "0.3" }
hex = { default-features = false, features = ["alloc"], version = "0.4" }
itertools = { version = "0.14" }
proptest = { default-features = false, features = ["alloc"], version = "1.7" }
rand-utils = { package = "winter-rand-utils", version = "0.13" }
rand_chacha = { default-features = false, version = "0.9" }
rstest = { version = "0.26" }
seq-macro = { version = "0.3" }

[build-dependencies]
cc = { version = "1.2", optional = true, features = ["parallel"] }
cc = { features = ["parallel"], optional = true, version = "1.2" }
glob = "0.3"

[lints.rust]
# Suppress warnings about `cfg(fuzzing)`, which is automatically set when using `cargo-fuzz`.
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }
[lints]
workspace = true
2 changes: 1 addition & 1 deletion miden-crypto/src/dsa/rpo_falcon512/tests/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ pub(crate) static SK_POLYS: [[[i16; 512]; 4]; NUM_TEST_VECTORS] = [
];

/// Serialized deterministic RPO-Falcon-512 signature intended for use as a test vector
/// for the determinism in the signing procedure accros platforms.
/// for the determinism in the signing procedure across platforms.
///
/// This was generated on an `Intel Core i5-8279U` running on Linux kernel `5.4.0-144-generic` and
/// built with Rust `1.88.0`.
Expand Down
2 changes: 1 addition & 1 deletion miden-crypto/src/hash/algebraic_sponge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! `[AlgebraicSponge]` which boils down to implementing the `apply_permutation` method.
//!
//! There are currently three algebraic sponge-based hash functions implemented in the module, RPO
//! and RPX hash functions, both of which belong to the Rescue familly of hash functions, and
//! and RPX hash functions, both of which belong to the Rescue family of hash functions, and
//! Poseidon2 hash function.

use core::ops::Range;
Expand Down
2 changes: 1 addition & 1 deletion miden-crypto/src/hash/algebraic_sponge/poseidon2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod test;

/// Implementation of the Poseidon2 hash function with 256-bit output.
///
/// The implementation follows the orignal [specification](https://eprint.iacr.org/2023/323) and
/// The implementation follows the original [specification](https://eprint.iacr.org/2023/323) and
/// its accompanying reference [implementation](https://github.com/HorizenLabs/poseidon2).
///
/// The parameters used to instantiate the function are:
Expand Down
2 changes: 1 addition & 1 deletion miden-crypto/src/merkle/mmr/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn test_empty_partial_mmr() {
}

#[test]
fn test_position_equal_or_higher_than_leafs_is_never_contained() {
fn test_position_equal_or_higher_than_leaves_is_never_contained() {
let empty_forest = 0;
for pos in 1..1024 {
// pos is index, 0 based
Expand Down
2 changes: 1 addition & 1 deletion miden-crypto/src/merkle/smt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ pub struct MutationSet<const DEPTH: u8, K: Eq + Hash, V> {
old_root: Word,
/// The set of nodes that need to be removed or added. The "effective" node at an index is the
/// Merkle tree's existing node at that index, with the [`NodeMutation`] in this map at that
/// index overlayed, if any. Each [`NodeMutation::Addition`] corresponds to a
/// index overlaid, if any. Each [`NodeMutation::Addition`] corresponds to a
/// [`SparseMerkleTree::insert_inner_node()`] call, and each [`NodeMutation::Removal`]
/// corresponds to a [`SparseMerkleTree::remove_inner_node()`] call.
node_mutations: NodeMutations,
Expand Down
2 changes: 1 addition & 1 deletion miden-crypto/src/merkle/smt/partial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl PartialSmt {

/// Returns an iterator over the [`InnerNode`] and the respective [`NodeIndex`] of the
/// [`PartialSmt`].
pub fn inner_node_indicies(&self) -> impl Iterator<Item = (NodeIndex, InnerNode)> + '_ {
pub fn inner_node_indices(&self) -> impl Iterator<Item = (NodeIndex, InnerNode)> + '_ {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this was added in #494 to support 0xMiden/miden-node#1158, but (for now?) the latter doesn't use these getters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we still need to propagate the dependencies to miden base/node.

self.0.inner_node_indices()
}

Expand Down
Loading
Loading