Compare commits

..

8 Commits

18 changed files with 88 additions and 71 deletions

View File

@@ -10,41 +10,39 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
features:
- ["stateless"]
- ["stateless", "parallel"]
- ["pmtree-ft"]
- ["pmtree-ft", "parallel"]
- ["fullmerkletree"]
- ["fullmerkletree", "parallel"]
- ["optimalmerkletree"]
- ["optimalmerkletree", "parallel"]
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu]
env:
FEATURES_CARGO: ${{ join(matrix.features, ',') }}
FEATURES_TAG: ${{ join(matrix.features, '-') }}
TARGET: ${{ matrix.target }}
feature:
- "stateless"
- "stateless,parallel"
- "pmtree-ft"
- "pmtree-ft,parallel"
- "fullmerkletree"
- "fullmerkletree,parallel"
- "optimalmerkletree"
- "optimalmerkletree,parallel"
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ env.TARGET }}
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: make installdeps
- name: Cross build
run: |
cross build --release --target $TARGET --no-default-features --features "$FEATURES_CARGO" --workspace
cross build --release --target ${{ matrix.target }} --no-default-features --features ${{ matrix.feature }} --workspace
mkdir release
cp target/$TARGET/release/librln* release/
tar -czvf $TARGET-$FEATURES_TAG-rln.tar.gz release/
cp target/${{ matrix.target }}/release/librln* release/
tar -czvf ${{ matrix.target }}-${{ matrix.feature }}-rln.tar.gz release/
- name: Upload archive artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.TARGET }}-${{ env.FEATURES_TAG }}-archive
path: ${{ env.TARGET }}-${{ env.FEATURES_TAG }}-rln.tar.gz
name: ${{ matrix.target }}-${{ matrix.feature }}-archive
path: ${{ matrix.target }}-${{ matrix.feature }}-rln.tar.gz
retention-days: 2
macos:
@@ -52,41 +50,39 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
features:
- ["stateless"]
- ["stateless", "parallel"]
- ["pmtree-ft"]
- ["pmtree-ft", "parallel"]
- ["fullmerkletree"]
- ["fullmerkletree", "parallel"]
- ["optimalmerkletree"]
- ["optimalmerkletree", "parallel"]
target: [x86_64-apple-darwin, aarch64-apple-darwin]
env:
FEATURES_CARGO: ${{ join(matrix.features, ',') }}
FEATURES_TAG: ${{ join(matrix.features, '-') }}
TARGET: ${{ matrix.target }}
feature:
- "stateless"
- "stateless,parallel"
- "pmtree-ft"
- "pmtree-ft,parallel"
- "fullmerkletree"
- "fullmerkletree,parallel"
- "optimalmerkletree"
- "optimalmerkletree,parallel"
target:
- x86_64-apple-darwin
- aarch64-apple-darwin
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ env.TARGET }}
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: make installdeps
- name: Cross build
run: |
cross build --release --target $TARGET --no-default-features --features "$FEATURES_CARGO" --workspace
cross build --release --target ${{ matrix.target }} --no-default-features --features ${{ matrix.feature }} --workspace
mkdir release
cp target/$TARGET/release/librln* release/
tar -czvf $TARGET-$FEATURES_TAG-rln.tar.gz release/
cp target/${{ matrix.target }}/release/librln* release/
tar -czvf ${{ matrix.target }}-${{ matrix.feature }}-rln.tar.gz release/
- name: Upload archive artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.TARGET }}-${{ env.FEATURES_TAG }}-archive
path: ${{ env.TARGET }}-${{ env.FEATURES_TAG }}-rln.tar.gz
name: ${{ matrix.target }}-${{ matrix.feature }}-archive
path: ${{ matrix.target }}-${{ matrix.feature }}-rln.tar.gz
retention-days: 2
rln-wasm:
@@ -107,11 +103,19 @@ jobs:
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
targets: wasm32-unknown-unknown
components: rust-src
- uses: Swatinem/rust-cache@v2
with:
key: rln-wasm-${{ matrix.feature }}
- name: Install dependencies
run: make installdeps
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install binaryen
run: |
sudo apt-get update
sudo apt-get install -y binaryen
- name: Build rln-wasm package
run: |
if [[ ${{ matrix.feature }} == *parallel* ]]; then
@@ -148,9 +152,22 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
with:
targets: wasm32-unknown-unknown
components: rust-src
- uses: Swatinem/rust-cache@v2
with:
key: rln-wasm-utils
- name: Install dependencies
run: make installdeps
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install binaryen
run: |
sudo apt-get update
sudo apt-get install -y binaryen
- name: Build rln-wasm-utils package
run: |
wasm-pack build --release --target web --scope waku

4
Cargo.lock generated
View File

@@ -1422,7 +1422,7 @@ checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001"
[[package]]
name = "rln"
version = "0.9.0"
version = "0.8.0"
dependencies = [
"ark-bn254",
"ark-ec",
@@ -2099,7 +2099,7 @@ dependencies = [
[[package]]
name = "zerokit_utils"
version = "0.7.0"
version = "0.6.0"
dependencies = [
"ark-bn254",
"ark-ff 0.5.0",

View File

@@ -1,6 +1,6 @@
[package]
name = "rln-cli"
version = "0.5.0"
version = "0.4.0"
edition = "2021"
[[example]]
@@ -13,8 +13,8 @@ path = "src/examples/stateless.rs"
required-features = ["stateless"]
[dependencies]
rln = { path = "../rln", version = "0.9.0", default-features = false }
zerokit_utils = { path = "../utils", version = "0.7.0", default-features = false }
rln = { path = "../rln", version = "0.8.0", default-features = false }
zerokit_utils = { path = "../utils", version = "0.6.0", default-features = false }
clap = { version = "4.5.41", features = ["cargo", "derive", "env"] }
color-eyre = "0.6.5"
serde_json = "1.0.141"

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_20")]
#[arg(short, long, default_value = "../rln/resources/tree_depth_30")]
resources_path: PathBuf,
},
SetTree {

View File

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

View File

@@ -9,7 +9,7 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
# TODO: remove this once we have a proper release
rln = { path = "../rln", version = "0.9.0", default-features = false, features = ["stateless"] }
rln = { path = "../rln", default-features = false, features = ["stateless"] }
js-sys = "0.3.77"
wasm-bindgen = "0.2.100"
rand = "0.8.5"

View File

@@ -1,6 +1,6 @@
[package]
name = "rln-wasm"
version = "0.3.0"
version = "0.2.0"
edition = "2021"
license = "MIT or Apache2"
@@ -8,11 +8,11 @@ license = "MIT or Apache2"
crate-type = ["cdylib", "rlib"]
[dependencies]
rln = { path = "../rln", version = "0.9.0", default-features = false, features = [
rln = { path = "../rln", version = "0.8.0", default-features = false, features = [
"stateless",
] }
rln-wasm-utils = { path = "../rln-wasm-utils", version = "0.1.0", default-features = false }
zerokit_utils = { path = "../utils", version = "0.7.0", default-features = false }
zerokit_utils = { path = "../utils", version = "0.6.0", default-features = false }
num-bigint = { version = "0.4.6", default-features = false }
js-sys = "0.3.77"
wasm-bindgen = "0.2.100"

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_20/rln_final.arkzkey");
include_bytes!("../../rln/resources/tree_depth_30/rln_final.arkzkey");
const CIRCOM_BYTES: &[u8] = include_bytes!("../../rln/resources/tree_depth_20/rln.wasm");
const CIRCOM_BYTES: &[u8] = include_bytes!("../../rln/resources/tree_depth_30/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_20/rln_final.arkzkey";
const ARKZKEY_PATH: &str = "../rln/resources/tree_depth_30/rln_final.arkzkey";
const CIRCOM_PATH: &str = "../rln/resources/tree_depth_20/rln.wasm";
const CIRCOM_PATH: &str = "../rln/resources/tree_depth_30/rln.wasm";
#[wasm_bindgen_test]
pub async fn rln_wasm_benchmark() {

View File

@@ -1,6 +1,6 @@
[package]
name = "rln"
version = "0.9.0"
version = "0.8.0"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "APIs to manage, compute and verify zkSNARK proofs and RLN primitives"
@@ -43,7 +43,7 @@ ruint = { version = "1.15.0", features = ["rand", "serde", "ark-ff-04"] }
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
zeroize = "1.8"
tempfile = "3.21.0"
utils = { package = "zerokit_utils", version = "0.7.0", path = "../utils", default-features = false }
utils = { package = "zerokit_utils", version = "0.6.0", path = "../utils", default-features = false }
# serialization
prost = "0.14.1"

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 = 20;
let tree_depth = 30;
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_20/rln_final.arkzkey");
pub const ARKZKEY_BYTES: &[u8] = include_bytes!("../../resources/tree_depth_30/rln_final.arkzkey");
#[cfg(not(target_arch = "wasm32"))]
const GRAPH_BYTES: &[u8] = include_bytes!("../../resources/tree_depth_20/graph.bin");
const GRAPH_BYTES: &[u8] = include_bytes!("../../resources/tree_depth_30/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 = 20;
pub const TEST_TREE_DEPTH: usize = 30;
// 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 = 20;
/// let tree_depth = 30;
/// 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 = 20;
/// let resources_folder = "./resources/tree_depth_20/";
/// let tree_depth = 30;
/// let resources_folder = "./resources/tree_depth_30/";
///
/// 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_20/";
/// let resources_folder = "./resources/tree_depth_30/";
///
/// 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_20/rln_final.arkzkey";
/// let zkey_path = "./resources/tree_depth_30/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 = 20;
/// let tree_depth = 30;
/// 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_20/rln_final.arkzkey";
let zkey_path = "./resources/tree_depth_30/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_20/graph.bin";
let graph_data = "./resources/tree_depth_30/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];

View File

@@ -1,6 +1,6 @@
[package]
name = "zerokit_utils"
version = "0.7.0"
version = "0.6.0"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Various utilities for Zerokit"