Documentation ¶
Overview ¶
Package ec contains logic for handling elliptic curve keys
Index ¶
- Constants
- func Sign(priv *PrivateKey, msg []byte) []byte
- func Verify(pub *PublicKey, msg, sig []byte) bool
- type PrivateKey
- func (priv *PrivateKey) GetPublic() *PublicKey
- func (priv *PrivateKey) KeyType() string
- func (priv *PrivateKey) Marshal() []byte
- func (priv *PrivateKey) MarshalJSON() ([]byte, error)
- func (priv *PrivateKey) MarshalText() string
- func (priv *PrivateKey) String() string
- func (priv *PrivateKey) Unmarshal(data []byte) error
- func (priv *PrivateKey) UnmarshalJSON(b []byte) error
- func (priv *PrivateKey) UnmarshalText(data string) error
- type PublicKey
- func (pub *PublicKey) DeepCopy() *PublicKey
- func (pub *PublicKey) KeyType() string
- func (pub *PublicKey) Marshal() []byte
- func (pub *PublicKey) MarshalJSON() ([]byte, error)
- func (pub *PublicKey) MarshalText() string
- func (pub *PublicKey) String() string
- func (pub *PublicKey) Unmarshal(data []byte) error
- func (pub *PublicKey) UnmarshalJSON(b []byte) error
- func (pub *PublicKey) UnmarshalText(data string) error
Constants ¶
const ( // PublicKeySize is the size of a serialized PublicKey in bytes (32 bytes). PublicKeySize = ed25519.PublicKeySize // PrivateKeySize is the size of a serialized PrivateKey in bytes (64 bytes). PrivateKeySize = ed25519.PrivateKeySize )
Variables ¶
This section is empty.
Functions ¶
func Sign ¶
func Sign(priv *PrivateKey, msg []byte) []byte
Sign signs the message msg with the PrivateKey and returns the signature.
Types ¶
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey is a wrapper of containing both an ed25519 private key and its associated public key. Wrapper provides additional functionality on top of Go's library
func LoadPrivateKey ¶
func LoadPrivateKey(data string) (*PrivateKey, error)
LoadPrivateKey loads a base64 string into a PrivateKey
func NewKeyPair ¶
func NewKeyPair(rand io.Reader) (*PrivateKey, error)
NewKeyPair creates an ed25519 keypair wrapped around a PrivateKey, using the random source (for example, crypto/rand.Reader).
func (*PrivateKey) GetPublic ¶
func (priv *PrivateKey) GetPublic() *PublicKey
GetPublic returns a copy of PrivateKey's PublicKey
func (*PrivateKey) KeyType ¶
func (priv *PrivateKey) KeyType() string
KeyType returns the PrivateKey type as a string. For this case, it will be the constant "edd25519 in this case the constant variable whose value is "ed25519".
func (*PrivateKey) Marshal ¶
func (priv *PrivateKey) Marshal() []byte
Marshal serializes a PrivateKey into a byte slice
func (*PrivateKey) MarshalJSON ¶
func (priv *PrivateKey) MarshalJSON() ([]byte, error)
MarshalJSON marshals the PrivateKey into valid JSON. This function adheres to the json.Marshaler interface.
func (*PrivateKey) MarshalText ¶
func (priv *PrivateKey) MarshalText() string
MarshalText returns a base64 encoded string of the PrivateKey. Adheres to the TextMarshaler interface defined in https://golang.org/pkg/encoding/
func (*PrivateKey) String ¶
func (priv *PrivateKey) String() string
Stringer function for PrivateKey
func (*PrivateKey) Unmarshal ¶
func (priv *PrivateKey) Unmarshal(data []byte) error
Unmarshal deserializes a byte slice into the PrivateKey
func (*PrivateKey) UnmarshalJSON ¶
func (priv *PrivateKey) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshalls the JSON into the PrivateKey. This function adheres to the json.Unmarshaler interface.
func (*PrivateKey) UnmarshalText ¶
func (priv *PrivateKey) UnmarshalText(data string) error
UnmarshalText deserializes a base64-encoded string into the PrivateKey. Adheres to the TextMarshaler interface defined in https://golang.org/pkg/encoding/
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey is a wrapper of an ed25519 public key. Wrapper provides additional functionality on top of Go's library.
func LoadPublicKey ¶
LoadPublicKey loads a base64 string into a PublicKey
func (*PublicKey) KeyType ¶
KeyType returns the PublicKey type as a string. For this case, it will be the constant "edd25519 in this case the constant variable whose value is "ed25519".
func (*PublicKey) MarshalJSON ¶
MarshalJSON marshals the PublicKey into valid JSON. This function adheres to the json.Marshaler interface.
func (*PublicKey) MarshalText ¶
MarshalText returns a base64 encoded string of the PublicKey. Adheres to the TextMarshaler interface defined in https://golang.org/pkg/encoding/
func (*PublicKey) UnmarshalJSON ¶
UnmarshalJSON unmarshalls the JSON into the PublicKey. This function adheres to the json.Unmarshaler interface.
func (*PublicKey) UnmarshalText ¶
UnmarshalText deserializes a base64-encoded string into the PublicKey. Adheres to the TextMarshaler interface defined in https://golang.org/pkg/encoding/