diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..776131f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "rln"] + path = lib/rln + url = https://github.com/kilic/rln diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d87dc46 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +.PHONY: rlnlib +rlnlib: + cd lib/rln && cargo build --release + cp lib/rln/target/release/librln.* lib/ \ No newline at end of file diff --git a/lib/librln.h b/lib/librln.h new file mode 100644 index 0000000..2394ac7 --- /dev/null +++ b/lib/librln.h @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include + +template +struct RLN; + +/// Buffer struct is taken from +/// https://github.com/celo-org/celo-threshold-bls-rs/blob/master/crates/threshold-bls-ffi/src/ffi.rs +struct Buffer { + const uint8_t *ptr; + uintptr_t len; +}; + +extern "C" { + +bool new_circuit_from_params(uintptr_t merkle_depth, + const Buffer *parameters_buffer, + RLN **ctx); + +bool generate_proof(const RLN *ctx, const Buffer *input_buffer, Buffer *output_buffer); + +bool verify(const RLN *ctx, + const Buffer *proof_buffer, + const Buffer *public_inputs_buffer, + uint32_t *result_ptr); + +bool hash(const RLN *ctx, + const Buffer *inputs_buffer, + const uintptr_t *input_len, + Buffer *output_buffer); + +bool key_gen(const RLN *ctx, Buffer *keypair_buffer); + +} // extern "C" diff --git a/lib/rln/cbindgen.toml b/lib/rln/cbindgen.toml new file mode 100644 index 0000000..e69de29 diff --git a/rln.go b/rln.go new file mode 100644 index 0000000..2c65ab1 --- /dev/null +++ b/rln.go @@ -0,0 +1,12 @@ +package main + +/* +//#cgo CFLAGS: -I../lib +#cgo LDFLAGS: -L./lib -llibrnl +#include "./lib/librln.h" +*/ +import "C" + +func main() { + C.verify() +}