Documentation ¶
Overview ¶
Package ed25519 implements Tor/BitTorrent-like ed25519 keys.
See the following stack overflow post for details on why golang.org/x/crypto/ed25519 can't be used:
https://stackoverflow.com/questions/44810708/ed25519-public-result-is-different
Index ¶
- Constants
- func Sign(keyPair KeyPair, message []byte) []byte
- func Verify(p PublicKey, message []byte, sig []byte) bool
- type KeyPair
- type PrivateKey
- func (p PrivateKey) KeyPair() KeyPair
- func (p PrivateKey) PrivateKey() PrivateKey
- func (p PrivateKey) Public() crypto.PublicKey
- func (p PrivateKey) PublicKey() PublicKey
- func (p PrivateKey) Sign(rand io.Reader, message []byte, opts crypto.SignerOpts) ([]byte, error)
- func (p PrivateKey) Verify(message []byte, sig []byte) bool
- type PublicKey
Constants ¶
const ( // PublicKeySize is the size, in bytes, of public keys as used in this package. PublicKeySize = 32 // PrivateKeySize is the size, in bytes, of private keys as used in this package. PrivateKeySize = 64 // SignatureSize is the size, in bytes, of signatures generated and verified by this package. SignatureSize = 64 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type KeyPair ¶
type KeyPair interface { crypto.Signer PrivateKey() PrivateKey PublicKey() PublicKey Verify(message []byte, sig []byte) bool }
KeyPair is an interface for types with both keys. While PrivateKey does implement this, it generates the PublicKey on demand. For better performance, use the result of GenerateKey directly or call PrivateKey.KeyPair().
func FromCryptoPrivateKey ¶
func FromCryptoPrivateKey(key ed25519.PrivateKey) KeyPair
FromCryptoPrivateKey converts a Go private key to the one in this package.
type PrivateKey ¶
type PrivateKey []byte
PrivateKey is a 64-byte Ed25519 private key. Unlike golang.org/x/crypto/ed25519, this is just the digest and does not contain the public key within it. Instead call PublicKey() or better, call KeyPair() which stores the precomputed public key.
func (PrivateKey) KeyPair ¶
func (p PrivateKey) KeyPair() KeyPair
KeyPair returns a new key pair with the public key precomputed.
func (PrivateKey) PrivateKey ¶
func (p PrivateKey) PrivateKey() PrivateKey
PrivateKey simply returns itself. Implements KeyPair.PrivateKey.
func (PrivateKey) Public ¶
func (p PrivateKey) Public() crypto.PublicKey
Public simply delegates to PublicKey() to satisfy crypto.Signer. This method does a bit more work than the traditional Go ed25519's private key's Public() method so developers are encouraged to reuse the result or use KeyPair() which stores this value.
func (PrivateKey) PublicKey ¶
func (p PrivateKey) PublicKey() PublicKey
PublicKey generates a public key for this private key. This method does a bit more work than the traditional Go ed25519's private key's Public() method so developers are encouraged to reuse the result or use KeyPair() which stores this value. Implements KeyPair.PublicKey.
func (PrivateKey) Sign ¶
func (p PrivateKey) Sign(rand io.Reader, message []byte, opts crypto.SignerOpts) ([]byte, error)
Sign signs the given message with priv. Ed25519 performs two passes over messages to be signed and therefore cannot handle pre-hashed messages. Thus opts.HashFunc() must return zero to indicate the message hasn't been hashed. This can be achieved by passing crypto.Hash(0) as the value for opts.
type PublicKey ¶
type PublicKey []byte
PublicKey is a 32-byte Ed25519 public key.
func FromCryptoPublicKey ¶
FromCryptoPublicKey converts a Go public key to the one in this package.