Documentation

Overview

    Package ecdh provides ECDH (X25519) wrappers.

    Index

    Constants

    View Source
    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) Bytes

            func (k *PrivateKey) Bytes() []byte

              Bytes returns the raw private key.

              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

                  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

                        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) Bytes

                              func (k *PublicKey) Bytes() []byte

                                Bytes returns the raw public key.

                                func (*PublicKey) Equal

                                func (k *PublicKey) Equal(cmp *PublicKey) bool

                                  Equal returns true iff the public key is byte for byte identical.

                                  func (*PublicKey) FromBytes

                                  func (k *PublicKey) FromBytes(b []byte) error

                                    FromBytes deserializes the byte slice b into the PublicKey.

                                    func (*PublicKey) FromPEMFile

                                    func (k *PublicKey) FromPEMFile(f string) error

                                      FromPEMFile reads the PublicKey from a PEM file at path f.

                                      func (*PublicKey) FromString

                                      func (k *PublicKey) FromString(s string) error

                                        FromString deserializes the string s into the PublicKey.

                                        func (*PublicKey) MarshalBinary

                                        func (k *PublicKey) MarshalBinary() ([]byte, error)

                                          MarshalBinary is an implementation of a method on the BinaryMarshaler interface defined in https://golang.org/pkg/encoding/

                                          func (*PublicKey) MarshalText

                                          func (k *PublicKey) MarshalText() ([]byte, error)

                                            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) String

                                              func (k *PublicKey) String() string

                                                String returns the public key as a base64 encoded string.

                                                func (*PublicKey) ToPEMFile

                                                func (k *PublicKey) ToPEMFile(f string) error

                                                  ToPEMFile writes out the PublicKey to a PEM file at path f.

                                                  func (*PublicKey) UnmarshalBinary

                                                  func (k *PublicKey) UnmarshalBinary(data []byte) error

                                                    UnmarshalBinary is an implementation of a method on the BinaryUnmarshaler interface defined in https://golang.org/pkg/encoding/

                                                    func (*PublicKey) UnmarshalText

                                                    func (k *PublicKey) UnmarshalText(data []byte) error

                                                      UnmarshalText is an implementation of a method on the TextUnmarshaler interface defined in https://golang.org/pkg/encoding/

                                                      Source Files