Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking PR for v0.14.0 release #351

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b151773
feat: implement concurrent Smt construction (#341)
Qyriad Dec 4, 2024
d2181f4
docs: remove repetitive words (#352)
RiceChuan Dec 10, 2024
8db71b6
chore: fix typo
bobbinth Dec 22, 2024
ef3183f
chore: minor benchmark fixes
bobbinth Dec 24, 2024
43b2954
Merge branch 'main' into next
bobbinth Dec 27, 2024
d470a50
chore: fix lints
bobbinth Dec 27, 2024
e4373e5
chore: update lockfile
bobbinth Dec 29, 2024
7ee6d7f
feat: add support for hashmaps in `Smt` and `SimpleSmt` (#363)
polydez Jan 2, 2025
f825c23
feat: add support for graviton4 (#364)
gswirski Jan 4, 2025
6da2a62
docs: add Graviton 4 to hash benchmarks
bobbinth Jan 4, 2025
a75dced
chore: fix typo
bobbinth Jan 19, 2025
0e85398
chore: update crate version to 0.14.0 and MSRV to 1.84
bobbinth Jan 23, 2025
a424652
Merge branch 'main' into next
bobbinth Jan 25, 2025
d569c71
feat: remove duplicated check in falcon verification (#368)
arnaucube Jan 26, 2025
1b77fa8
feat: implements concurrent `Smt::compute_mutations` (#365)
krushimir Feb 7, 2025
58d173e
chore: minor code cleanup
bobbinth Feb 7, 2025
117813f
chore: update changelog
bobbinth Feb 7, 2025
fe7bdae
chore: update Winterfell dependencies to v0.12.0 (#374)
Al-Kindi-0 Feb 10, 2025
1e59686
Merge branch 'main' into next
bobbinth Feb 12, 2025
bbe1196
fix: `subtree8-rand` benchmark panics with debug assertions enabled (…
krushimir Feb 13, 2025
0514a83
Merge branch 'main' into next
bobbinth Feb 18, 2025
2ba30bf
fix: error in Cargo.lock
bobbinth Feb 18, 2025
d0e9ead
feat: filter empty values in `Smt::with_entries` (#383)
PhilippGackstatter Feb 18, 2025
b97243c
fix: dead_code warning on pairs_to_leaf when not(feature = "concurren…
Qyriad Feb 24, 2025
1e87cd6
docs: add SMT benchmarks (#384)
Qyriad Feb 25, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
matrix:
toolchain: [stable, nightly]
os: [ubuntu]
args: [default, no-std]
args: [default, smt-hashmaps, no-std]
timeout-minutes: 30
steps:
- uses: actions/checkout@main
Expand Down
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 0.14.0 (TBD)

- [BREAKING] Increment minimum supported Rust version to 1.84.
- Removed duplicated check in RpoFalcon512 verification (#368).
- Added parallel implementation of `Smt::compute_mutations` with better performance (#365).
- Implemented parallel leaf hashing in `Smt::process_sorted_pairs_to_leaves` (#365).
- [BREAKING] Updated Winterfell dependency to v0.12 (#374).
- Added debug-only duplicate column check in `build_subtree` (#378).
- Filter out empty values in concurrent version of `Smt::with_entries` to fix a panic (#383).

## 0.13.3 (2025-02-18)

- Implement `PartialSmt` (#372, #381).
Expand All @@ -16,11 +26,12 @@
- Fixed a bug in the implementation of `draw_integers` for `RpoRandomCoin` (#343).
- [BREAKING] Refactor error messages and use `thiserror` to derive errors (#344).
- [BREAKING] Updated Winterfell dependency to v0.11 (#346).

- Added support for hashmaps in `Smt` and `SimpleSmt` which gives up to 10x boost in some operations (#363).

## 0.12.0 (2024-10-30)

- [BREAKING] Updated Winterfell dependency to v0.10 (#338).
- Added parallel implementation of `Smt::with_entries()` with significantly better performance when the `concurrent` feature is enabled (#341).

## 0.11.0 (2024-10-17)

Expand Down
53 changes: 43 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 27 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "miden-crypto"
version = "0.13.3"
version = "0.14.0"
description = "Miden Cryptographic primitives"
authors = ["miden contributors"]
readme = "README.md"
license = "MIT"
repository = "https://github.com/0xPolygonMiden/crypto"
documentation = "https://docs.rs/miden-crypto/0.13.3"
documentation = "https://docs.rs/miden-crypto/0.14.0"
categories = ["cryptography", "no-std"]
keywords = ["miden", "crypto", "hash", "merkle"]
edition = "2021"
rust-version = "1.82"
rust-version = "1.84"

[[bin]]
name = "miden-crypto"
Expand All @@ -27,13 +27,29 @@ harness = false
name = "smt"
harness = false

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

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

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

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

[features]
default = ["std"]
concurrent = ["dep:rayon", "hashbrown?/rayon"]
default = ["std", "concurrent"]
executable = ["dep:clap", "dep:rand-utils", "std"]
smt_hashmaps = ["dep:hashbrown"]
internal = []
serde = ["dep:serde", "serde?/alloc", "winter-math/serde"]
std = [
"blake3/std",
Expand All @@ -48,17 +64,19 @@ std = [
[dependencies]
blake3 = { version = "1.5", 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.8", default-features = false }
rand_core = { version = "0.6", default-features = false }
rand-utils = { version = "0.11", package = "winter-rand-utils", optional = true }
rand-utils = { version = "0.12", 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.11", default-features = false }
winter-math = { version = "0.11", default-features = false }
winter-utils = { version = "0.11", default-features = false }
winter-crypto = { version = "0.12", default-features = false }
winter-math = { version = "0.12", default-features = false }
winter-utils = { version = "0.12", default-features = false }

[dev-dependencies]
assert_matches = { version = "1.5", default-features = false }
Expand All @@ -67,7 +85,7 @@ getrandom = { version = "0.2", features = ["js"] }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
proptest = "1.6"
rand_chacha = { version = "0.3", default-features = false }
rand-utils = { version = "0.11", package = "winter-rand-utils" }
rand-utils = { version = "0.12", package = "winter-rand-utils" }
seq-macro = { version = "0.3" }

[build-dependencies]
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,17 @@ doc: ## Generate and check documentation
test-default: ## Run tests with default features
$(DEBUG_OVERFLOW_INFO) cargo nextest run --profile default --release --all-features

.PHONY: test-smt-hashmaps
test-smt-hashmaps: ## Run tests with `smt_hashmaps` feature enabled
$(DEBUG_OVERFLOW_INFO) cargo nextest run --profile default --release --features smt_hashmaps

.PHONY: test-no-std
test-no-std: ## Run tests with `no-default-features` (std)
$(DEBUG_OVERFLOW_INFO) cargo nextest run --profile default --release --no-default-features


.PHONY: test
test: test-default test-no-std ## Run all tests
test: test-default test-smt-hashmaps test-no-std ## Run all tests

# --- checking ------------------------------------------------------------------------------------

Expand Down Expand Up @@ -83,8 +86,8 @@ build-sve: ## Build with sve support

.PHONY: bench
bench: ## Run crypto benchmarks
cargo bench
cargo bench --features concurrent

.PHONY: bench-smt-concurrent
bench-smt-concurrent: ## Run SMT benchmarks with concurrent feature
cargo run --release --features executable -- --size 1000000
cargo run --release --features concurrent,executable -- --size 1000000
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/0xPolygonMiden/crypto/blob/main/LICENSE)
[![test](https://github.com/0xPolygonMiden/crypto/actions/workflows/test.yml/badge.svg)](https://github.com/0xPolygonMiden/crypto/actions/workflows/test.yml)
[![build](https://github.com/0xPolygonMiden/crypto/actions/workflows/build.yml/badge.svg)](https://github.com/0xPolygonMiden/crypto/actions/workflows/build.yml)
[![RUST_VERSION](https://img.shields.io/badge/rustc-1.82+-lightgray.svg)](https://www.rust-lang.org/tools/install)
[![RUST_VERSION](https://img.shields.io/badge/rustc-1.84+-lightgray.svg)](https://www.rust-lang.org/tools/install)
[![CRATE](https://img.shields.io/crates/v/miden-crypto)](https://crates.io/crates/miden-crypto)

This crate contains cryptographic primitives used in Polygon Miden.
Expand Down Expand Up @@ -60,10 +60,12 @@ make

This crate can be compiled with the following features:

- `concurrent`- enabled by default; enables multi-threaded implementation of `Smt::with_entries()` which significantly improves performance on multi-core CPUs.
- `std` - enabled by default and relies on the Rust standard library.
- `no_std` does not rely on the Rust standard library and enables compilation to WebAssembly.
- `smt_hashmaps` - uses hashbrown hashmaps in SMT implementation which significantly improves performance of SMT updating. Keys ordering in SMT iterators is not guarantied when this feature is enabled.

Both of these features imply the use of [alloc](https://doc.rust-lang.org/alloc/) to support heap-allocated collections.
All of these features imply the use of [alloc](https://doc.rust-lang.org/alloc/) to support heap-allocated collections.

To compile with `no_std`, disable default features via `--no-default-features` flag or using the following command:

Expand Down
49 changes: 13 additions & 36 deletions arch/arm64-sve/rpo/library.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <stddef.h>
#include <arm_sve.h>
#include "library.h"
#include "rpo_hash.h"
#include "rpo_hash_128bit.h"
#include "rpo_hash_256bit.h"

// The STATE_WIDTH of RPO hash is 12x u64 elements.
// The current generation of SVE-enabled processors - Neoverse V1
Expand Down Expand Up @@ -31,48 +32,24 @@

bool add_constants_and_apply_sbox(uint64_t state[STATE_WIDTH], uint64_t constants[STATE_WIDTH]) {
const uint64_t vl = svcntd(); // number of u64 numbers in one SVE vector

if (vl != 4) {

if (vl == 2) {
return add_constants_and_apply_sbox_128(state, constants);
} else if (vl == 4) {
return add_constants_and_apply_sbox_256(state, constants);
} else {
return false;
}

svbool_t ptrue = svptrue_b64();

svuint64_t state1 = svld1(ptrue, state + 0*vl);
svuint64_t state2 = svld1(ptrue, state + 1*vl);

svuint64_t const1 = svld1(ptrue, constants + 0*vl);
svuint64_t const2 = svld1(ptrue, constants + 1*vl);

add_constants(ptrue, &state1, &const1, &state2, &const2, state+8, constants+8);
apply_sbox(ptrue, &state1, &state2, state+8);

svst1(ptrue, state + 0*vl, state1);
svst1(ptrue, state + 1*vl, state2);

return true;
}

bool add_constants_and_apply_inv_sbox(uint64_t state[STATE_WIDTH], uint64_t constants[STATE_WIDTH]) {
const uint64_t vl = svcntd(); // number of u64 numbers in one SVE vector

if (vl != 4) {
if (vl == 2) {
return add_constants_and_apply_inv_sbox_128(state, constants);
} else if (vl == 4) {
return add_constants_and_apply_inv_sbox_256(state, constants);
} else {
return false;
}

svbool_t ptrue = svptrue_b64();

svuint64_t state1 = svld1(ptrue, state + 0 * vl);
svuint64_t state2 = svld1(ptrue, state + 1 * vl);

svuint64_t const1 = svld1(ptrue, constants + 0 * vl);
svuint64_t const2 = svld1(ptrue, constants + 1 * vl);

add_constants(ptrue, &state1, &const1, &state2, &const2, state + 8, constants + 8);
apply_inv_sbox(ptrue, &state1, &state2, state + 8);

svst1(ptrue, state + 0 * vl, state1);
svst1(ptrue, state + 1 * vl, state2);

return true;
}
Loading
Loading