Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -17,35 +17,5 @@ permissions:
contents: read

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
26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[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" }
42 changes: 40 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 Expand Up @@ -104,3 +123,22 @@ bench-smt-concurrent: ## Run SMT benchmarks with concurrent feature
.PHONY: fuzz-smt
fuzz-smt: ## Run fuzzing for SMT
cargo +nightly fuzz run smt --release --fuzz-dir miden-crypto-fuzz -- -max_len=10485760

# --- installing ----------------------------------------------------------------------------------

.PHONY: check-tools
check-tools: ## Checks if development tools are installed
@echo "Checking development tools..."
@command -v typos >/dev/null 2>&1 && echo "[OK] typos is installed" || echo "[MISSING] typos is not installed (run: make install-tools)"
@command -v cargo nextest >/dev/null 2>&1 && echo "[OK] nextest is installed" || echo "[MISSING] nextest is not installed (run: make install-tools)"
@command -v taplo >/dev/null 2>&1 && echo "[OK] taplo is installed" || echo "[MISSING] taplo is not installed (run: make install-tools)"
@command -v cargo machete >/dev/null 2>&1 && echo "[OK] machete is installed" || echo "[MISSING] machete is not installed (run: make install-tools)"

.PHONY: install-tools
install-tools: ## Installs development tools required by the Makefile (typos, nextest, taplo, machete)
@echo "Installing development tools..."
cargo install typos-cli --locked
cargo install cargo-nextest --locked
cargo install taplo-cli --locked
cargo install cargo-machete --locked
@echo "Development tools installation complete!"
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
134 changes: 68 additions & 66 deletions miden-crypto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,115 +1,117 @@
[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"] }
getrandom = { version = "0.2", features = ["js"] }
hashbrown = { version = "0.15", optional = true, features = ["serde"] }
hkdf = { version = "0.12", default-features = false }
k256 = { version = "0.13", features = ["ecdsa", "ecdh"] }
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_hc = { version = "0.3" }
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" }
getrandom = { features = ["js"], version = "0.2" }
hashbrown = { features = ["serde"], optional = true, version = "0.15" }
hkdf = { default-features = false, version = "0.12" }
k256 = { features = ["ecdh", "ecdsa"], version = "0.13" }
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" }
rand_hc = { version = "0.3" }
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"] }
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" }
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

[package.metadata.cargo-machete]
ignored = ["getrandom"]
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
Loading
Loading