fix: add treepath config

This commit is contained in:
Richard Ramos 2023-08-21 11:55:21 -04:00
parent 05ef8aca57
commit 70f1ff564b
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760

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