feat: tree config

This commit is contained in:
Richard Ramos 2023-08-04 15:30:23 -04:00 committed by richΛrd
parent 0a4e68d0b8
commit ea636e5b40
6 changed files with 12 additions and 6 deletions

Binary file not shown.

View File

@ -31,6 +31,7 @@ bool new_with_params(uintptr_t tree_height,
const struct Buffer *circom_buffer,
const struct Buffer *zkey_buffer,
const struct Buffer *vk_buffer,
const struct Buffer *tree_config,
struct RLN **ctx);
bool set_tree(struct RLN *ctx, uintptr_t tree_height);

View File

@ -41,28 +41,33 @@ func sliceToPtr(slice []byte) (*C.uchar, C.int) {
}
}
func NewWithParams(depth int, wasm []byte, zkey []byte, verifKey []byte) (*RLN, error) {
func NewWithParams(depth int, wasm []byte, zkey []byte, verifKey []byte, treeConfig []byte) (*RLN, error) {
wasmBuffer := toCBufferPtr(wasm)
zkeyBuffer := toCBufferPtr(zkey)
verifKeyBuffer := toCBufferPtr(verifKey)
treeConfigBuffer := toCBufferPtr(treeConfig)
r := &RLN{}
if !bool(C.new_with_params(C.uintptr_t(depth), wasmBuffer, zkeyBuffer, verifKeyBuffer, &r.ptr)) {
if !bool(C.new_with_params(C.uintptr_t(depth), wasmBuffer, zkeyBuffer, verifKeyBuffer, treeConfigBuffer, &r.ptr)) {
return nil, errors.New("failed to initialize")
}
return r, nil
}
func NewWithFolder(depth int, resourcesFolderPath string) (*RLN, error) {
func New(depth uint, config []byte) (*RLN, error) {
r := &RLN{}
pathBuffer := toCBufferPtr([]byte(resourcesFolderPath))
if !bool(C.new(C.uintptr_t(depth), pathBuffer, &r.ptr)) {
configBuffer := toCBufferPtr(config)
if !bool(C.new(C.uintptr_t(depth), configBuffer, &r.ptr)) {
return nil, errors.New("failed to initialize")
}
return r, nil
}
func (r *RLN) Flush() bool {
return bool(C.flush(r.ptr))
}
func (r *RLN) SetTree(treeHeight uint) bool {
return bool(C.set_tree(r.ptr, C.uintptr_t(treeHeight)))
}

@ -1 +1 @@
Subproject commit d1414a44c5e088bbf23523f032a001122e35f0c2
Subproject commit d015c4ab591cb7b260a92a077d3cd1d76609667f