Skip to content
Merged
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
27 changes: 5 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
matrix:
platform: [ubuntu-latest, macos-latest]
crate: [rln]
feature: ["default", "stateless", "multi-message-id"]
feature: ["default", "stateless"]
runs-on: ${{ matrix.platform }}
timeout-minutes: 60

Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
matrix:
platform: [ubuntu-latest, macos-latest]
crate: [rln-wasm]
feature: ["default", "multi-message-id"]
feature: ["default"]
runs-on: ${{ matrix.platform }}
timeout-minutes: 60

Expand All @@ -96,26 +96,13 @@ jobs:
- name: Install dependencies
run: make installdeps
- name: Build rln-wasm
run: |
if [ ${{ matrix.feature }} == default ]; then
cargo make build
else
FEATURE=$(echo "${{ matrix.feature }}" | tr '-' '_')
cargo make build_${FEATURE}
fi
run: cargo make build
working-directory: ${{ matrix.crate }}
- name: Test rln-wasm on node
if: matrix.feature == 'default'
run: cargo make test --release
working-directory: ${{ matrix.crate }}
- name: Test rln-wasm on browser
run: |
if [ ${{ matrix.feature }} == default ]; then
cargo make test_browser --release
else
FEATURE=$(echo "${{ matrix.feature }}" | tr '-' '_')
cargo make test_${FEATURE} --release
fi
run: cargo make test_browser --release
working-directory: ${{ matrix.crate }}

rln-wasm-parallel-test:
Expand Down Expand Up @@ -206,11 +193,7 @@ jobs:
run: |
cargo clippy --all-targets --tests --release --features=stateless --no-default-features -- -D warnings
working-directory: ${{ matrix.crate }}
- name: Check clippy multi-message-id feature
if: (success() || failure()) && (matrix.crate == 'rln')
run: |
cargo clippy --all-targets --tests --release --features=multi-message-id -- -D warnings
working-directory: ${{ matrix.crate }}


benchmark-utils:
# run only on ready PRs
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/nightly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,12 @@ jobs:
features:
- ["stateless"]
- ["stateless", "parallel"]
- ["stateless", "multi-message-id"]
- ["stateless", "parallel", "multi-message-id"]
- ["pmtree-ft"]
- ["pmtree-ft", "parallel"]
- ["pmtree-ft", "multi-message-id"]
- ["pmtree-ft", "parallel", "multi-message-id"]
- ["fullmerkletree"]
- ["fullmerkletree", "parallel"]
- ["fullmerkletree", "multi-message-id"]
- ["fullmerkletree", "parallel", "multi-message-id"]
- ["optimalmerkletree"]
- ["optimalmerkletree", "parallel"]
- ["optimalmerkletree", "multi-message-id"]
- ["optimalmerkletree", "parallel", "multi-message-id"]
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu]
env:
FEATURES_CARGO: ${{ join(matrix.features, ',') }}
Expand Down Expand Up @@ -63,20 +55,12 @@ jobs:
features:
- ["stateless"]
- ["stateless", "parallel"]
- ["stateless", "multi-message-id"]
- ["stateless", "parallel", "multi-message-id"]
- ["pmtree-ft"]
- ["pmtree-ft", "parallel"]
- ["pmtree-ft", "multi-message-id"]
- ["pmtree-ft", "parallel", "multi-message-id"]
- ["fullmerkletree"]
- ["fullmerkletree", "parallel"]
- ["fullmerkletree", "multi-message-id"]
- ["fullmerkletree", "parallel", "multi-message-id"]
- ["optimalmerkletree"]
- ["optimalmerkletree", "parallel"]
- ["optimalmerkletree", "multi-message-id"]
- ["optimalmerkletree", "parallel", "multi-message-id"]
target: [x86_64-apple-darwin, aarch64-apple-darwin]
env:
FEATURES_CARGO: ${{ join(matrix.features, ',') }}
Expand Down Expand Up @@ -113,8 +97,6 @@ jobs:
feature:
- "default"
- "parallel"
- "multi-message-id"
- "parallel-multi-message-id"
- "utils"
steps:
- name: Checkout sources
Expand All @@ -138,14 +120,6 @@ jobs:
rustup run nightly wasm-pack build --release --target web --scope waku \
--features parallel -Z build-std=panic_abort,std
sed -i.bak 's/rln-wasm/zerokit-rln-wasm-parallel/g' pkg/package.json && rm pkg/package.json.bak
elif [[ ${{ matrix.feature }} == "parallel-multi-message-id" ]]; then
env CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--shared-memory -C link-arg=--max-memory=1073741824 -C link-arg=--import-memory -C link-arg=--export=__wasm_init_tls -C link-arg=--export=__tls_size -C link-arg=--export=__tls_align -C link-arg=--export=__tls_base" \
rustup run nightly wasm-pack build --release --target web --scope waku \
--features parallel,multi-message-id -Z build-std=panic_abort,std
sed -i.bak 's/rln-wasm/zerokit-rln-wasm-parallel-multi-message-id/g' pkg/package.json && rm pkg/package.json.bak
elif [[ ${{ matrix.feature }} == "multi-message-id" ]]; then
wasm-pack build --release --target web --scope waku --features multi-message-id
sed -i.bak 's/rln-wasm/zerokit-rln-wasm-multi-message-id/g' pkg/package.json && rm pkg/package.json.bak
elif [[ ${{ matrix.feature }} == "utils" ]]; then
wasm-pack build --release --target web --scope waku --no-default-features --features utils
sed -i.bak 's/rln-wasm/zerokit-rln-wasm-utils/g' pkg/package.json && rm pkg/package.json.bak
Expand Down
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ make test

# Module-specific testing
cd rln && cargo make test_stateless # Test stateless features
cd rln && cargo make test_multi_message_id # Test multi_message_id features
cd rln-wasm && cargo make test_browser # Test in browser headless mode
cd rln-wasm && cargo make test_parallel # Test parallel features
```
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ cross build --target x86_64-unknown-linux-gnu --release -p rln

Zerokit powers zero-knowledge functionality in:

- [**nwaku**](https://github.com/waku-org/nwaku) Nim implementation of the Waku v2 protocol
- [**js-rln**](https://github.com/waku-org/js-rln) JavaScript bindings for RLN
- [**nwaku**](https://github.com/waku-org/nwaku) - Nim implementation of the Waku v2 protocol
- [**js-rln**](https://github.com/waku-org/js-rln) - JavaScript bindings for RLN

## Acknowledgements

Expand Down
2 changes: 0 additions & 2 deletions rln-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ required-features = ["stateless"]
[[example]]
name = "multi_message_id"
path = "src/examples/multi_message_id.rs"
required-features = ["multi-message-id"]

[[example]]
name = "partial"
Expand All @@ -29,7 +28,6 @@ clap = { version = "4.6.0", features = ["cargo", "derive", "env"] }
[features]
default = ["rln/pmtree-ft", "rln/parallel"]
stateless = ["rln/stateless", "rln/parallel"]
multi-message-id = ["rln/pmtree-ft", "rln/parallel", "rln/multi-message-id"]

[package.metadata.docs.rs]
all-features = true
10 changes: 4 additions & 6 deletions rln-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ cargo run --example stateless --no-default-features --features stateless
## Multi Message ID Example

The following [Multi Message ID Example](src/examples/multi_message_id.rs) demonstrates
how RLN supports consuming multiple message_id units in a single proof
using the multi-message-id feature.
how RLN supports consuming multiple message_id units in a single proof.

This example functions similarly to the [Relay Example](#relay-example)
but uses different [resource files](../rln/resources/tree_depth_20/multi_message_id)
that support the multi-message-id feature.
but uses the [multi-message-id resource files](../rln/resources/tree_depth_20/multi_message_id).

You can run the example using the following command:

```bash
cargo run --example multi_message_id --features multi-message-id
cargo run --example multi_message_id
```

## Partial Proof Example
Expand All @@ -64,7 +62,7 @@ This example functions similarly to the [Relay Example](#relay-example)
but demonstrates the partial proof optimization technique
for improved proof generation performance.

Cached partial proofs remain usable across tree changes within a small window
Cached partial proofs remain usable across tree changes within a small window -
verify against a bounded set of recent roots
(e.g. via [`verify_with_roots`](../rln/src/public.rs))
instead of regenerating immediately.
Expand Down
9 changes: 2 additions & 7 deletions rln-cli/src/examples/multi_message_id.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(feature = "multi-message-id")]

use std::{
collections::HashMap,
fs::File,
Expand All @@ -10,16 +8,14 @@ use std::{
use clap::{Parser, Subcommand};
use rln::prelude::{
hash_to_field_le, keygen, poseidon_hash, recover_id_secret, Fr, IdSecret, PmtreeConfigBuilder,
RLNProofValues, RLNWitnessInput, DEFAULT_MAX_OUT, DEFAULT_TREE_DEPTH, RLN,
RLNProofValues, RLNWitnessInput, DEFAULT_TREE_DEPTH, RLN,
};
use zerokit_utils::pm_tree::Mode;

const MESSAGE_LIMIT: u32 = 4;

const TREE_DEPTH: usize = DEFAULT_TREE_DEPTH;

const MAX_OUT: usize = DEFAULT_MAX_OUT;

type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;

#[derive(Parser)]
Expand Down Expand Up @@ -93,7 +89,6 @@ impl RLNSystem {
.build()?;
let rln = RLN::new_with_params(
TREE_DEPTH,
MAX_OUT,
resources[0].clone(),
resources[1].clone(),
tree_config,
Expand Down Expand Up @@ -196,7 +191,7 @@ impl RLNSystem {
let (path_elements, identity_path_index) = self.rln.get_merkle_proof(user_index)?;
let x = hash_to_field_le(signal.as_bytes());

let witness = RLNWitnessInput::new(
let witness = RLNWitnessInput::new_multi(
identity.identity_secret.clone(),
Fr::from(MESSAGE_LIMIT),
message_ids.clone(),
Expand Down
6 changes: 3 additions & 3 deletions rln-cli/src/examples/partial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl RLNSystem {
for user_index in indices {
let identity = self.local_identities[&user_index].clone();
let (path_elements, identity_path_index) = self.rln.get_merkle_proof(user_index)?;
let witness = RLNWitnessInput::new(
let witness = RLNWitnessInput::new_single(
identity.identity_secret.clone(),
Fr::from(MESSAGE_LIMIT),
Fr::from(0u32),
Expand Down Expand Up @@ -250,7 +250,7 @@ impl RLNSystem {
"Using cached partial proof for user {user_index} (root {})",
cached.root
);
let witness = RLNWitnessInput::new(
let witness = RLNWitnessInput::new_single(
identity.identity_secret.clone(),
Fr::from(MESSAGE_LIMIT),
Fr::from(message_id),
Expand All @@ -266,7 +266,7 @@ impl RLNSystem {
"Cached partial proof missing or stale for user {user_index}; generating fresh proof"
);
let (path_elements, identity_path_index) = self.rln.get_merkle_proof(user_index)?;
let witness = RLNWitnessInput::new(
let witness = RLNWitnessInput::new_single(
identity.identity_secret.clone(),
Fr::from(MESSAGE_LIMIT),
Fr::from(message_id),
Expand Down
2 changes: 1 addition & 1 deletion rln-cli/src/examples/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl RLNSystem {
let (path_elements, identity_path_index) = self.rln.get_merkle_proof(user_index)?;
let x = hash_to_field_le(signal.as_bytes());

let witness = RLNWitnessInput::new(
let witness = RLNWitnessInput::new_single(
identity.identity_secret.clone(),
Fr::from(MESSAGE_LIMIT),
Fr::from(message_id),
Expand Down
2 changes: 1 addition & 1 deletion rln-cli/src/examples/stateless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl RLNSystem {
let merkle_proof = self.tree.proof(user_index)?;
let x = hash_to_field_le(signal.as_bytes());

let witness = RLNWitnessInput::new(
let witness = RLNWitnessInput::new_single(
identity.identity_secret.clone(),
Fr::from(MESSAGE_LIMIT),
Fr::from(message_id),
Expand Down
1 change: 0 additions & 1 deletion rln-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ default = []
utils = []
panic_hook = ["console_error_panic_hook"]
parallel = ["rln/parallel", "wasm-bindgen-rayon", "ark-groth16/parallel"]
multi-message-id = ["rln/multi-message-id"]

[package.metadata.docs.rs]
all-features = true
71 changes: 0 additions & 71 deletions rln-wasm/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@ dependencies = [
clear = true
dependencies = ["pack_build_utils", "pack_rename_utils", "pack_add_keywords"]

[tasks.build_multi_message_id]
clear = true
dependencies = [
"pack_build_multi_message_id",
"pack_rename_multi_message_id",
"pack_add_keywords",
]

[tasks.build_parallel_multi_message_id]
clear = true
dependencies = [
"pack_build_parallel_multi_message_id",
"pack_rename_parallel_multi_message_id",
"pack_add_keywords",
]

[tasks.pack_build]
command = "wasm-pack"
args = ["build", "--release", "--target", "web", "--scope", "waku"]
Expand Down Expand Up @@ -60,45 +44,6 @@ args = [
[tasks.pack_rename_parallel]
script = "sed -i.bak 's/rln-wasm/zerokit-rln-wasm-parallel/g' pkg/package.json && rm pkg/package.json.bak"

[tasks.pack_build_multi_message_id]
command = "wasm-pack"
args = [
"build",
"--release",
"--target",
"web",
"--scope",
"waku",
"--features",
"multi-message-id",
]

[tasks.pack_rename_multi_message_id]
script = "sed -i.bak 's/rln-wasm/zerokit-rln-wasm-multi-message-id/g' pkg/package.json && rm pkg/package.json.bak"

[tasks.pack_build_parallel_multi_message_id]
command = "env"
args = [
"CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS=-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--shared-memory -C link-arg=--max-memory=1073741824 -C link-arg=--import-memory -C link-arg=--export=__wasm_init_tls -C link-arg=--export=__tls_size -C link-arg=--export=__tls_align -C link-arg=--export=__tls_base",
"rustup",
"run",
"nightly",
"wasm-pack",
"build",
"--release",
"--target",
"web",
"--scope",
"waku",
"--features",
"parallel,multi-message-id",
"-Z",
"build-std=panic_abort,std",
]

[tasks.pack_rename_parallel_multi_message_id]
script = "sed -i.bak 's/rln-wasm/zerokit-rln-wasm-parallel-multi-message-id/g' pkg/package.json && rm pkg/package.json.bak"

[tasks.pack_build_utils]
command = "wasm-pack"
args = [
Expand Down Expand Up @@ -172,22 +117,6 @@ args = [
]
dependencies = ["build_parallel"]

[tasks.test_multi_message_id]
command = "wasm-pack"
args = [
"test",
"--release",
"--chrome",
"--headless",
"--target",
"wasm32-unknown-unknown",
"--features",
"multi-message-id",
"--",
"--nocapture",
]
dependencies = ["build_multi_message_id"]

[tasks.test_utils]
command = "wasm-pack"
args = [
Expand Down
Loading
Loading