|
|
@ -11,13 +11,13 @@ import "C" |
|
|
|
import "unsafe" |
|
|
|
|
|
|
|
type Verify struct { |
|
|
|
Message []byte |
|
|
|
PubKey []byte |
|
|
|
Sig []byte |
|
|
|
Valid bool |
|
|
|
Message []byte |
|
|
|
PubKey []byte |
|
|
|
Signature []byte |
|
|
|
Valid bool |
|
|
|
} |
|
|
|
|
|
|
|
func makeKeypair(privKey []byte) []byte { |
|
|
|
func MakePubKey(privKey []byte) []byte { |
|
|
|
pubKey := [32]byte{} |
|
|
|
C.ed25519_publickey( |
|
|
|
(*C.uchar)(unsafe.Pointer(&privKey[0])), |
|
|
@ -26,7 +26,7 @@ func makeKeypair(privKey []byte) []byte { |
|
|
|
return pubKey[:] |
|
|
|
} |
|
|
|
|
|
|
|
func signMessage(message []byte, privKey []byte, pubKey []byte) []byte { |
|
|
|
func SignMessage(message []byte, privKey []byte, pubKey []byte) []byte { |
|
|
|
sig := [64]byte{} |
|
|
|
C.ed25519_sign( |
|
|
|
(*C.uchar)(unsafe.Pointer(&message[0])), (C.size_t)(len(message)), |
|
|
@ -37,7 +37,7 @@ func signMessage(message []byte, privKey []byte, pubKey []byte) []byte { |
|
|
|
return sig[:] |
|
|
|
} |
|
|
|
|
|
|
|
func verifyBatch(verifys []Verify) bool { |
|
|
|
func VerifyBatch(verifys []*Verify) bool { |
|
|
|
|
|
|
|
count := len(verifys) |
|
|
|
|
|
|
@ -51,14 +51,14 @@ func verifyBatch(verifys []Verify) bool { |
|
|
|
msgs[i] = (*byte)(unsafe.Pointer(&v.Message[0])) |
|
|
|
lens[i] = (C.size_t)(len(v.Message)) |
|
|
|
pubs[i] = (*byte)(&v.PubKey[0]) |
|
|
|
sigs[i] = (*byte)(&v.Sig[0]) |
|
|
|
sigs[i] = (*byte)(&v.Signature[0]) |
|
|
|
} |
|
|
|
|
|
|
|
count_ := (C.size_t)(count) |
|
|
|
msgs_ := (**C.uchar)(unsafe.Pointer(&msgs[0])) |
|
|
|
lens_ := (*C.size_t)(unsafe.Pointer(&lens[0])) |
|
|
|
pubs_ := (**C.uchar)(unsafe.Pointer(&pubs[0])) |
|
|
|
sigs_ := (**C.uchar)(unsafe.Pointer(&pubs[0])) |
|
|
|
sigs_ := (**C.uchar)(unsafe.Pointer(&sigs[0])) |
|
|
|
|
|
|
|
res := C.ed25519_sign_open_batch(msgs_, lens_, pubs_, sigs_, count_, &valids[0]) |
|
|
|
|
|
|
|