예제 #1
0
파일: key.go 프로젝트: ZiRo-/srndv2
// make keypair from seed
func LoadSignKey(seed []byte) *KeyPair {
	seed_len := C.crypto_sign_seedbytes()
	if C.size_t(len(seed)) != seed_len {
		return nil
	}
	seedbuff := NewBuffer(seed)
	defer seedbuff.Free()
	pk_len := C.crypto_sign_publickeybytes()
	sk_len := C.crypto_sign_secretkeybytes()
	pkbuff := malloc(pk_len)
	skbuff := malloc(sk_len)
	res := C.crypto_sign_seed_keypair(pkbuff.uchar(), skbuff.uchar(), seedbuff.uchar())
	if res != 0 {
		pkbuff.Free()
		skbuff.Free()
		return nil
	}
	return &KeyPair{pkbuff, skbuff}
}
예제 #2
0
파일: key.go 프로젝트: 4cdn/srndv2
// make keypair from seed
func LoadSignKey(seed []byte) *KeyPair {
	seed_len := C.crypto_sign_seedbytes()
	if C.size_t(len(seed)) != seed_len {
		log.Println("nacl.SeedSignKey() invalid seed size", len(seed))
		return nil
	}
	seedbuff := NewBuffer(seed)
	defer seedbuff.Free()
	pk_len := C.crypto_sign_publickeybytes()
	sk_len := C.crypto_sign_secretkeybytes()
	pkbuff := malloc(pk_len)
	skbuff := malloc(sk_len)
	res := C.crypto_sign_seed_keypair(pkbuff.uchar(), skbuff.uchar(), seedbuff.uchar())
	if res != 0 {
		log.Println("nacl.SeedSignKey cannot derive keys from seed", res)
		pkbuff.Free()
		skbuff.Free()
		return nil
	}
	return &KeyPair{pkbuff, skbuff}
}
예제 #3
0
func SignSeedBytes() int {
	return int(C.crypto_sign_seedbytes())
}
예제 #4
0
파일: key.go 프로젝트: 4cdn/srndv2
func (self *KeyPair) Seed() []byte {
	seed_len := C.crypto_sign_seedbytes()
	return self.sk.Bytes()[:seed_len]
}
예제 #5
0
파일: key.go 프로젝트: 4cdn/srndv2
func CryptoSignSeedLen() int {
	return int(C.crypto_sign_seedbytes())
}