made new work

This commit is contained in:
decanus 2021-09-13 22:41:27 +02:00
parent 2e02e6d97b
commit b6e723c29b
No known key found for this signature in database
GPG Key ID: 3730AAF5D6589867
3 changed files with 18 additions and 4 deletions

View File

@ -17,7 +17,12 @@ func New(depth int, parameters []byte) *RLN {
r := &RLN{}
buf := toBuffer(parameters)
C.new_circuit_from_params(C.ulong(depth), &buf, &r.ptr)
size := int(unsafe.Sizeof(buf))
in := (*C.Buffer)(C.malloc(C.size_t(size)))
*in = buf
C.new_circuit_from_params(C.ulong(depth), in, &r.ptr)
return r
}

View File

@ -1,10 +1,19 @@
package rln
import (
"io/ioutil"
"testing"
)
func TestHash(t *testing.T) {
rln := New(0, []byte{})
rln.Hash([]byte{1, 2, 3})
func TestNew(t *testing.T) {
params, err := ioutil.ReadFile("./testdata/parameters.key")
if err != nil {
t.Fatal(err)
}
rln := New(32, params)
if rln.ptr == nil {
t.Fatal("pointer not initialized.")
}
}

BIN
rln/testdata/parameters.key vendored Normal file

Binary file not shown.