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
|
.PHONY: rlnlib
|
||||||
|
|
||||||
rlnlib:
|
rlnlib:
|
||||||
cd lib/rln && cargo build --release
|
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.
|
# @TODO TARGET FOR BINDINGS.
|
48
lib/librln.h
48
lib/librln.h
|
@ -1,37 +1,35 @@
|
||||||
#include <cstdarg>
|
#include <stdarg.h>
|
||||||
#include <cstdint>
|
#include <stdbool.h>
|
||||||
#include <cstdlib>
|
#include <stdint.h>
|
||||||
#include <ostream>
|
#include <stdlib.h>
|
||||||
#include <new>
|
|
||||||
|
|
||||||
template<typename E = void>
|
typedef struct RLN_Bn256 RLN_Bn256;
|
||||||
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
|
* Buffer struct is taken from
|
||||||
struct Buffer {
|
* 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;
|
const uint8_t *ptr;
|
||||||
uintptr_t len;
|
uintptr_t len;
|
||||||
};
|
} Buffer;
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
|
|
||||||
bool new_circuit_from_params(uintptr_t merkle_depth,
|
bool new_circuit_from_params(uintptr_t merkle_depth,
|
||||||
const Buffer *parameters_buffer,
|
const struct Buffer *parameters_buffer,
|
||||||
RLN<Bn256> **ctx);
|
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,
|
bool verify(const struct RLN_Bn256 *ctx,
|
||||||
const Buffer *proof_buffer,
|
const struct Buffer *proof_buffer,
|
||||||
const Buffer *public_inputs_buffer,
|
const struct Buffer *public_inputs_buffer,
|
||||||
uint32_t *result_ptr);
|
uint32_t *result_ptr);
|
||||||
|
|
||||||
bool hash(const RLN<Bn256> *ctx,
|
bool hash(const struct RLN_Bn256 *ctx,
|
||||||
const Buffer *inputs_buffer,
|
const struct Buffer *inputs_buffer,
|
||||||
const uintptr_t *input_len,
|
const uintptr_t *input_len,
|
||||||
Buffer *output_buffer);
|
struct Buffer *output_buffer);
|
||||||
|
|
||||||
bool key_gen(const RLN<Bn256> *ctx, Buffer *keypair_buffer);
|
bool key_gen(const struct RLN_Bn256 *ctx, struct Buffer *keypair_buffer);
|
||||||
|
|
||||||
} // extern "C"
|
|
||||||
|
|
Loading…
Reference in New Issue