This commit is contained in:
decanus 2021-09-13 23:15:01 +02:00
parent e5d478e09f
commit 7fa929adb4
No known key found for this signature in database
GPG Key ID: 3730AAF5D6589867
1 changed files with 6 additions and 3 deletions

View File

@ -62,15 +62,18 @@ func (r *RLN) GenerateKey() (*KeyPair, error) {
return key, nil
}
func (r *RLN) Hash(input []byte) []byte {
// Hash hashes a given input using the underlying function.
func (r *RLN) Hash(input []byte) ([]byte, error) {
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, &in.len, out)
if !bool(C.hash(r.ptr, in, &in.len, out)) {
return nil, errors.New("failed to hash")
}
return C.GoBytes(unsafe.Pointer(out.ptr), C.int(out.len))
return C.GoBytes(unsafe.Pointer(out.ptr), C.int(out.len)), nil
}
func (r *RLN) CircuitFromParams(depth int, parameters []byte) bool {