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:
- 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
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 )
This section is empty.
Sign signs the message with the given key pair.
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 ¶
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.
KeyPair returns a new key pair with the public key precomputed.
func (PrivateKey) PrivateKey ¶
PrivateKey simply returns itself. Implements KeyPair.PrivateKey.
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.
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.
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 byte
PublicKey is a 32-byte Ed25519 public key.
func FromCryptoPublicKey ¶
FromCryptoPublicKey converts a Go public key to the one in this package.