Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
beeinger committed Nov 3, 2023
2 parents 231fe8f + f207dd1 commit fb11986
Show file tree
Hide file tree
Showing 11 changed files with 696 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "mmr"
name = "accumulators"
version = "0.1.0"
edition = "2021"

Expand Down
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
# Rust MMR

```
_____ _ __ __ __ __ _____
| __ \ | | | \/ | \/ | __ \
| |__) | _ ___| |_ | \ / | \ / | |__) |
| _ / | | / __| __| | |\/| | |\/| | _ /
| | \ \ |_| \__ \ |_ | | | | | | | | \ \
|_| \_\__,_|___/\__| |_| |_|_| |_|_| \_\
```
# Rust Accumulators

[![Cargo Test](https://github.com/HerodotusDev/rust-mmr/actions/workflows/ci.yml/badge.svg)](https://github.com/HerodotusDev/rust-mmr/actions/workflows/ci.yml)

Expand Down Expand Up @@ -59,3 +49,12 @@ mmr.verify_proof(
## Reference

- [accumulators - CoreMMR](https://github.com/HerodotusDev/accumulators)
- [cairo_lib - MMR](https://github.com/HerodotusDev/cairo-lib/tree/main/src/data_structures)

## License

`accumulators` is licensed under the [GNU General Public License v3.0](./LICENSE).

---

Herodotus Dev Ltd - 2023
4 changes: 2 additions & 2 deletions benches/mmr_benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use mmr::{
use accumulators::{
core::CoreMMR,
hash::{stark_poseidon::StarkPoseidonHasher, IHasher},
store::sqlite::SQLiteStore,
};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};

fn prepare_mmr(count: usize) -> CoreMMR<SQLiteStore, StarkPoseidonHasher> {
let hasher = StarkPoseidonHasher::new(Some(false));
Expand Down
7 changes: 1 addition & 6 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ where

let peaks = find_peaks(tree_size);

let leaf_count = mmr_size_to_leaf_count(tree_size);
if leaf_count_to_peaks_count(leaf_count) as usize != peaks.len() {
return Err(anyhow!("Invalid peaks count".to_string()));
};

let siblings = find_siblings(element_index, tree_size).unwrap();

let formatting_opts = options
Expand All @@ -154,7 +149,7 @@ where
.iter()
.filter_map(|&idx| siblings_hashes.get(&idx.to_string()).cloned())
.collect();
// let mut siblings_hashes_vec: Vec<String> = siblings_hashes.values().cloned().collect();

if let Some(formatting_opts) = options.formatting_opts.as_ref() {
siblings_hashes_vec =
format_proof(siblings_hashes_vec, formatting_opts.proof.clone()).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion tests/core.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::vec;

use mmr::{
use accumulators::{
core::CoreMMR,
hash::{stark_poseidon::StarkPoseidonHasher, IHasher},
helpers::AppendResult,
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod tests {
use std::vec;

use mmr::helpers::{
use accumulators::helpers::{
element_index_to_leaf_index, elements_count_to_leaf_count, find_peaks, find_siblings,
get_peak_info,
};
Expand Down
2 changes: 1 addition & 1 deletion tests/keccak.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(test)]
mod tests {
use mmr::hash::{keccak::KeccakHasher, IHasher};
use accumulators::hash::{keccak::KeccakHasher, IHasher};

#[test]
fn genesis() {
Expand Down
4 changes: 3 additions & 1 deletion tests/sqlite.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use mmr::store::{counter::InStoreCounter, sqlite::SQLiteStore, table::InStoreTable, IStore};
use accumulators::store::{
counter::InStoreCounter, sqlite::SQLiteStore, table::InStoreTable, IStore,
};
use std::{collections::HashMap, rc::Rc};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/stark_pedersen.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(test)]
mod tests {
use mmr::hash::{stark_pedersen::StarkPedersenHasher, IHasher};
use accumulators::hash::{stark_pedersen::StarkPedersenHasher, IHasher};

#[test]
fn should_compute_a_hash() {
Expand Down
2 changes: 1 addition & 1 deletion tests/stark_poseidon.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(test)]
mod tests {
use mmr::hash::{stark_poseidon::StarkPoseidonHasher, IHasher};
use accumulators::hash::{stark_poseidon::StarkPoseidonHasher, IHasher};

#[test]
fn should_compute_a_hash() {
Expand Down

0 comments on commit fb11986

Please sign in to comment.