Esempio n. 1
0
func CryptoScalarmultBase(n []byte) ([]byte, int) {
	support.CheckSize(n, CryptoScalarmultScalarBytes(), "secret key")
	q := make([]byte, CryptoScalarmultBytes())
	var exit C.int

	exit = C.crypto_scalarmult_base(
		(*C.uchar)(&q[0]),
		(*C.uchar)(&n[0]))

	return q, int(exit)
}
Esempio n. 2
0
File: key.go Progetto: ZiRo-/srndv2
// get public key from secret key
func GetBoxPubkey(sk []byte) []byte {
	sk_len := C.crypto_box_seedbytes()
	if C.size_t(len(sk)) != sk_len {
		return nil
	}

	pk_len := C.crypto_box_publickeybytes()
	pkbuff := malloc(pk_len)
	defer pkbuff.Free()

	skbuff := NewBuffer(sk)
	defer skbuff.Free()

	// compute the public key
	C.crypto_scalarmult_base(pkbuff.uchar(), skbuff.uchar())

	return pkbuff.Bytes()
}
Esempio n. 3
0
func ScalarMultBase(pkOut []byte, skIn []byte) int {
	checkSize(pkOut, BoxPublicKeyBytes(), "public key")
	checkSize(skIn, BoxSecretKeyBytes(), "secret key")

	return int(C.crypto_scalarmult_base((*C.uchar)(&pkOut[0]), (*C.uchar)(&skIn[0])))
}
Esempio n. 4
0
func (priv ECDHPrivate) PublicKey() ECDHPublic {
	toret := make([]byte, ECDHKeyLength)
	C.crypto_scalarmult_base((*C.uchar)(&toret[0]),
		(*C.uchar)(&priv[0]))
	return toret
}