Example #1
0
func BoxSeedKeyPair(pkOut []byte, skOut []byte, seed []byte) int {
	checkSize(pkOut, BoxPublicKeyBytes(), "public key")
	checkSize(skOut, BoxSecretKeyBytes(), "secret key")
	checkSize(seed, BoxSeedBytes(), "seed")

	return int(C.crypto_box_seed_keypair((*C.uchar)(&pkOut[0]), (*C.uchar)(&skOut[0]), (*C.uchar)(&seed[0])))
}
Example #2
0
func CryptoBoxSeedKeyPair(seed []byte) ([]byte, []byte, int) {
	support.CheckSize(seed, CryptoBoxSeedBytes(), "seed")
	sk := make([]byte, CryptoBoxSecretKeyBytes())
	pk := make([]byte, CryptoBoxPublicKeyBytes())
	exit := int(C.crypto_box_seed_keypair(
		(*C.uchar)(&pk[0]),
		(*C.uchar)(&sk[0]),
		(*C.uchar)(&seed[0])))

	return sk, pk, exit
}
Example #3
0
File: key.go Project: ZiRo-/srndv2
// make keypair from seed
func SeedBoxKey(seed []byte) *KeyPair {
	seed_len := C.crypto_box_seedbytes()
	if C.size_t(len(seed)) != seed_len {
		return nil
	}
	seedbuff := NewBuffer(seed)
	defer seedbuff.Free()
	pk_len := C.crypto_box_publickeybytes()
	sk_len := C.crypto_box_secretkeybytes()
	pkbuff := malloc(pk_len)
	skbuff := malloc(sk_len)
	res := C.crypto_box_seed_keypair(pkbuff.uchar(), skbuff.uchar(), seedbuff.uchar())
	if res != 0 {
		pkbuff.Free()
		skbuff.Free()
		return nil
	}
	return &KeyPair{pkbuff, skbuff}
}
Example #4
0
File: key.go Project: 4cdn/srndv2
// make keypair from seed
func SeedBoxKey(seed []byte) *KeyPair {
	seed_len := C.crypto_box_seedbytes()
	if C.size_t(len(seed)) != seed_len {
		log.Println("nacl.SeedBoxKey() invalid seed size", len(seed))
		return nil
	}
	seedbuff := NewBuffer(seed)
	defer seedbuff.Free()
	pk_len := C.crypto_box_publickeybytes()
	sk_len := C.crypto_box_secretkeybytes()
	pkbuff := malloc(pk_len)
	skbuff := malloc(sk_len)
	res := C.crypto_box_seed_keypair(pkbuff.uchar(), skbuff.uchar(), seedbuff.uchar())
	if res != 0 {
		pkbuff.Free()
		skbuff.Free()
		log.Println("nacl.SeedBoxKey cannot derive keys from seed:", res)
		return nil
	}
	return &KeyPair{pkbuff, skbuff}
}