started working on things

This commit is contained in:
decanus 2021-09-13 13:37:42 +02:00
parent 609b91bfe3
commit b5279edfc6
No known key found for this signature in database
GPG Key ID: 3730AAF5D6589867
5 changed files with 56 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "rln"]
path = lib/rln
url = https://github.com/kilic/rln

4
Makefile Normal file
View File

@ -0,0 +1,4 @@
.PHONY: rlnlib
rlnlib:
cd lib/rln && cargo build --release
cp lib/rln/target/release/librln.* lib/

37
lib/librln.h Normal file
View File

@ -0,0 +1,37 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
template<typename E = void>
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<Bn256> **ctx);
bool generate_proof(const RLN<Bn256> *ctx, const Buffer *input_buffer, Buffer *output_buffer);
bool verify(const RLN<Bn256> *ctx,
const Buffer *proof_buffer,
const Buffer *public_inputs_buffer,
uint32_t *result_ptr);
bool hash(const RLN<Bn256> *ctx,
const Buffer *inputs_buffer,
const uintptr_t *input_len,
Buffer *output_buffer);
bool key_gen(const RLN<Bn256> *ctx, Buffer *keypair_buffer);
} // extern "C"

0
lib/rln/cbindgen.toml Normal file
View File

12
rln.go Normal file
View File

@ -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()
}