Commit Graph

143 Commits

Author SHA1 Message Date
Aaryamann Challani 96497db7c5
test(rln): sled db config change (#174)
* test(rln): sled db config change

* fix: increase cache_capacity
2023-06-06 22:41:38 +05:30
Aaryamann Challani 72a3ce1770
fix(cargo.toml): bench=false (#172) 2023-05-29 19:44:00 +05:30
Aaryamann Challani b841e725a0
feat(rln): pmtree benchmarks (#169)
* feat(rln): pmtree benchmarks

* style(rln): lint
2023-05-29 18:51:36 +05:30
Aaryamann Challani c2d386cb74
feat(rln): public, ffi for atomic ops (#162) 2023-05-16 10:00:32 +05:30
Aaryamann Challani 8f2c9e3586
combined batch operations (insert + delete) (#160)
* fix(rln): clippy error

* feat: batch ops in ZerokitMerkleTree

* chore: bump pmtree

* fix: upstream root calc
2023-05-15 07:11:43 +05:30
Aaryamann Challani 584c2cf4c0
fix(rln): clippy error (#159) 2023-05-06 18:30:58 +05:30
Aaryamann Challani 2c4b399126
feat(rln): ability to pass rln tree config in ffi (#150)
* feat(rln): pass config in rln ffi

* fix: for rln-wasm

* fix: ffi tests

* fix: clippy

* fix: test cursor
2023-05-05 15:15:33 +05:30
RichΛrd c4b699ddff
fix: `len().to_le_bytes().to_vec()` contains 4 bytes on 32b and should contain 8 (#154) 2023-05-04 15:23:53 +05:30
Richard Ramos 33d3732922 fix: u64 to usize conversion
usize::from_le_bytes will take an array of length 2, 4 or 8 bytes depending on the target pointer size. Since wasm uses 32b, there was a failure while reading serialized values due to the number of bytes read being incorrect. I also update version rln-wasm to 0.0.9 (npm package needs to be updated to include this fix)
2023-05-03 09:53:11 -04:00
Aaryamann Challani 654c77dcf6
feat: make pmtree default (#149) 2023-05-02 13:31:26 +05:30
Aaryamann Challani fd7d7d9318
Integrate pmtree into rln (#147)
* feat: integrate pmtree with zerokit

* fix: tests
2023-04-28 10:02:21 +05:30
tyshko-rostyslav 4f98fd8028
chore(rln): bring hash functions under a single module (#146) 2023-04-20 16:24:29 +05:30
Aaryamann Challani 0fb7e0bbcb
feat: abstract shared behaviour into ZerokitMerkleTree (#142)
* feat: abstract shared behaviour into ZerokitMerkleTree

* fix: tests
2023-04-11 16:46:13 +05:30
Aaryamann Challani 1f983bb232
fix(rln): move std::path to cfg_if block (#138) 2023-03-24 09:31:01 +05:30
tyshko-rostyslav 8cd4baba8a
leave our fork of `ark-circom` (#132)
* leave our fork of `ark-circom`

---------

Co-authored-by: tyshkor <tyshko1@gmail.com>
2023-03-22 07:01:24 +01:00
Aaryamann Challani c319f32a1e
feat(rln): package rln w/ resources into a static lib (#118)
* feat(rln): package resources into lib

* fix(rln): use Path

* fix(rln): fmt

* fix(rln): trailing slash
2023-03-07 18:15:06 +05:30
tyshko-rostyslav bf2aa16a71
chore(rln): ensure all dependencies have fixed revision (#127) 2023-03-07 09:11:08 +05:30
tyshko-rostyslav c423bdea61
chore(rln): update pmtree implementation (#125)
* most changes

* fmt

* hide tests back under feature

* grooming

* changed `SledConfig`

* requested change: rm `dbpath`

---------

Co-authored-by: tyshkor <tyshko1@gmail.com>
2023-03-03 10:33:39 +05:30
Carlos Pérez 5eb98d4b33
change: Replace `u64` for `usize` for length vars (#94)
* change: Replace `u64` for `usize` for length vars

Resolves: #39

* fix(rln): usize instead of u64 in tests

* fix(rln): linter

* fix: outlier u64 usage

* fix(rln|rln-wasm): serde of usize types

---------

Co-authored-by: Aaryamann Challani <43716372+rymnc@users.noreply.github.com>
2023-03-02 19:15:58 +05:30
Aaryamann Challani 062055dc5e
fix(license): add licensing info to cargo.toml (#121) 2023-02-27 11:47:55 +05:30
tyshko-rostyslav 55b00fd653
Code quality (#114)
* to color_eyre::Result 1st part

* tests and seconds batch

* third batch

* rln fixes + multiplier

* rln-wasm, assert rln, multiplier

* io to color_eyre

* fmt + clippy

* fix lint

* temporary fix of `ark-circom`

* fix ci after merge

* fmt

* fix rln tests

* minor

* fix tests

* imports

* requested change

* report + commented line + requested change

* requested changes

* fix build

* lint fixes

* better comments

---------

Co-authored-by: tyshkor <tyshko1@gmail.com>
2023-02-27 11:46:16 +05:30
Rahul Ghangas 62018b4eba
Update documentation for building and testing (#120)
* chore: fix Makefile pre-build

* chore: add Makefile command to install depenedncy cargo-make

* chore: update all READMEs with instructions to install dependencies, build and test

* chore: add target to fetch all submodules
2023-02-24 11:50:51 +05:30
Aaryamann Challani a6145ab201
feat(rln): expose poseidon to ffi (#112) 2023-02-16 13:26:13 +05:30
tyshko-rostyslav 7aba62ff51
Add rust-clippy to CI (#108)
Convert clippy warnings to errors, fix them 

---------

Co-authored-by: tyshkor <tyshko1@gmail.com>
2023-02-06 05:54:59 +01:00
Rahul Ghangas cbf8c541c2
test: separate out tests (#103)
* test: move tests for rln, multiplier and private-settlements to tests folder

* test: fix rln test for poseiden tree

* test: move tests for rln-wasn to standalone tests folder

* test: move tests for semaphore and utils to standalone tests folder

* chore: cargo fmt

* test: rename test files

* test: move tests out from rln/src/public to test folder

* test: fix rln tests, move tests accessign private fields back to relevant source file

* chor: run cargo fmt

* test: move all semaphore tests to tests folder

* chore: cargo fmt
2023-01-31 21:27:28 +05:30
tyshko-rostyslav 01fdba6d88
feat(rln): Abstract ffi APIs structure with a helper function (#102)
Added macros to do the following:

read the input passed to the FFI API;
cast it to a byte sequence;
pass the byte sequence to the corresponding public function;
cast the output of the public function to Buffer(if any) and write it into the FFI caller ´output_buffer` variable;
erase memory from any temporarily allocated data structure;
return true if everything went fine, false otherwise.
2023-01-31 09:43:41 +01:00
Rahul Ghangas 1502315605
chore: Makefile and consistent usage of cargo-make (#101)
* feat: add Makefile with pre build check. add targets for build, test and clean

* feat: add workspace level build file

* chore: add skeletal build files for each crate

* chore: remove environment variable to extend workspace makefile

* chore: formatting

* chore: add release flags to all builds/tests
2023-01-26 09:19:55 +05:30
G 89ea87a98a
feat(rln): integrate pmtree for MT persistance (#86)
* feat(rln): integrate pmtree for MT persistance

* fix(rln): address reviewers comments

* refactor(rln): move pmtree tests under pmtree flag
2022-12-13 20:00:27 +01:00
G 32f3202e9d
feat(rln): add extended keygen APIs for Semaphore-compatible credentials (#85)
* refactor(rln): update APIs based on updated rln circuit design

* chore(rln): update rln vendor submodule

* fix(ci): update ci to not ignore rln resources changes

* feat(rln): add extended keygen APIs

* refactor(rln): rename id_secret/id_key to identity_secret_hash as per RFC

* fix(rln): cargo fmt
2022-12-12 00:48:22 +01:00
G 9e1355d36a
refactor(rln): update APIs after circuit update (#84)
* refactor(rln): update APIs based on updated rln circuit design

* chore(rln): update rln vendor submodule

* fix(ci): update ci to not ignore rln resources changes
2022-12-09 17:19:55 +01:00
G 60e3369621
feat(rln): add recover identity secret API (#80)
* feat(rln): add API to recover id_secret when a user is slashed

* feat(rln): add RLN API for recovering id_secret

* feat(rln): add recover_id_secret FFI API; update public API docs

* fix(rln): address reviewers' comments

* fix(rln): removing ; for clippy
2022-11-28 12:05:33 +01:00
G 284e51483c
feat(rln): add example usage tutorial and expand documentation for RLN (WIP) (#74)
* feat(rln): expand documentation with minimal public API usage example

* refactor(rln): ease RLN interaction with new APIs

* feat(rln): expand API docs

* fix(rln): disable doctest for rln
2022-11-25 10:54:17 +01:00
G bc69e25359
feat(rln): add few serialization APIs to ease user interaction (#75)
* feat(rln): add few serialization APIs to ease user interaction

* fix(rln): cargo fmt
2022-11-21 17:55:08 +01:00
Aaryamann Challani fba905f45d
fix(rln): throw if attempting to insert out of bounds (#67)
* fix(rln): throw if attempting to insert out of bounds

* chore(rln): better error msg

* fix(merkle-tree): make it mimic OptimalMerkleTree impl

* chore(rln): return result as is
2022-11-10 22:41:44 +05:30
Aaryamann Challani 490206aa44
feat(rln): ability to set leaves from a given index (#63)
* feat(rln): ability to set leaves from a given index

* style(rln): fmt

* fix(rln): bubble the error

* revert: "fix(rln): bubble the error"

This reverts commit 40265082ba.

* fix(rln): replace ark::std::Zero with default

* fix(rln): ordering of ffi api

* fix(rln): use PoseidonHash::default_leaf

* chore(rln): add ffi test for batching

* docs(rln): add entry to changelog

* fix(rln): address reviews

* fix(changelog): fmt

* fix(rln): safe conversion

* fix(rln): reset tree with init func,  add comments

* chore(rln): add comment about init_tree_with_leaves

* fix(rln): comment
2022-11-03 17:49:30 +05:30
G afa4a09bba
Update public.rs
fix(rln): remove unnecessary print
2022-10-10 08:52:36 +02:00
G b77facc5e9
feat(RLN): Proof verification using provided roots (#61)
* chore(rln): better comments

* feat(rln): add verification with roots
2022-10-07 18:04:48 +02:00
G 1df6c53ca0
fix(rln): fix order of inputs in comments (#59) 2022-10-03 14:58:49 +02:00
G a5aa4e8d4f
feat(rln): add seeded keygen (#56)
* refactor(rln/zerokit): move poseidon to separate utils crate

* refactor(rln/zerokit): move merkle tree to utils crate

* feat(rln): add seeded keygen
2022-09-30 17:27:55 +02:00
G bbacc9dcce
Add `utils` module (#53)
* refactor(rln/zerokit): move poseidon to separate utils crate

* refactor(rln/zerokit): move merkle tree to utils crate

* refactor(rln/zerokit): move poseidon to separate utils crate

* fix(utils/rln): fmt & conflict resolve

* feat(utils): add parallel feature
2022-09-28 11:33:14 +02:00
G c42fcfe644
Add GrainLFRS and PrimeField trait to Poseidon (#51)
* refactor(rln): generate poseidon constants

* refactor(rln): use traits in poseidon hash; refactor constants

* fix(rln): fix poseidon hardcoded constants test

* fix(rln): cargo fmt
2022-09-27 17:17:23 +02:00
Richard Ramos c401c0b21d
feat: wasm (#38) 2022-09-20 08:22:46 -04:00
G 4dc600d353
refactor(RLN:) Remove dependencies and add new APIs (#45)
* refactor(rln): removing unused crates/dependencies

* cargo fmt

* refactor(rln): removed more dependencies; curve/fields as parameters

* refactor(rln): use poseidon-rs hash instead of semaphore-rs poseidon

* chore(rln): remove deps

* refactor(rln): use exclusively arkworks Fr

* refactor(rln): integrate poseidon-rs implementation to work with arkworks arithmetic

* fix(rln): remove previous poseidon-rs wrapper

* feat(rln): add features to select MT; remove prints if not in debug mode

* fix(rln): collect test parameters in a vector

* feat(RLN): add `new_with_params` (#36)

Allows passing the wasm, zkey and verification key data as buffers, instead of using a path to a folder

* chore(rln): simplify read wasm

* fix(rln): remove unused dependencies

* cargo fmt

* fix(rln): update dependencies, fix commit

* refactor(rln): restore ark-circom original dep

Co-authored-by: Richard Ramos <info@richardramos.me>
2022-09-15 16:32:45 +08:00
G 1131b76a66
feat(RLN): integrate Poseidon Hash (#44)
* refactor(rln): removing unused crates/dependencies

* cargo fmt

* refactor(rln): removed more dependencies; curve/fields as parameters

* refactor(rln): use poseidon-rs hash instead of semaphore-rs poseidon

* chore(rln): remove deps

* refactor(rln): use exclusively arkworks Fr

* refactor(rln): integrate poseidon-rs implementation to work with arkworks arithmetic

* fix(rln): remove previous poseidon-rs wrapper
2022-09-15 11:06:16 +08:00
G a85454cfd7
Use arkworks arithmetic only (#43)
* refactor(rln): removing unused crates/dependencies

* cargo fmt

* refactor(rln): removed more dependencies; curve/fields as parameters

* refactor(rln): use poseidon-rs hash instead of semaphore-rs poseidon

* chore(rln): remove deps

* refactor(rln): use exclusively arkworks Fr
2022-09-14 17:48:48 +08:00
Richard Ramos 2455bea922
refactor(RLN): use iterators instead of loops (#33)
* refactor(RLN): use iterators instead of loops
* fix(rln): cargo fmt
* fix(rln): cargo clippy: avoid Vec object creation

Co-authored-by: s1fr0 <28568419+s1fr0@users.noreply.github.com>
2022-08-22 07:48:31 -04:00
G 824296e695
refactor(rln): use space-efficient Merkle tree implementation (#32)
* refactor(rln): replace merkle tree implementation

refactor(rln): before switch

refactor(rln): replace merkle tree implementation

fix(rln): cargo fmt, cargo clippy

cargo fmt

* chore(rln): add comments

* chore(rln): cargo fmt; cargo clippy

* refactor(rln): improve Merkle tree crate

- Integrate previous Full storage MT with Optimal (storage) MT implementation
- Align the two implementation to same API/traits implementations
- Align implementations as much as possible to same language and variable names/meaning
- Comment code
- Add descriptions to each module's crate
- address reviewer's comments

* refactor(rln): fmt, clippy, remove pub from next index, update output type for some proc
2022-08-17 11:08:14 +02:00
G 64f5083639
RLN: update README (#27)
* refactor(rln): update readme

* fix(rln): update README in light of https://github.com/vacp2p/zerokit/pull/30
2022-08-07 16:51:03 +02:00
G 3378aed857
refactor(rln): Update Merkle tree initialization method (#30)
* refactor(rln): fix merkle tree initialization

* fix(rln): cargo fmt; cargo clippy
2022-08-05 12:36:06 +02:00
G c1db14dd7c
refactor(rln): improve circuit loading performances and tests fix (#26)
* refactor(rln): change witness generation logic to improve performance

* rln(refactor): - change circuit loading logic; - update tests with tree size 20
2022-07-29 13:40:16 +08:00
Richard Ramos 7fe9bb4f94
chore(rln): add "staticlib" to crate-type in Cargo.toml (#24) 2022-07-25 12:54:13 -04:00
oskarth 42e1743198
fix(rln): Fix CI by updating ethers dependency (#25) 2022-07-25 14:18:50 +08:00
G 9cc333811b
RLN: Update API (#22)
* refactor(rln): integrate semaphore's merkle tree implementation

* feat(rln): expand API and refactor

* refactor(rln):  support external resource path for circuits/keys, add circuit for tree_height = 20

* feat(rln): add cargo library directives
2022-06-29 18:56:03 +02:00
G 95352a4a7c
RLN: Update Rust and C API (#20)
* fix(rln): ignore dirty rln submodule

* feat(rln): add RLN witness & proof values byte serialization/deserialization

* feat(RLN): add Merkle-tree public APIs

* fix(rln): use references to avoid unnecessary clone()

* fix(rln): fix rust public API, code refactor

* fix(rln): change vector length serialization from usize to u64; add random witness generation

* feat(rln): add C APIs

* chore(rln): cargo format/clippy

* feat(rln): add C APIs tests

* chore(rln): minor code restyling

* refactor(rln): change &Vec<u8> to &[u8] (avoids  new object creation)
2022-06-22 15:36:54 +01:00
s1fr0 8e065d4a83
fix(rln): fixed proof generation/verification and E2E tests
chore(rln): clippy and fmt

fix(rln): cargo fix

ci: update submodules

chore(rln): remove unnecessary test, restyle

fix(rln): switch to field type, add field arithmetic

feat(rln): public input computation from witness

fix(rln): fix semaphore crate version
2022-06-09 15:57:03 +02:00
Oskar Thoren 23171bb041
docs(rln): Compiling circuits 2022-05-24 12:14:02 +01:00
Oskar Thoren af0397fa09
chore(rln): Add git submodule 2022-05-24 12:08:42 +01:00
Oskar Thoren 45520e7869
refactor(rln): Upgrade semaphore-rs 2022-05-23 09:28:13 +01:00
Oskar Thoren 1d8408d743
style(rln): cargo fmt 2022-05-23 08:07:32 +01:00
Oskar Thoren f2f3c820ff
test(rln): Add passing semaphore test 2022-03-18 19:17:50 +08:00
Oskar Thoren ddb3efc4a5
docs(rln): more notes and todos 2022-03-18 15:55:41 +08:00
Oskar Thoren cb38360311
docs(rln): comments and notes 2022-03-18 15:01:37 +08:00
Oskar Thoren 6b3be4438e
refactor(rln): move out json spike to separate fn 2022-03-18 14:42:38 +08:00
Oskar Thoren 0d087e3f0a
test(rln): end to end test wip 2022-03-18 14:32:54 +08:00
Oskar Thoren 1e8e834887
feat(rln): add wip rln protocol abstraction 2022-03-18 14:23:44 +08:00
Oskar Thoren ceddd20ff1
fix(rln): correct rln wasm path 2022-03-18 14:23:23 +08:00
Oskar Thoren be1fafd27f
feat(rln): add rln zkey based circuit abstraction
Different from CircomConfig etc
2022-03-18 14:13:10 +08:00
Oskar Thoren c566b29c6d
docs: add notes and todos 2022-03-18 13:38:48 +08:00
Oskar Thoren 6fdaf3474b
docs: add todos 2022-03-18 13:21:09 +08:00
Oskar Thoren 9cb37a229d
refactor(rln): use semaphore-rs as dep
Instead of manually importing moving target

Assumes public functions etc are exposed and that code bases /
priorities end up developing in same way

1) Upstream changes
2) Keep fork up to date
3) Keep option open to embed it as appropriate
2022-03-18 12:57:11 +08:00
Oskar Thoren 3314aba6cc
refactor(rln): Use PoseidonTree
Some LE stuff to sort
2022-03-17 19:15:11 +08:00
Oskar Thoren 6881a078d6
feat(rln): Add IncrementalMerkleTree to RLN
- Sapling-based version
- Also Update ffi with get_root
2022-03-17 16:00:50 +08:00
Oskar Thoren 14aaf696d3
feat(rln): import sapling-based merkle impl 2022-03-17 15:39:14 +08:00
Oskar Thoren 445c12da29
feat(rln): import sapling-based poseidon
From RLN lib, should probably be rewritten to use arkworks
2022-03-17 15:24:36 +08:00
Oskar Thoren 0774674c6e
test(rln): merkle proof 2022-03-17 13:59:00 +08:00
Oskar Thoren ccdf1e75d7
feat(rln): add debug impl for PoseidonHash 2022-03-16 16:40:25 +08:00
Oskar Thoren 9b5cd131c6
test(rln): ignore expensive test by default 2022-03-16 16:05:41 +08:00
Oskar Thoren 826a02f652
feat(rln): add hash, merkle and poseidon tree
Import from existing semaphore-rs
2022-03-16 16:05:23 +08:00
Oskar Thoren 83ef5ae3c3
chore: make clippy happy 2022-03-16 14:30:51 +08:00
Oskar Thoren 292ece2945
style: cargo fmt 2022-03-16 14:18:54 +08:00
Oskar Thoren 6717a24c07
chore(rln): clippy ignore unsafe
Already wrapped in unsafe block but doesn't seem to work. Whole function
can be made unsafe but shouldn't be necessary from what I can tell.
2022-03-16 14:16:43 +08:00
Oskar Thoren abe67c8d4a
chore: use remote instead of local deps 2022-03-16 14:01:44 +08:00
Oskar Thoren 0dbf417e63
fix(rln): use rln in public module
Previously this was using Multipler boilerplate. This also fixes tests.
2022-03-16 13:54:02 +08:00
Oskar Thoren 15c331db36
Add identity poseidon test 2022-03-15 18:04:11 +08:00
Oskar Thoren c718101ff1
import util for fr/bigint 2022-03-15 17:51:13 +08:00
Oskar Thoren b2fe1bd99b
more deps 2022-03-15 17:48:42 +08:00
Oskar Thoren b2a301a967
Import identity.rs from semaphore-rs 2022-03-15 17:30:44 +08:00
Oskar Thoren 751fd22951
Add deps 2022-03-15 17:29:40 +08:00
Oskar Thoren f090f199ac
Add poseidon-rs 2022-03-15 17:27:24 +08:00
Oskar Thoren b23dabab4f
Update RLN README 2022-03-11 18:09:45 +08:00
Oskar Thoren 4737dd34c1
Adapt rln fields etc
Proof works!
2022-03-11 18:08:41 +08:00
Oskar Thoren 224589a1ed
Add rln r1cs wasm files 2022-03-11 17:55:55 +08:00
Oskar Thoren 2af04cc729
Init rln from poseidon-tornado 2022-03-11 17:55:46 +08:00