From 6df4912fe348cde08007b85a3b522188002d8ab9 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Mon, 31 Jul 2023 14:01:45 -0400 Subject: [PATCH] chore: expose get_leaf --- rln/wrapper.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rln/wrapper.go b/rln/wrapper.go index a23af4f..1e338cf 100644 --- a/rln/wrapper.go +++ b/rln/wrapper.go @@ -222,3 +222,14 @@ func (r *RLN) GetRoot() ([]byte, error) { return C.GoBytes(unsafe.Pointer(out.ptr), C.int(out.len)), nil } + +func (r *RLN) GetLeaf(index uint) ([]byte, error) { + var output []byte + out := toBuffer(output) + + if !bool(C.get_leaf(r.ptr, C.uintptr_t(index), &out)) { + return nil, errors.New("could not get the leaf") + } + + return C.GoBytes(unsafe.Pointer(out.ptr), C.int(out.len)), nil +}