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

[WIP] feat: Pollard and partial forest support #56

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
12 changes: 6 additions & 6 deletions examples/full-accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use std::str::FromStr;

use rustreexo::accumulator::mem_forest::MemForest;
use rustreexo::accumulator::node_hash::NodeHash;
use rustreexo::accumulator::pollard::Pollard;
use rustreexo::accumulator::proof::Proof;
use rustreexo::accumulator::stump::Stump;

Expand All @@ -16,26 +16,26 @@ fn main() {
NodeHash::from_str("d3bd63d53c5a70050a28612a2f4b2019f40951a653ae70736d93745efb1124fa")
.unwrap(),
];
// Create a new Pollard, and add the utxos to it
let mut p = Pollard::new();
// Create a new MemForest, and add the utxos to it
let mut p = MemForest::new();
p.modify(&elements, &[]).unwrap();

// Create a proof that the first utxo is in the Pollard
// Create a proof that the first utxo is in the MemForest
let proof = p.prove(&[elements[0]]).unwrap();
// Verify the proof. Notice how we use the del_hashes returned by `prove` here.
let s = Stump::new()
.modify(&elements, &[], &Proof::default())
.unwrap()
.0;
assert_eq!(s.verify(&proof, &[elements[0]]), Ok(true));
// Now we want to update the Pollard, by removing the first utxo, and adding a new one.
// Now we want to update the MemForest, by removing the first utxo, and adding a new one.
// This would be in case we received a new block with a transaction spending the first utxo,
// and creating a new one.
let new_utxo =
NodeHash::from_str("cac74661f4944e6e1fed35df40da951c6e151e7b0c8d65c3ee37d6dfd3bc3ef7")
.unwrap();
p.modify(&[new_utxo], &[elements[0]]).unwrap();

// Now we can prove that the new utxo is in the Pollard.
// Now we can prove that the new utxo is in the MemForest.
let _ = p.prove(&[new_utxo]).unwrap();
}
Loading
Loading