Documentation ¶
Overview ¶
Package ecdh provides ECDH (X25519) wrappers.
Index ¶
- Constants
- func Exp(dst, x, y *[GroupElementLength]byte)
- type PrivateKey
- func (k *PrivateKey) Bytes() []byte
- func (k *PrivateKey) Exp(sharedSecret *[GroupElementLength]byte, publicKey *PublicKey)
- func (k *PrivateKey) FromBytes(b []byte) error
- func (k *PrivateKey) MarshalBinary() ([]byte, error)
- func (k *PrivateKey) PublicKey() *PublicKey
- func (k *PrivateKey) Reset()
- func (k *PrivateKey) UnmarshalBinary(data []byte) error
- type PublicKey
- func (k *PublicKey) Blind(blindingFactor *[GroupElementLength]byte)
- func (k *PublicKey) Bytes() []byte
- func (k *PublicKey) Equal(cmp *PublicKey) bool
- func (k *PublicKey) FromBytes(b []byte) error
- func (k *PublicKey) FromPEMFile(f string) error
- func (k *PublicKey) FromString(s string) error
- func (k *PublicKey) MarshalBinary() ([]byte, error)
- func (k *PublicKey) MarshalText() ([]byte, error)
- func (k *PublicKey) Reset()
- func (k *PublicKey) String() string
- func (k *PublicKey) ToPEMFile(f string) error
- func (k *PublicKey) UnmarshalBinary(data []byte) error
- func (k *PublicKey) UnmarshalText(data []byte) error
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 )
Variables ¶
This section is empty.
Functions ¶
func Exp ¶
func Exp(dst, x, y *[GroupElementLength]byte)
Exp sets the group element dst to be the result of x^y, over the ECDH group.
Types ¶
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey is a ECDH private key.
func Load ¶
func Load(privFile, pubFile string, r io.Reader) (*PrivateKey, error)
Load loads a new PrivateKey from the PEM encoded file privFile, optionally creating and saving a PrivateKey instead if an entropy source is provided. If pubFile is specified and a key has been created, the corresponding PublicKey will be wrtten to pubFile in PEM format.
func NewKeypair ¶
func NewKeypair(r io.Reader) (*PrivateKey, error)
NewKeypair generates a new PrivateKey sampled from the provided entropy source.
func (*PrivateKey) Exp ¶
func (k *PrivateKey) Exp(sharedSecret *[GroupElementLength]byte, publicKey *PublicKey)
Exp calculates the shared secret with the provided public key.
func (*PrivateKey) FromBytes ¶
func (k *PrivateKey) FromBytes(b []byte) error
FromBytes deserializes the byte slice b into the PrivateKey.
func (*PrivateKey) MarshalBinary ¶ added in v0.0.7
func (k *PrivateKey) MarshalBinary() ([]byte, error)
MarshalBinary is an implementation of a method on the BinaryMarshaler interface defined in https://golang.org/pkg/encoding/
func (*PrivateKey) PublicKey ¶
func (k *PrivateKey) PublicKey() *PublicKey
PublicKey returns the PublicKey corresponding to the PrivateKey.
func (*PrivateKey) Reset ¶
func (k *PrivateKey) Reset()
Reset clears the PrivateKey structure such that no sensitive data is left in memory.
func (*PrivateKey) UnmarshalBinary ¶ added in v0.0.7
func (k *PrivateKey) UnmarshalBinary(data []byte) error
UnmarshalBinary is an implementation of a method on the BinaryUnmarshaler interface defined in https://golang.org/pkg/encoding/
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey is a ECDH public key.
func (*PublicKey) Blind ¶
func (k *PublicKey) Blind(blindingFactor *[GroupElementLength]byte)
Blind blinds the public key with the provided blinding factor.
func (*PublicKey) FromPEMFile ¶ added in v0.0.3
FromPEMFile reads the PublicKey from a PEM file at path f.
func (*PublicKey) FromString ¶
FromString deserializes the string s into the PublicKey.
func (*PublicKey) MarshalBinary ¶
MarshalBinary is an implementation of a method on the BinaryMarshaler interface defined in https://golang.org/pkg/encoding/
func (*PublicKey) MarshalText ¶
MarshalText is an implementation of a method on the TextMarshaler interface defined in https://golang.org/pkg/encoding/
func (*PublicKey) Reset ¶
func (k *PublicKey) Reset()
Reset clears the PublicKey structure such that no sensitive data is left in memory.
func (*PublicKey) UnmarshalBinary ¶
UnmarshalBinary is an implementation of a method on the BinaryUnmarshaler interface defined in https://golang.org/pkg/encoding/
func (*PublicKey) UnmarshalText ¶
UnmarshalText is an implementation of a method on the TextUnmarshaler interface defined in https://golang.org/pkg/encoding/