refactor: update tree depth to 10 and adjust resource paths accordingly

This commit is contained in:
vinhtc27
2025-09-19 19:49:01 +07:00
parent b5afb847f1
commit 9cb4ff7571
11 changed files with 18 additions and 18 deletions

View File

@@ -12,7 +12,7 @@ pub(crate) enum Commands {
NewWithParams {
#[arg(short, long, default_value_t = TEST_TREE_DEPTH)]
tree_depth: usize,
#[arg(short, long, default_value = "../rln/resources/tree_depth_30")]
#[arg(short, long, default_value = "../rln/resources/tree_depth_10")]
resources_path: PathBuf,
},
SetTree {

View File

@@ -17,7 +17,7 @@ use rln::{
const MESSAGE_LIMIT: u32 = 1;
const TREE_DEPTH: usize = 30;
const TREE_DEPTH: usize = 10;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]

View File

@@ -75,9 +75,9 @@ mod tests {
const WITNESS_CALCULATOR_JS: &str = include_str!("../resources/witness_calculator.js");
const ARKZKEY_BYTES: &[u8] =
include_bytes!("../../rln/resources/tree_depth_30/rln_final.arkzkey");
include_bytes!("../../rln/resources/tree_depth_10/rln_final.arkzkey");
const CIRCOM_BYTES: &[u8] = include_bytes!("../../rln/resources/tree_depth_30/rln.wasm");
const CIRCOM_BYTES: &[u8] = include_bytes!("../../rln/resources/tree_depth_10/rln.wasm");
wasm_bindgen_test_configure!(run_in_browser);

View File

@@ -73,9 +73,9 @@ mod tests {
async fn calculateWitness(circom_path: &str, input: Object) -> Result<JsValue, JsValue>;
}
const ARKZKEY_PATH: &str = "../rln/resources/tree_depth_30/rln_final.arkzkey";
const ARKZKEY_PATH: &str = "../rln/resources/tree_depth_10/rln_final.arkzkey";
const CIRCOM_PATH: &str = "../rln/resources/tree_depth_30/rln.wasm";
const CIRCOM_PATH: &str = "../rln/resources/tree_depth_10/rln.wasm";
#[wasm_bindgen_test]
pub async fn rln_wasm_benchmark() {

View File

@@ -55,7 +55,7 @@ fn main() {
// 1. Initialize RLN with parameters:
// - the tree depth;
// - the tree config, if it is not defined, the default value will be set
let tree_depth = 30;
let tree_depth = 10;
let input = Cursor::new(json!({}).to_string());
let mut rln = RLN::new(tree_depth, input).unwrap();

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -19,17 +19,17 @@ use {ark_ff::Field, ark_serialize::CanonicalDeserialize, ark_serialize::Canonica
use crate::utils::FrOrSecret;
pub const ARKZKEY_BYTES: &[u8] = include_bytes!("../../resources/tree_depth_30/rln_final.arkzkey");
pub const ARKZKEY_BYTES: &[u8] = include_bytes!("../../resources/tree_depth_10/rln_final.arkzkey");
#[cfg(not(target_arch = "wasm32"))]
const GRAPH_BYTES: &[u8] = include_bytes!("../../resources/tree_depth_30/graph.bin");
const GRAPH_BYTES: &[u8] = include_bytes!("../../resources/tree_depth_10/graph.bin");
lazy_static! {
static ref ARKZKEY: (ProvingKey<Curve>, ConstraintMatrices<Fr>) =
read_arkzkey_from_bytes_uncompressed(ARKZKEY_BYTES).expect("Failed to read arkzkey");
}
pub const TEST_TREE_DEPTH: usize = 30;
pub const TEST_TREE_DEPTH: usize = 10;
// The following types define the pairing friendly elliptic curve, the underlying finite fields and groups default to this module
// Note that proofs are serialized assuming Fr to be 4x8 = 32 bytes in size. Hence, changing to a curve with different encoding will make proof verification to fail

View File

@@ -105,7 +105,7 @@ impl RLN {
/// ```
/// use std::io::Cursor;
///
/// let tree_depth = 30;
/// let tree_depth = 10;
/// let input_buffer = Cursor::new(json!({}).to_string());
///
/// // We create a new RLN instance
@@ -167,8 +167,8 @@ impl RLN {
/// use std::fs::File;
/// use std::io::Read;
///
/// let tree_depth = 30;
/// let resources_folder = "./resources/tree_depth_30/";
/// let tree_depth = 10;
/// let resources_folder = "./resources/tree_depth_10/";
///
/// let mut resources: Vec<Vec<u8>> = Vec::new();
/// for filename in ["rln_final.arkzkey", "graph.bin"] {
@@ -228,7 +228,7 @@ impl RLN {
/// use std::fs::File;
/// use std::io::Read;
///
/// let resources_folder = "./resources/tree_depth_30/";
/// let resources_folder = "./resources/tree_depth_10/";
///
/// let mut resources: Vec<Vec<u8>> = Vec::new();
/// for filename in ["rln_final.arkzkey", "graph.bin"] {
@@ -267,7 +267,7 @@ impl RLN {
/// use std::fs::File;
/// use std::io::Read;
///
/// let zkey_path = "./resources/tree_depth_30/rln_final.arkzkey";
/// let zkey_path = "./resources/tree_depth_10/rln_final.arkzkey";
///
/// let mut file = File::open(zkey_path).expect("Failed to open file");
/// let metadata = std::fs::metadata(zkey_path).expect("Failed to read metadata");
@@ -517,7 +517,7 @@ impl RLN {
/// use rln::circuit::Fr;
/// use rln::utils::*;
///
/// let tree_depth = 30;
/// let tree_depth = 10;
/// let start_index = 10;
/// let no_of_leaves = 256;
///

View File

@@ -414,7 +414,7 @@ mod test {
// We obtain the root from the RLN instance
let root_rln_folder = get_tree_root(rln_pointer);
let zkey_path = "./resources/tree_depth_30/rln_final.arkzkey";
let zkey_path = "./resources/tree_depth_10/rln_final.arkzkey";
let mut zkey_file = File::open(zkey_path).expect("no file found");
let metadata = std::fs::metadata(zkey_path).expect("unable to read metadata");
let mut zkey_buffer = vec![0; metadata.len() as usize];
@@ -424,7 +424,7 @@ mod test {
let zkey_data = &Buffer::from(&zkey_buffer[..]);
let graph_data = "./resources/tree_depth_30/graph.bin";
let graph_data = "./resources/tree_depth_10/graph.bin";
let mut graph_file = File::open(graph_data).expect("no file found");
let metadata = std::fs::metadata(graph_data).expect("unable to read metadata");
let mut graph_buffer = vec![0; metadata.len() as usize];