This commit is contained in:
decanus 2021-09-14 13:21:02 +02:00
parent 138375a857
commit 902507f32c
No known key found for this signature in database
GPG Key ID: 3730AAF5D6589867
2 changed files with 27 additions and 3 deletions

View File

@ -113,8 +113,11 @@ func (r *RLN) Verify(proof []byte) bool {
}
func (r *RLN) UpdateNextMember(input []byte) error {
buf := toBuffer(input)
if !bool(C.update_next_member(r.ptr, &buf)) {
size := int(unsafe.Sizeof(C.Buffer{}))
in := (*C.Buffer)(C.malloc(C.size_t(size)))
*in = toBuffer(input)
if !bool(C.update_next_member(r.ptr, in)) {
return errors.New("failed to update next member")
}

View File

@ -61,11 +61,32 @@ func TestRLN_Verify(t *testing.T) {
t.Fatal(err)
}
_, err = r.GenerateKey()
index := 5
auth, err := r.GenerateKey()
if err != nil {
t.Fatal(err)
}
for i := 0; i < 10; i++ {
if i == index {
err := r.UpdateNextMember(auth.Commitment[:])
if err != nil {
t.Fatalf("failed to add member: %s", err)
}
} else {
key, err := r.GenerateKey()
if err != nil {
t.Fatal(err)
}
err = r.UpdateNextMember(key.Commitment[:])
if err != nil {
t.Fatalf("failed to add member: %s", err)
}
}
}
// @TODO create inputs
}