Documentation ¶
Index ¶
- Constants
- Variables
- func Curve25519PrivateKeyFromEd25519(privKey crypto.PrivKey) (crypto.PrivKey, error)
- func Curve25519PublicKeyFromEd25519(pubKey crypto.PubKey) (crypto.PubKey, error)
- func Decrypt(privKey crypto.PrivKey, ciphertext []byte) ([]byte, error)
- func Encrypt(pubKey crypto.PubKey, plaintext []byte) ([]byte, error)
- func GenerateCurve25519Key(src io.Reader) (crypto.PrivKey, crypto.PubKey, error)
- func UnmarshalCurve25519PrivateKey(data []byte) (crypto.PrivKey, error)
- func UnmarshalCurve25519PublicKey(data []byte) (crypto.PubKey, error)
- type Curve25519PrivateKey
- func (k *Curve25519PrivateKey) Decrypt(cipherText []byte) ([]byte, error)
- func (k *Curve25519PrivateKey) Equals(o crypto.Key) bool
- func (k *Curve25519PrivateKey) GetPublic() crypto.PubKey
- func (k *Curve25519PrivateKey) Raw() ([]byte, error)
- func (k *Curve25519PrivateKey) Sign(msg []byte) ([]byte, error)
- func (k *Curve25519PrivateKey) Type() pb.KeyType
- type Curve25519PublicKey
- func (k *Curve25519PublicKey) Encrypt(plaintext []byte) ([]byte, error)
- func (k *Curve25519PublicKey) Equals(o crypto.Key) bool
- func (k *Curve25519PublicKey) Raw() ([]byte, error)
- func (k *Curve25519PublicKey) Type() pb.KeyType
- func (k *Curve25519PublicKey) Verify(data []byte, sig []byte) (bool, error)
Constants ¶
const ( Libp2pKeyTypeCurve25519 = pb.KeyType(4) Curve25519PrivateKeySize = 32 Curve25519PublicKeySize = 32 )
const ( // Length of nacl nonce NonceBytes = 24 // Length of nacl ephemeral public key EphemeralPublicKeyBytes = 32 )
Variables ¶
var ErrBoxDecryption = errors.New("failed to decrypt curve25519")
ErrBoxDecryption Nacl box decryption failed
var ErrSigNoop = errors.New("curve25519 keys cannot do signing or verification")
Functions ¶
func GenerateCurve25519Key ¶
GenerateCurve25519Key generates a new Curve25519 private and public key pair.
func UnmarshalCurve25519PrivateKey ¶
UnmarshalCurve25519PrivateKey returns a private key from input bytes.
Types ¶
type Curve25519PrivateKey ¶
type Curve25519PrivateKey struct {
// contains filtered or unexported fields
}
Curve25519PrivateKey is a Curve25519 private key.
func (*Curve25519PrivateKey) Decrypt ¶
func (k *Curve25519PrivateKey) Decrypt(cipherText []byte) ([]byte, error)
Decrypt attempts to decrypt ciphertext using the private key.
func (*Curve25519PrivateKey) Equals ¶
func (k *Curve25519PrivateKey) Equals(o crypto.Key) bool
Equals compares two Curve25519 private keys.
func (*Curve25519PrivateKey) GetPublic ¶
func (k *Curve25519PrivateKey) GetPublic() crypto.PubKey
GetPublic returns an Curve25519 public key from a private key.
func (*Curve25519PrivateKey) Raw ¶
func (k *Curve25519PrivateKey) Raw() ([]byte, error)
Raw private key bytes.
func (*Curve25519PrivateKey) Sign ¶
func (k *Curve25519PrivateKey) Sign(msg []byte) ([]byte, error)
Sign returns a signature from an input message. This is a noop.
func (*Curve25519PrivateKey) Type ¶
func (k *Curve25519PrivateKey) Type() pb.KeyType
Type of the private key (Curve25519).
type Curve25519PublicKey ¶
type Curve25519PublicKey struct {
// contains filtered or unexported fields
}
Curve25519PublicKey is a Curve25519 public key.
func (*Curve25519PublicKey) Encrypt ¶
func (k *Curve25519PublicKey) Encrypt(plaintext []byte) ([]byte, error)
Encrypt encrypts the plaintext using the public key and returns the ciphertext.
func (*Curve25519PublicKey) Equals ¶
func (k *Curve25519PublicKey) Equals(o crypto.Key) bool
Equals compares two Curve25519 public keys.
func (*Curve25519PublicKey) Raw ¶
func (k *Curve25519PublicKey) Raw() ([]byte, error)
Raw public key bytes.
func (*Curve25519PublicKey) Type ¶
func (k *Curve25519PublicKey) Type() pb.KeyType
Type of the public key (Curve25519).