mirror of https://github.com/waku-org/go-rln.git
added cbindgen
This commit is contained in:
parent
a69c11dcff
commit
3faa61ce34
4
Makefile
4
Makefile
|
@ -1,6 +1,8 @@
|
|||
.PHONY: rlnlib
|
||||
|
||||
rlnlib:
|
||||
cd lib/rln && cargo build --release
|
||||
cp lib/rln/target/release/librln.* lib/
|
||||
cbindgen --config ../cbindgen.toml --crate rln --output librln.h --lang c
|
||||
mv lib/rln/target/release/librln.* lib/
|
||||
|
||||
# @TODO TARGET FOR BINDINGS.
|
48
lib/librln.h
48
lib/librln.h
|
@ -1,37 +1,35 @@
|
|||
#include <cstdarg>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
template<typename E = void>
|
||||
struct RLN;
|
||||
typedef struct RLN_Bn256 RLN_Bn256;
|
||||
|
||||
/// 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 {
|
||||
/**
|
||||
* Buffer struct is taken from
|
||||
* https://github.com/celo-org/celo-threshold-bls-rs/blob/master/crates/threshold-bls-ffi/src/ffi.rs
|
||||
*/
|
||||
typedef struct Buffer {
|
||||
const uint8_t *ptr;
|
||||
uintptr_t len;
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
} Buffer;
|
||||
|
||||
bool new_circuit_from_params(uintptr_t merkle_depth,
|
||||
const Buffer *parameters_buffer,
|
||||
RLN<Bn256> **ctx);
|
||||
const struct Buffer *parameters_buffer,
|
||||
struct RLN_Bn256 **ctx);
|
||||
|
||||
bool generate_proof(const RLN<Bn256> *ctx, const Buffer *input_buffer, Buffer *output_buffer);
|
||||
bool generate_proof(const struct RLN_Bn256 *ctx,
|
||||
const struct Buffer *input_buffer,
|
||||
struct Buffer *output_buffer);
|
||||
|
||||
bool verify(const RLN<Bn256> *ctx,
|
||||
const Buffer *proof_buffer,
|
||||
const Buffer *public_inputs_buffer,
|
||||
bool verify(const struct RLN_Bn256 *ctx,
|
||||
const struct Buffer *proof_buffer,
|
||||
const struct Buffer *public_inputs_buffer,
|
||||
uint32_t *result_ptr);
|
||||
|
||||
bool hash(const RLN<Bn256> *ctx,
|
||||
const Buffer *inputs_buffer,
|
||||
bool hash(const struct RLN_Bn256 *ctx,
|
||||
const struct Buffer *inputs_buffer,
|
||||
const uintptr_t *input_len,
|
||||
Buffer *output_buffer);
|
||||
struct Buffer *output_buffer);
|
||||
|
||||
bool key_gen(const RLN<Bn256> *ctx, Buffer *keypair_buffer);
|
||||
|
||||
} // extern "C"
|
||||
bool key_gen(const struct RLN_Bn256 *ctx, struct Buffer *keypair_buffer);
|
||||
|
|
Loading…
Reference in New Issue