From a8b8c6ab4b8009bc87e054d1d4afefc2c87d9428 Mon Sep 17 00:00:00 2001 From: Alvaro Revuelta Date: Tue, 16 Jan 2024 14:49:31 +0100 Subject: [PATCH] Expose get_proof as GetMerkleProof (#2) --- rln/wrapper.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rln/wrapper.go b/rln/wrapper.go index c2d320c..99111c7 100644 --- a/rln/wrapper.go +++ b/rln/wrapper.go @@ -245,6 +245,17 @@ func (r *RLN) GetLeaf(index uint) ([]byte, error) { return C.GoBytes(unsafe.Pointer(out.ptr), C.int(out.len)), nil } +func (r *RLN) GetMerkleProof(index uint) ([]byte, error) { + var output []byte + out := toBuffer(output) + + if !bool(C.get_proof(r.ptr, C.uintptr_t(index), &out)) { + return nil, errors.New("could not get the proof") + } + + return C.GoBytes(unsafe.Pointer(out.ptr), C.int(out.len)), nil +} + func (r *RLN) LeavesSet() uint { return uint(C.leaves_set(r.ptr)) }