Skip to content

Commit

Permalink
use VerkleField abstraction from banderwagon crate
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray committed Jan 7, 2024
1 parent 806e4b5 commit 92895a6
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 22 deletions.
5 changes: 1 addition & 4 deletions verkle-trie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ tempfile = "3.2.0"
thiserror = "1.0"
ipa-multipoint = { path = "../ipa-multipoint" }
banderwagon = { path = "../banderwagon" }
ark-ff = { version = "^0.4.2", default-features = false }
ark-ec = { version = "^0.4.2", default-features = false }
ark-serialize = { version = "^0.4.2", default-features = false }
verkle-db = { path = "../verkle-db", default-features = false }
once_cell = "1.8.0"
Expand All @@ -33,5 +31,4 @@ name = "benchmark_main"
harness = false

[features]
default = ["parallel"]
parallel = ["ark-ff/parallel", "ark-ff/asm", "ark-ec/parallel"]
default = []
5 changes: 2 additions & 3 deletions verkle-trie/src/committer/precompute.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::committer::Committer;
use ark_ff::Zero;

use banderwagon::{Element, Fr};
use banderwagon::{Element, Fr, VerkleField};

use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, Read, SerializationError, Write};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};

#[derive(Debug, Clone, CanonicalSerialize, CanonicalDeserialize, PartialEq, Eq)]
pub struct PrecomputeLagrange {
Expand Down
7 changes: 3 additions & 4 deletions verkle-trie/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ark_ff::BigInteger256;
use banderwagon::fr_from_u64_limbs;
pub use banderwagon::Fr;
use ipa_multipoint::{crs::CRS, lagrange_basis::PrecomputedWeights};
use once_cell::sync::Lazy;
Expand All @@ -11,7 +11,7 @@ pub const VERKLE_NODE_WIDTH: usize = 256;
// using try-and-increment
const PEDERSEN_SEED: &[u8] = b"eth_verkle_oct_2021";

pub(crate) const TWO_POW_128: Fr = Fr::new(BigInteger256::new([0, 0, 1, 0]));
pub(crate) const TWO_POW_128: Fr = fr_from_u64_limbs([0, 0, 1, 0]);

pub static CRS: Lazy<CRS> = Lazy::new(|| CRS::new(VERKLE_NODE_WIDTH, PEDERSEN_SEED));

Expand All @@ -21,8 +21,7 @@ pub static PRECOMPUTED_WEIGHTS: Lazy<PrecomputedWeights> =
#[cfg(test)]
mod tests {
use super::TWO_POW_128;
use ark_ff::PrimeField;
use banderwagon::Fr;
use banderwagon::{Fr, VerkleField};

#[test]
fn test_two_pow128_constant() {
Expand Down
2 changes: 1 addition & 1 deletion verkle-trie/src/database/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl std::fmt::Debug for BranchMeta {
}
impl BranchMeta {
pub fn zero() -> BranchMeta {
use ark_ff::Zero;
use banderwagon::VerkleField;
BranchMeta {
commitment: Element::zero(),
hash_commitment: Fr::zero(),
Expand Down
1 change: 0 additions & 1 deletion verkle-trie/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::{
constants::{CRS, PRECOMPUTED_WEIGHTS},
errors::HintError,
};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};

use banderwagon::Element;
use ipa_multipoint::multiproof::MultiPointProof;
Expand Down
4 changes: 2 additions & 2 deletions verkle-trie/src/proof/opening_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::{
database::{Meta, ReadOnlyHigherDb},
proof::key_path_finder::{KeyNotFound, KeyPathFinder, KeyState},
};
use ark_ff::{One, PrimeField, Zero};
use banderwagon::Fr;

use banderwagon::{Fr, VerkleField};
use ipa_multipoint::{lagrange_basis::LagrangeBasis, multiproof::ProverQuery};
use std::{
collections::{BTreeMap, BTreeSet},
Expand Down
3 changes: 1 addition & 2 deletions verkle-trie/src/proof/stateless_updater.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::constants::TWO_POW_128;
use crate::{committer::Committer, errors::VerificationError, group_to_field, proof::ExtPresent};
use ark_ff::{One, PrimeField, Zero};
use banderwagon::{Element, Fr};
use banderwagon::{Element, Fr, VerkleField};
use std::collections::{BTreeMap, HashSet};

use super::{UpdateHint, VerkleProof};
Expand Down
3 changes: 1 addition & 2 deletions verkle-trie/src/proof/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use crate::{
group_to_field,
proof::{ExtPresent, UpdateHint},
};
use ark_ff::{One, PrimeField, Zero};
use banderwagon::{Element, Fr};
use banderwagon::{Element, Fr, VerkleField};
use ipa_multipoint::multiproof::VerifierQuery;
use std::{
collections::{BTreeMap, BTreeSet},
Expand Down
5 changes: 2 additions & 3 deletions verkle-trie/src/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use crate::constants::{CRS, TWO_POW_128};
use crate::database::{BranchMeta, Flush, Meta, ReadWriteHigherDb, StemMeta};
use crate::{committer::Committer, Config};
use crate::{group_to_field, TrieTrait};
use ark_ff::{PrimeField, Zero};

use banderwagon::{Element, Fr};
use banderwagon::{Element, Fr, VerkleField};

#[derive(Debug, Clone)]
// The trie implements the logic to insert values, fetch values, and create paths to said values
Expand Down Expand Up @@ -763,8 +762,8 @@ fn paths_from_relative(parent_path: Vec<u8>, relative_paths: Vec<u8>) -> Vec<Vec
}
#[cfg(test)]
mod tests {
use ark_ff::{PrimeField, Zero};
use ark_serialize::CanonicalSerialize;
use banderwagon::VerkleField;

use crate::constants::{CRS, TWO_POW_128};
use crate::database::memory_db::MemoryDb;
Expand Down

0 comments on commit 92895a6

Please sign in to comment.