mirror of https://github.com/waku-org/go-rln.git
fix
This commit is contained in:
parent
e928e8a25a
commit
2e02e6d97b
14
rln/rln.go
14
rln/rln.go
|
@ -13,14 +13,22 @@ type RLN struct {
|
|||
ptr *C.RLN_Bn256
|
||||
}
|
||||
|
||||
func New(depth int, parameters []byte) *RLN {
|
||||
r := &RLN{}
|
||||
|
||||
buf := toBuffer(parameters)
|
||||
C.new_circuit_from_params(C.ulong(depth), &buf, &r.ptr)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *RLN) Hash(input []byte) []byte {
|
||||
size := int(unsafe.Sizeof(C.Buffer{}))
|
||||
|
||||
size = int(unsafe.Sizeof(C.Buffer{}))
|
||||
in := (*C.Buffer)(C.malloc(C.size_t(size)))
|
||||
*in = toBuffer(input)
|
||||
|
||||
out := (*C.Buffer)(C.malloc(C.size_t(size)))
|
||||
C.hash(r.ptr, in, size, out)
|
||||
C.hash(r.ptr, in, &in.len, out)
|
||||
|
||||
return C.GoBytes(unsafe.Pointer(out.ptr), C.int(out.len))
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package rln
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHash(t *testing.T) {
|
||||
rln := &RLN{}
|
||||
rln := New(0, []byte{})
|
||||
rln.Hash([]byte{1, 2, 3})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue