Implement pubkeys in API functions

This commit is contained in:
Neil Alexander 2020-02-16 23:09:24 +00:00
parent a101fc0556
commit c107f891d2
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
4 changed files with 49 additions and 11 deletions

View file

@ -194,6 +194,16 @@ type BoxSharedKey [BoxSharedKeyLen]byte
// BoxNonce is the nonce used in NaCl-like crypto "box" operations (curve25519+xsalsa20+poly1305), and must not be reused for different messages encrypted using the same BoxSharedKey.
type BoxNonce [BoxNonceLen]byte
// String returns a string representation of the "box" key.
func (k BoxPubKey) String() string {
return hex.EncodeToString(k[:])
}
// Network returns "pubkey" for "box" keys.
func (n BoxPubKey) Network() string {
return "pubkey"
}
// NewBoxKeys generates a new pair of public/private crypto box keys.
func NewBoxKeys() (*BoxPubKey, *BoxPrivKey) {
pubBytes, privBytes, err := box.GenerateKey(rand.Reader)