mirror of
https://github.com/logos-messaging/go-rln.git
synced 2026-01-11 01:13:05 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb630fcf3b | ||
|
|
0b11737b65 | ||
|
|
af16918a8d | ||
|
|
e8bc51f653 | ||
|
|
e6f625d283 | ||
|
|
e9ce4db29a | ||
|
|
7d5fb6db12 | ||
|
|
c58534eb3b | ||
|
|
346e01fa7e | ||
|
|
429ea1c12a | ||
|
|
9bd071c7fb | ||
|
|
f6ea3a73ab | ||
|
|
7497b77073 |
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -1,6 +1,6 @@
|
||||
[submodule "rln"]
|
||||
path = lib/rln
|
||||
url = https://github.com/kilic/rln
|
||||
url = https://github.com/status-im/rln
|
||||
[submodule "lib/rln"]
|
||||
path = lib/rln
|
||||
url = git@github.com:kilic/rln.git
|
||||
url = git@github.com:status-im/rln.git
|
||||
|
||||
2
Makefile
2
Makefile
@ -13,4 +13,4 @@ rlnlib:
|
||||
cd lib/rln && cbindgen --config ../cbindgen.toml --crate rln --output ../../rln/librln.h --lang c
|
||||
|
||||
test:
|
||||
LD_LIBRARY_PATH="${PWD}/libs/x86_64-unknown-linux-gnu/" go test ./... -count 1 -v
|
||||
go test ./... -count 1 -v
|
||||
9
go.mod
9
go.mod
@ -1,10 +1,13 @@
|
||||
module github.com/decanus/go-rln
|
||||
module github.com/waku-org/go-rln
|
||||
|
||||
go 1.16
|
||||
go 1.17
|
||||
|
||||
require github.com/stretchr/testify v1.7.2
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/stretchr/testify v1.7.2
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
2
lib/rln
2
lib/rln
@ -1 +1 @@
|
||||
Subproject commit 7ac74183f8b69b399e3bc96c1ae8ab61c026dc43
|
||||
Subproject commit a7d30f175f903fa21864470e98445bffe32280da
|
||||
BIN
libs/aarch64-apple-darwin/librln.a
Normal file
BIN
libs/aarch64-apple-darwin/librln.a
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
/Users/deaneigenmann/go/src/github.com/decanus/go-rln/lib/rln/target/aarch64-apple-darwin/release/librln.dylib: /Users/deaneigenmann/go/src/github.com/decanus/go-rln/lib/rln/src/circuit/mod.rs /Users/deaneigenmann/go/src/github.com/decanus/go-rln/lib/rln/src/circuit/polynomial.rs /Users/deaneigenmann/go/src/github.com/decanus/go-rln/lib/rln/src/circuit/poseidon.rs /Users/deaneigenmann/go/src/github.com/decanus/go-rln/lib/rln/src/circuit/rln.rs /Users/deaneigenmann/go/src/github.com/decanus/go-rln/lib/rln/src/ffi.rs /Users/deaneigenmann/go/src/github.com/decanus/go-rln/lib/rln/src/lib.rs /Users/deaneigenmann/go/src/github.com/decanus/go-rln/lib/rln/src/merkle.rs /Users/deaneigenmann/go/src/github.com/decanus/go-rln/lib/rln/src/poseidon.rs /Users/deaneigenmann/go/src/github.com/decanus/go-rln/lib/rln/src/public.rs /Users/deaneigenmann/go/src/github.com/decanus/go-rln/lib/rln/src/utils.rs
|
||||
Binary file not shown.
BIN
libs/aarch64-linux-android/librln.a
Normal file
BIN
libs/aarch64-linux-android/librln.a
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/aarch64-linux-android/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/aarch64-linux-android/release/build/num-bigint-4ba1a00c5942ed3b/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
BIN
libs/aarch64-unknown-linux-gnu/librln.a
Normal file
BIN
libs/aarch64-unknown-linux-gnu/librln.a
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/aarch64-unknown-linux-gnu/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/aarch64-unknown-linux-gnu/release/build/num-bigint-69b80aa090dc4b25/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/arm-unknown-linux-gnueabi/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/arm-unknown-linux-gnueabi/release/build/num-bigint-9bbf2c096f81fccc/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/arm-unknown-linux-gnueabihf/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/arm-unknown-linux-gnueabihf/release/build/num-bigint-c5d4eab0df01f46f/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
BIN
libs/armv7-linux-androideabi/librln.a
Normal file
BIN
libs/armv7-linux-androideabi/librln.a
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/armv7-linux-androideabi/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/armv7-linux-androideabi/release/build/num-bigint-8fa42ea69abd53fb/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
BIN
libs/i686-linux-android/librln.a
Normal file
BIN
libs/i686-linux-android/librln.a
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/i686-linux-android/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/i686-linux-android/release/build/num-bigint-5b002515a3c1c3de/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
BIN
libs/i686-pc-windows-gnu/librln.a
Normal file
BIN
libs/i686-pc-windows-gnu/librln.a
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/i686-pc-windows-gnu/release/librln.rlib: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/i686-pc-windows-gnu/release/build/num-bigint-cab2a6b70097bfc3/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
BIN
libs/i686-unknown-linux-gnu/librln.a
Normal file
BIN
libs/i686-unknown-linux-gnu/librln.a
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/i686-unknown-linux-gnu/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/i686-unknown-linux-gnu/release/build/num-bigint-b0e1c075ff9f6d68/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/mips-unknown-linux-gnu/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/mips-unknown-linux-gnu/release/build/num-bigint-2a58e28365905d0a/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/mips64-unknown-linux-gnuabi64/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/mips64-unknown-linux-gnuabi64/release/build/num-bigint-a70850dcc99c7fb1/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/mips64el-unknown-linux-gnuabi64/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/mips64el-unknown-linux-gnuabi64/release/build/num-bigint-0b729d8fe959893e/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/mipsel-unknown-linux-gnu/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/mipsel-unknown-linux-gnu/release/build/num-bigint-23ad468891d1fc36/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
BIN
libs/universal/librln.a
Normal file
BIN
libs/universal/librln.a
Normal file
Binary file not shown.
BIN
libs/x86_64-apple-darwin/librln.a
Normal file
BIN
libs/x86_64-apple-darwin/librln.a
Normal file
Binary file not shown.
BIN
libs/x86_64-linux-android/librln.a
Normal file
BIN
libs/x86_64-linux-android/librln.a
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/x86_64-linux-android/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/x86_64-linux-android/release/build/num-bigint-a07eaff1eafc61a9/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
BIN
libs/x86_64-pc-windows-gnu/librln.a
Normal file
BIN
libs/x86_64-pc-windows-gnu/librln.a
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/x86_64-pc-windows-gnu/release/librln.rlib: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/x86_64-pc-windows-gnu/release/build/num-bigint-2d87d54ca5f526b6/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
BIN
libs/x86_64-unknown-linux-gnu/librln.a
Normal file
BIN
libs/x86_64-unknown-linux-gnu/librln.a
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/x86_64-unknown-linux-gnu/release/librln.so: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/x86_64-unknown-linux-gnu/release/build/num-bigint-e05ef1c2b46a8adc/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
Binary file not shown.
BIN
libs/x86_64-unknown-linux-musl/librln.a
Normal file
BIN
libs/x86_64-unknown-linux-musl/librln.a
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
/target/x86_64-unknown-linux-musl/release/librln.rlib: /project/src/circuit/mod.rs /project/src/circuit/polynomial.rs /project/src/circuit/poseidon.rs /project/src/circuit/rln.rs /project/src/ffi.rs /project/src/hash_to_field.rs /project/src/lib.rs /project/src/merkle.rs /project/src/poseidon.rs /project/src/public.rs /project/src/utils.rs /target/x86_64-unknown-linux-musl/release/build/num-bigint-11903a3d0fc503f2/out/radix_bases.rs build.rs
|
||||
Binary file not shown.
21
rln/link.go
Normal file
21
rln/link.go
Normal file
@ -0,0 +1,21 @@
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS:-lrln -ldl -lm
|
||||
#cgo android,arm64 LDFLAGS:-L${SRCDIR}/../libs/aarch64-linux-android
|
||||
#cgo android,arm7 LDFLAGS:-L${SRCDIR}/../libs/armv7-linux-androideabi
|
||||
#cgo android,amd64 LDFLAGS:-L${SRCDIR}/../libs/x86_64-linux-android
|
||||
#cgo android,386 LDFLAGS:-L${SRCDIR}/../libs/i686-linux-android
|
||||
#cgo linux,arm LDFLAGS:-L${SRCDIR}/../libs/armv7-linux-androideabi
|
||||
#cgo linux,arm64 LDFLAGS:-L${SRCDIR}/../libs/aarch64-unknown-linux-gnu
|
||||
#cgo linux,amd64,musl,!android LDFLAGS:-L${SRCDIR}/../libs/x86_64-unknown-linux-musl
|
||||
#cgo linux,amd64,!musl,!android LDFLAGS:-L${SRCDIR}/../libs/x86_64-unknown-linux-gnu
|
||||
#cgo linux,386 LDFLAGS:-L${SRCDIR}/../libs/i686-unknown-linux-gnu
|
||||
#cgo windows,386 LDFLAGS:-L${SRCDIR}/../libs/i686-pc-windows-gnu -lrln -lm -lws2_32 -luserenv
|
||||
#cgo windows,amd64 LDFLAGS:-L${SRCDIR}/../libs/x86_64-pc-windows-gnu -lrln -lm -lws2_32 -luserenv
|
||||
#cgo darwin,386,!ios LDFLAGS:-L${SRCDIR}/../libs/i686-apple-darwin
|
||||
#cgo darwin,arm64,!ios LDFLAGS:-L${SRCDIR}/../libs/aarch64-apple-darwin
|
||||
#cgo darwin,amd64,!ios LDFLAGS:-L${SRCDIR}/../libs/x86_64-apple-darwin
|
||||
#cgo ios LDFLAGS:-L${SRCDIR}/../libs/universal -framework Security -framework Foundation
|
||||
*/
|
||||
import "C"
|
||||
@ -36,7 +36,7 @@ func NewRLNWithDepth(depth int, params []byte) (*RLN, error) {
|
||||
in := (*C.Buffer)(C.malloc(C.size_t(size)))
|
||||
*in = buf
|
||||
|
||||
if !bool(C.new_circuit_from_params(C.ulong(depth), in, &r.ptr)) {
|
||||
if !bool(C.new_circuit_from_params(C.uintptr_t(depth), in, &r.ptr)) {
|
||||
return nil, errors.New("failed to initialize")
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ func toBuffer(data []byte) C.Buffer {
|
||||
dataPtr, dataLen := sliceToPtr(data)
|
||||
return C.Buffer{
|
||||
ptr: dataPtr,
|
||||
len: C.ulong(dataLen),
|
||||
len: C.uintptr_t(dataLen),
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ func (r *RLN) InsertMember(idComm IDCommitment) bool {
|
||||
// parameter is the position of the id commitment key to be deleted from the tree.
|
||||
// The deleted id commitment key is replaced with a zero leaf
|
||||
func (r *RLN) DeleteMember(index MembershipIndex) bool {
|
||||
deletionSuccess := bool(C.delete_member(r.ptr, C.ulong(index)))
|
||||
deletionSuccess := bool(C.delete_member(r.ptr, C.uintptr_t(index)))
|
||||
return deletionSuccess
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
// +build android
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/aarch64-linux-android -L${SRCDIR}/../libs/armv7-linux-androideabi -L${SRCDIR}/../libs/i686-linux-android -L${SRCDIR}/../libs/x86_64-linux-android -lrln -ldl -lm
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build linux,arm,!arm7
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/arm-unknown-linux-gnueabi -lrln -ldl -lm
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build linux,arm64
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/aarch64-unknown-linux-gnu -lrln -ldl -lm
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build arm7
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/arm-unknown-linux-gnueabihf -lrln -ldl -lm
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build darwin,386,!ios
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/i686-apple-darwin -lrln -ldl -lm
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build darwin,amd64,!ios
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/x86_64-apple-darwin -lrln -ldl -lm
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build darwin,arm64,!ios
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/aarch64-apple-darwin -lrln -ldl -lm
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build ios
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/universal -lrln -ldl -lm -framework Security -framework Foundation
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build !android,linux,386,!musl
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/i686-unknown-linux-gnu -lrln -ldl -lm -lpthread
|
||||
*/
|
||||
import "C"
|
||||
@ -1,9 +0,0 @@
|
||||
//go:build !android && linux && amd64 && !musl
|
||||
// +build !android,linux,amd64,!musl
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/x86_64-unknown-linux-gnu -lrln -ldl -lm -lpthread
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build !android,musl
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/x86_64-unknown-linux-musl -lrln -ldl -lm
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build linux,mips
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/mips-unknown-linux-gnu -lrln -ldl -lm
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build linux,mips64
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/mips64-unknown-linux-gnuabi64 -lrln -ldl -lm
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build linux,mips64le
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/mips64el-unknown-linux-gnuabi64 -lrln -ldl -lm
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build linux,mipsle
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/mipsel-unknown-linux-gnu -lrln -ldl -lm
|
||||
*/
|
||||
import "C"
|
||||
@ -10,17 +10,17 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
func TestWakuRLNRelaySuite(t *testing.T) {
|
||||
suite.Run(t, new(WakuRLNRelaySuite))
|
||||
func TestRLNSuite(t *testing.T) {
|
||||
suite.Run(t, new(RLNSuite))
|
||||
}
|
||||
|
||||
type WakuRLNRelaySuite struct {
|
||||
type RLNSuite struct {
|
||||
suite.Suite
|
||||
|
||||
parameters []byte
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) SetupTest() {
|
||||
func (s *RLNSuite) SetupTest() {
|
||||
// parameters.key contains the prover and verifier keys
|
||||
// to generate this file, clone this repo https://github.com/kilic/rln
|
||||
// and run the following command in the root directory of the cloned project
|
||||
@ -38,7 +38,7 @@ func (s *WakuRLNRelaySuite) SetupTest() {
|
||||
s.parameters = params
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) TestMembershipKeyGen() {
|
||||
func (s *RLNSuite) TestMembershipKeyGen() {
|
||||
rln, err := NewRLNWithDepth(32, s.parameters)
|
||||
s.NoError(err)
|
||||
|
||||
@ -52,7 +52,7 @@ func (s *WakuRLNRelaySuite) TestMembershipKeyGen() {
|
||||
s.False(bytes.Equal(key.IDKey[:], make([]byte, 32)))
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) TestGetMerkleRoot() {
|
||||
func (s *RLNSuite) TestGetMerkleRoot() {
|
||||
rln, err := NewRLNWithDepth(32, s.parameters)
|
||||
s.NoError(err)
|
||||
|
||||
@ -67,7 +67,7 @@ func (s *WakuRLNRelaySuite) TestGetMerkleRoot() {
|
||||
s.Equal(root1, root2)
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) TestInsertMember() {
|
||||
func (s *RLNSuite) TestInsertMember() {
|
||||
rln, err := NewRLNWithDepth(32, s.parameters)
|
||||
s.NoError(err)
|
||||
|
||||
@ -78,7 +78,7 @@ func (s *WakuRLNRelaySuite) TestInsertMember() {
|
||||
s.True(inserted)
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) TestRemoveMember() {
|
||||
func (s *RLNSuite) TestRemoveMember() {
|
||||
rln, err := NewRLNWithDepth(32, s.parameters)
|
||||
s.NoError(err)
|
||||
|
||||
@ -86,7 +86,7 @@ func (s *WakuRLNRelaySuite) TestRemoveMember() {
|
||||
s.True(deleted)
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) TestMerkleTreeConsistenceBetweenDeletionAndInsertion() {
|
||||
func (s *RLNSuite) TestMerkleTreeConsistenceBetweenDeletionAndInsertion() {
|
||||
rln, err := NewRLNWithDepth(32, s.parameters)
|
||||
s.NoError(err)
|
||||
|
||||
@ -123,7 +123,7 @@ func (s *WakuRLNRelaySuite) TestMerkleTreeConsistenceBetweenDeletionAndInsertion
|
||||
s.Equal(root1, root3)
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) TestHash() {
|
||||
func (s *RLNSuite) TestHash() {
|
||||
rln, err := NewRLNWithDepth(32, s.parameters)
|
||||
s.NoError(err)
|
||||
|
||||
@ -137,7 +137,7 @@ func (s *WakuRLNRelaySuite) TestHash() {
|
||||
s.Equal(expectedHash, hash[:])
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) TestCreateListMembershipKeysAndCreateMerkleTreeFromList() {
|
||||
func (s *RLNSuite) TestCreateListMembershipKeysAndCreateMerkleTreeFromList() {
|
||||
groupSize := 100
|
||||
list, root, err := CreateMembershipList(groupSize, s.parameters)
|
||||
s.NoError(err)
|
||||
@ -145,7 +145,7 @@ func (s *WakuRLNRelaySuite) TestCreateListMembershipKeysAndCreateMerkleTreeFromL
|
||||
s.Len(root, HASH_HEX_SIZE) // check the size of the calculated tree root
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) TestCheckCorrectness() {
|
||||
func (s *RLNSuite) TestCheckCorrectness() {
|
||||
groupKeys := STATIC_GROUP_KEYS
|
||||
|
||||
// create a set of MembershipKeyPair objects from groupKeys
|
||||
@ -168,7 +168,7 @@ func (s *WakuRLNRelaySuite) TestCheckCorrectness() {
|
||||
s.Equal(expectedRoot, root[:])
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) TestValidProof() {
|
||||
func (s *RLNSuite) TestValidProof() {
|
||||
rln, err := NewRLN(s.parameters)
|
||||
s.NoError(err)
|
||||
|
||||
@ -210,7 +210,7 @@ func (s *WakuRLNRelaySuite) TestValidProof() {
|
||||
s.True(verified)
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) TestInvalidProof() {
|
||||
func (s *RLNSuite) TestInvalidProof() {
|
||||
rln, err := NewRLN(s.parameters)
|
||||
s.NoError(err)
|
||||
|
||||
@ -254,7 +254,7 @@ func (s *WakuRLNRelaySuite) TestInvalidProof() {
|
||||
s.False(verified)
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) TestEpochConsistency() {
|
||||
func (s *RLNSuite) TestEpochConsistency() {
|
||||
// check edge cases
|
||||
var epoch uint64 = math.MaxUint64
|
||||
epochBytes := ToEpoch(epoch)
|
||||
@ -263,7 +263,7 @@ func (s *WakuRLNRelaySuite) TestEpochConsistency() {
|
||||
s.Equal(epoch, decodedEpoch)
|
||||
}
|
||||
|
||||
func (s *WakuRLNRelaySuite) TestEpochComparison() {
|
||||
func (s *RLNSuite) TestEpochComparison() {
|
||||
// check edge cases
|
||||
var time1 uint64 = math.MaxUint64
|
||||
var time2 uint64 = math.MaxUint64 - 1
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
// +build windows,386
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/i686-pc-windows-gnu -lrln -lm -lws2_32 -luserenv
|
||||
*/
|
||||
import "C"
|
||||
@ -1,8 +0,0 @@
|
||||
// +build windows,amd64
|
||||
|
||||
package rln
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L${SRCDIR}/../libs/x86_64-pc-windows-gnu -lrln -lm -lws2_32 -luserenv
|
||||
*/
|
||||
import "C"
|
||||
59
rln/types.go
59
rln/types.go
@ -7,21 +7,21 @@ import (
|
||||
)
|
||||
|
||||
// IDKey is an identity key as defined in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
||||
type IDKey [32]byte
|
||||
type IDKey = [32]byte
|
||||
|
||||
// IDCommintment is hash of identity key as defined in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
||||
type IDCommitment [32]byte
|
||||
type IDCommitment = [32]byte
|
||||
|
||||
// Each node of the Merkle tee is a Poseidon hash which is a 32 byte value
|
||||
type MerkleNode [32]byte
|
||||
type MerkleNode = [32]byte
|
||||
|
||||
type Nullifier [32]byte
|
||||
type Nullifier = [32]byte
|
||||
|
||||
type ZKSNARK [256]byte
|
||||
type ZKSNARK = [256]byte
|
||||
|
||||
// Custom data types defined for waku rln relay -------------------------
|
||||
|
||||
type MembershipKeyPair struct {
|
||||
type MembershipKeyPair = struct {
|
||||
// user's identity key (a secret key) which is selected randomly
|
||||
// see details in https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?view#Membership
|
||||
IDKey IDKey
|
||||
@ -50,7 +50,7 @@ type RateLimitProof struct {
|
||||
Nullifier Nullifier
|
||||
}
|
||||
|
||||
type MembershipIndex uint
|
||||
type MembershipIndex = uint
|
||||
|
||||
type ProofMetadata struct {
|
||||
Nullifier Nullifier
|
||||
@ -62,29 +62,9 @@ func (p ProofMetadata) Equals(p2 ProofMetadata) bool {
|
||||
return bytes.Equal(p.Nullifier[:], p2.Nullifier[:]) && bytes.Equal(p.ShareX[:], p2.ShareX[:]) && bytes.Equal(p.ShareY[:], p2.ShareY[:])
|
||||
}
|
||||
|
||||
type MessageValidationResult int
|
||||
|
||||
const (
|
||||
MessageValidationResult_Unknown MessageValidationResult = iota
|
||||
MessageValidationResult_Valid
|
||||
MessageValidationResult_Invalid
|
||||
MessageValidationResult_Spam
|
||||
)
|
||||
|
||||
/*
|
||||
# inputs of the membership contract constructor
|
||||
# TODO may be able to make these constants private and put them inside the waku_rln_relay_utils
|
||||
const
|
||||
MEMBERSHIP_FEE* = 5.u256
|
||||
*/
|
||||
|
||||
// the current implementation of the rln lib only supports a circuit for Merkle tree with depth 32
|
||||
const MERKLE_TREE_DEPTH int = 20
|
||||
|
||||
// TODO the ETH_CLIENT should be an input to the rln-relay, though hardcoded for now
|
||||
// the current address is the address of ganache-cli when run locally
|
||||
const ETH_CLIENT = "ws://localhost:8540/"
|
||||
|
||||
// HASH_BIT_SIZE is the size of poseidon hash output in bits
|
||||
const HASH_BIT_SIZE = 256
|
||||
|
||||
@ -211,16 +191,7 @@ func init() {
|
||||
// the root is created locally, using createMembershipList proc from waku_rln_relay_utils module, and the result is hardcoded in here
|
||||
const STATIC_GROUP_MERKLE_ROOT = "a1877a553eff12e1b21632a0545a916a5c5b8060ad7cc6c69956741134397b2d"
|
||||
|
||||
// the rln-relay epoch length in seconds
|
||||
// TODO: change data type
|
||||
const EPOCH_UNIT_SECONDS = time.Second * 10
|
||||
|
||||
// the maximum clock difference between peers in seconds
|
||||
// TODO: change data type
|
||||
const MAX_CLOCK_GAP_SECONDS = 20 * time.Second
|
||||
|
||||
// maximum allowed gap between the epochs of messages' RateLimitProofs
|
||||
const MAX_EPOCH_GAP = int64(MAX_CLOCK_GAP_SECONDS / EPOCH_UNIT_SECONDS)
|
||||
const EPOCH_UNIT_SECONDS = uint64(10) // the rln-relay epoch length in seconds
|
||||
|
||||
type Epoch [32]byte
|
||||
|
||||
@ -240,16 +211,14 @@ func (e Epoch) Uint64() uint64 {
|
||||
return binary.LittleEndian.Uint64(e[:])
|
||||
}
|
||||
|
||||
// CalcEpoch gets time `t` as `float64` with subseconds resolution in the fractional part
|
||||
// and returns its corresponding rln `Epoch` value
|
||||
func CalcEpoch(t time.Duration) Epoch {
|
||||
e := uint64(t / EPOCH_UNIT_SECONDS)
|
||||
return ToEpoch(e)
|
||||
// CalcEpoch returns the corresponding rln `Epoch` value for a time.Time
|
||||
func CalcEpoch(t time.Time) Epoch {
|
||||
return ToEpoch(uint64(t.Unix()) / EPOCH_UNIT_SECONDS)
|
||||
}
|
||||
|
||||
// GetCurrentEpoch gets the current rln Epoch time
|
||||
func GetCurrentEpoch() Epoch {
|
||||
return ToEpoch(uint64(time.Now().Unix()))
|
||||
return CalcEpoch(time.Now())
|
||||
}
|
||||
|
||||
// Diff returns the difference between the two rln `Epoch`s `e1` and `e2`
|
||||
@ -258,3 +227,7 @@ func Diff(e1, e2 Epoch) int64 {
|
||||
epoch2 := e2.Uint64()
|
||||
return int64(epoch1) - int64(epoch2)
|
||||
}
|
||||
|
||||
func (e Epoch) Time() time.Time {
|
||||
return time.Unix(int64(e.Uint64()*EPOCH_UNIT_SECONDS), 0)
|
||||
}
|
||||
|
||||
@ -59,5 +59,5 @@ for platform in `ls ${COMPILE_DIR} | grep -v release | grep -v debug`
|
||||
do
|
||||
PLATFORM_DIR=${DIRECTORY}/$platform
|
||||
mkdir -p ${PLATFORM_DIR}
|
||||
cp ${COMPILE_DIR}/$platform/release/librln.* ${PLATFORM_DIR}
|
||||
cp ${COMPILE_DIR}/$platform/release/librln.{a,lib} ${PLATFORM_DIR}
|
||||
done
|
||||
|
||||
@ -57,5 +57,5 @@ for platform in `ls ${COMPILE_DIR} | grep -v release | grep -v debug`
|
||||
do
|
||||
PLATFORM_DIR=${DIRECTORY}/$platform
|
||||
mkdir -p ${PLATFORM_DIR}
|
||||
cp ${COMPILE_DIR}/$platform/release/librln.* ${PLATFORM_DIR}
|
||||
cp ${COMPILE_DIR}/$platform/release/librln.{a,lib} ${PLATFORM_DIR}
|
||||
done
|
||||
Loading…
x
Reference in New Issue
Block a user