Skip to content

Commit 97e6e29

Browse files
authored
Merge branch 'main' into next
2 parents 8ee8591 + 467484b commit 97e6e29

File tree

4 files changed

+102
-59
lines changed

4 files changed

+102
-59
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
- [BREAKING] Removed `PartialEq`/`Eq` for AEAD `SecretKey` in non-test builds, fix various hygiene issues in dealing with secret keys ([#849](https://github.com/0xMiden/crypto/pull/849)).
1919
- Added `PublicKey::from_der()` for ECDSA public keys over secp256k1 ([#855](https://github.com/0xMiden/crypto/pull/855)).
2020

21+
## 0.22.4 (2026-03-03)
22+
23+
- Make `SmtLeaf::get_value` public ([#872](https://github.com/0xMiden/crypto/pull/872)).
24+
2125
## 0.22.3 (2026-02-23)
2226

2327
- Refactored to introduce a unified `Felt` type for on-chain and off-chain code ([#819](https://github.com/0xMiden/crypto/pull/819)).

Cargo.lock

Lines changed: 68 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

miden-crypto/src/merkle/smt/full/concurrent/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ proptest! {
667667
let has_real_changes = update_entries.iter().any(|(key, value)| {
668668
match initial_entries.iter().find(|(init_key, _)| init_key == key) {
669669
Some((_, init_value)) => init_value != value,
670-
None => true,
670+
None => *value != EMPTY_WORD,
671671
}
672672
});
673673

miden-crypto/src/merkle/smt/full/leaf.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,35 @@ impl SmtLeaf {
124124
// PUBLIC ACCESSORS
125125
// ---------------------------------------------------------------------------------------------
126126

127+
/// Returns the value associated with `key` in the leaf, or `None` if `key` maps to another
128+
/// leaf.
129+
pub fn get_value(&self, key: &Word) -> Option<Word> {
130+
// Ensure that `key` maps to this leaf
131+
if self.index() != (*key).into() {
132+
return None;
133+
}
134+
135+
match self {
136+
SmtLeaf::Empty(_) => Some(EMPTY_WORD),
137+
SmtLeaf::Single((key_in_leaf, value_in_leaf)) => {
138+
if key == key_in_leaf {
139+
Some(*value_in_leaf)
140+
} else {
141+
Some(EMPTY_WORD)
142+
}
143+
},
144+
SmtLeaf::Multiple(kv_pairs) => {
145+
for (key_in_leaf, value_in_leaf) in kv_pairs {
146+
if key == key_in_leaf {
147+
return Some(*value_in_leaf);
148+
}
149+
}
150+
151+
Some(EMPTY_WORD)
152+
},
153+
}
154+
}
155+
127156
/// Returns true if the leaf is empty
128157
pub fn is_empty(&self) -> bool {
129158
matches!(self, Self::Empty(_))
@@ -254,35 +283,6 @@ impl SmtLeaf {
254283
// HELPERS
255284
// ---------------------------------------------------------------------------------------------
256285

257-
/// Returns the value associated with `key` in the leaf, or `None` if `key` maps to another
258-
/// leaf.
259-
pub(in crate::merkle::smt) fn get_value(&self, key: &Word) -> Option<Word> {
260-
// Ensure that `key` maps to this leaf
261-
if self.index() != (*key).into() {
262-
return None;
263-
}
264-
265-
match self {
266-
SmtLeaf::Empty(_) => Some(EMPTY_WORD),
267-
SmtLeaf::Single((key_in_leaf, value_in_leaf)) => {
268-
if key == key_in_leaf {
269-
Some(*value_in_leaf)
270-
} else {
271-
Some(EMPTY_WORD)
272-
}
273-
},
274-
SmtLeaf::Multiple(kv_pairs) => {
275-
for (key_in_leaf, value_in_leaf) in kv_pairs {
276-
if key == key_in_leaf {
277-
return Some(*value_in_leaf);
278-
}
279-
}
280-
281-
Some(EMPTY_WORD)
282-
},
283-
}
284-
}
285-
286286
/// Inserts key-value pair into the leaf; returns the previous value associated with `key`, if
287287
/// any.
288288
///

0 commit comments

Comments
 (0)