mirror of https://github.com/waku-org/go-rln.git
fix
This commit is contained in:
parent
138375a857
commit
902507f32c
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue