// CreateKeyPair needs no input, produces a public key and secret key as output func CreateKeyPair() (publicKey PublicKey, secretKey SecretKey, err error) { errorCode := C.crypto_sign_keypair((*C.uchar)(unsafe.Pointer(&publicKey[0])), (*C.uchar)(unsafe.Pointer(&secretKey[0]))) if errorCode != 0 { err = fmt.Errorf("Key Creation Failed!") return } return }
// EdDSAGenerateKeys generates an EdDSA private key. The public key // can be derived from the private key, so there is no issue. // Keys are represented by byte slices, and can be cast to and from them. func EdDSAGenerateKey() EdDSAPrivate { priv := make([]byte, EdDSAPrivateLength) publ := make([]byte, EdDSAPublicLength) rv := C.crypto_sign_keypair((*C.uchar)(&publ[0]), (*C.uchar)(&priv[0])) if rv != 0 { panic("crypto_sign_keypair returned non-zero") } return priv }
func CryptoSignKeyPair() ([]byte, []byte, int) { sk := make([]byte, CryptoSignSecretKeyBytes()) pk := make([]byte, CryptoSignPublicKeyBytes()) exit := int(C.crypto_sign_keypair( (*C.uchar)(&pk[0]), (*C.uchar)(&sk[0]))) return sk, pk, exit }
// generate a keypair func GenSignKeypair() *KeyPair { sk_len := C.crypto_sign_secretkeybytes() sk := malloc(sk_len) pk_len := C.crypto_sign_publickeybytes() pk := malloc(pk_len) res := C.crypto_sign_keypair(pk.uchar(), sk.uchar()) if res == 0 { return &KeyPair{pk, sk} } pk.Free() sk.Free() return nil }
// generate a keypair func GenSignKeypair() *KeyPair { sk_len := C.crypto_sign_secretkeybytes() sk := malloc(sk_len) pk_len := C.crypto_sign_publickeybytes() pk := malloc(pk_len) res := C.crypto_sign_keypair(pk.uchar(), sk.uchar()) if res == 0 { return &KeyPair{pk, sk} } log.Println("nacl.GenSignKeypair() failed to generate keypair") pk.Free() sk.Free() return nil }
func SignKeyPair(pkOut []byte, skOut []byte) int { support.CheckSize(pkOut, SignPublicKeyBytes(), "sign key pair public") support.CheckSize(skOut, SignSecretKeyBytes(), "sign key pair secret") return int(C.crypto_sign_keypair((*C.uchar)(&pkOut[0]), (*C.uchar)(&skOut[0]))) }