Documentation ¶
Overview ¶
Package x25519 implements Elliptic Curve Diffie-Hellman (ECDH) function over Curve25519
Index ¶
Constants ¶
const ( // GroupElementLength is the length of a ECDH group element in bytes. GroupElementLength = 32 // PublicKeySize is the size of a serialized PublicKey in bytes. PublicKeySize = GroupElementLength // PrivateKeySize is the size of a serialized PrivateKey in bytes. PrivateKeySize = GroupElementLength )
Key sizes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PrivateKey ¶
type PrivateKey struct { PublicKey // contains filtered or unexported fields }
PrivateKey represents an X25519 private key.
func GenerateKey ¶
func GenerateKey(random io.Reader) (*PrivateKey, error)
GenerateKey generates an X25519 keypair using the random source random (for example, crypto/rand.Reader).
func (*PrivateKey) Bytes ¶
func (priv *PrivateKey) Bytes() []byte
Bytes returns the raw private key.
func (*PrivateKey) MarshalPEM ¶
func (priv *PrivateKey) MarshalPEM() []byte
MarshalPEM encodes a X25519 private key to PEM.
func (*PrivateKey) Public ¶
func (priv *PrivateKey) Public() *PublicKey
Public returns the public key corresponding to priv.
func (*PrivateKey) SetBytes ¶
func (priv *PrivateKey) SetBytes(b []byte)
SetBytes interprets b as the bytes of a big-endian private key.
func (*PrivateKey) Shared ¶
func (priv *PrivateKey) Shared(peer *PublicKey) []byte
Shared computes the shared key corresponding to priv and peer's public key.
func (*PrivateKey) UnmarshalPEM ¶
func (priv *PrivateKey) UnmarshalPEM(data []byte) error
UnmarshalPEM decodes an X25519 private key PEM block.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey represents an X25519 public key.
func (*PublicKey) MarshalPubPEM ¶
MarshalPubPEM encodes a X25519 private key to PEM.
func (*PublicKey) UnmarshalPubPEM ¶
UnmarshalPubPEM decodes an X25519 private key PEM block.