func BoxKeypair() (pk PublicKey, sk SecretKey) { pk = make([]byte, C.crypto_box_PUBLICKEYBYTES) sk = make([]byte, C.crypto_box_SECRETKEYBYTES) C.crypto_box_keypair(array(pk), array(sk)) return }
func CryptoBoxKeyPair() ([]byte, []byte, int) { sk := make([]byte, CryptoBoxSecretKeyBytes()) pk := make([]byte, CryptoBoxPublicKeyBytes()) exit := int(C.crypto_box_keypair( (*C.uchar)(&pk[0]), (*C.uchar)(&sk[0]))) return sk, pk, exit }
func GenBoxKeypair() *KeyPair { sk_len := C.crypto_box_secretkeybytes() sk := malloc(sk_len) pk_len := C.crypto_box_publickeybytes() pk := malloc(pk_len) res := C.crypto_box_keypair(pk.uchar(), sk.uchar()) if res == 0 { return &KeyPair{pk, sk} } pk.Free() sk.Free() return nil }
func GenBoxKeypair() *KeyPair { sk_len := C.crypto_box_secretkeybytes() sk := malloc(sk_len) pk_len := C.crypto_box_publickeybytes() pk := malloc(pk_len) res := C.crypto_box_keypair(pk.uchar(), sk.uchar()) if res == 0 { return &KeyPair{pk, sk} } log.Println("nacl.GenBoxKeyPair() failed to generate keypair") pk.Free() sk.Free() return nil }
// BoxKeyPair generates a new public/secret key pair, returning them in the passed buffers. func BoxKeyPair(pkOut, skOut []byte) int { checkSize(pkOut, BoxPublicKeyBytes(), "public key") checkSize(skOut, BoxSecretKeyBytes(), "secret key") return int(C.crypto_box_keypair((*C.uchar)(&pkOut[0]), (*C.uchar)(&skOut[0]))) }
func crypto_box_keypair(pk []byte, sk []byte) int { result := C.crypto_box_keypair((*C.uchar)(&pk[0]), (*C.uchar)(&sk[0])) return int(result) }