Documentation
¶
Overview ¶
Package ed25519 implements the cryptographic primitives for the Edwards 25519 elliptic curve.
The signatures are created using the Schnorr algorithm which allows the aggregation of multiple signatures and public keys.
Related Papers:
Efficient Identification and Signatures for Smart Cards (1989) https://link.springer.com/chapter/10.1007/0-387-34805-0_22
Documentation Last Review: 05.10.2020
Index ¶
- Constants
- func NewPublicKeyFactory() crypto.PublicKeyFactory
- func NewSignatureFactory() crypto.SignatureFactory
- func NewSigner() crypto.Signer
- func RegisterPublicKeyFormat(format serde.Format, engine serde.FormatEngine)
- func RegisterSignatureFormat(format serde.Format, engine serde.FormatEngine)
- type PublicKey
- func (pk PublicKey) Equal(other interface{}) bool
- func (pk PublicKey) GetPoint() kyber.Point
- func (pk PublicKey) MarshalBinary() ([]byte, error)
- func (pk PublicKey) MarshalText() ([]byte, error)
- func (pk PublicKey) Serialize(ctx serde.Context) ([]byte, error)
- func (pk PublicKey) String() string
- func (pk PublicKey) Verify(msg []byte, sig crypto.Signature) error
- type Signature
- type Signer
Examples ¶
Constants ¶
const (
// Algorithm is the name of the curve used for the schnorr signature.
Algorithm = "CURVE-ED25519"
)
Variables ¶
This section is empty.
Functions ¶
func NewPublicKeyFactory ¶
func NewPublicKeyFactory() crypto.PublicKeyFactory
NewPublicKeyFactory returns a new instance of the factory.
func NewSignatureFactory ¶
func NewSignatureFactory() crypto.SignatureFactory
NewSignatureFactory returns a new instance of the factory.
func RegisterPublicKeyFormat ¶
func RegisterPublicKeyFormat(format serde.Format, engine serde.FormatEngine)
RegisterPublicKeyFormat register the engine for the provided format.
func RegisterSignatureFormat ¶
func RegisterSignatureFormat(format serde.Format, engine serde.FormatEngine)
RegisterSignatureFormat register the engine for the provided format.
Types ¶
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey is the public key adapter to the Kyber Ed25519 public key.
- implements crypto.PublicKey
func NewPublicKey ¶
NewPublicKey returns a new public key from the data.
func NewPublicKeyFromPoint ¶
func NewPublicKeyFromPoint(point kyber.Point) PublicKey
NewPublicKeyFromPoint creates a new public key from an existing point.
func (PublicKey) Equal ¶
Equal implements crypto.PublicKey. It returns true if the other public key is the same.
func (PublicKey) GetPoint ¶
func (pk PublicKey) GetPoint() kyber.Point
GetPoint returns the kyber.point.
func (PublicKey) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler. It produces a slice of bytes representing the public key.
func (PublicKey) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It returns a text representation of the public key.
func (PublicKey) Serialize ¶
Serialize implements serde.Message. It returns the serialized data of the public key.
type Signature ¶
type Signature struct {
// contains filtered or unexported fields
}
Signature is the adapter of the Kyber Schnorr signature.
- implements crypto.Signature
func NewSignature ¶
NewSignature returns a new signature from the data.
func (Signature) Equal ¶
Equal implements crypto.Signature. It returns true if both signatures are the same.
func (Signature) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler. It returns a slice of bytes representing the signature.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer implements a signer that is creating Schnorr signatures using the private key of the Ed25519 elliptic curve.
- implements crypto.Signer
func (Signer) GetPrivateKey ¶
func (s Signer) GetPrivateKey() kyber.Scalar
GetPrivateKey returns the signer's private key.
func (Signer) GetPublicKey ¶
GetPublicKey implements crypto.Signer. It returns the public key of the signer that can be used to verify signatures.
func (Signer) GetPublicKeyFactory ¶
func (s Signer) GetPublicKeyFactory() crypto.PublicKeyFactory
GetPublicKeyFactory implements crypto.Signer. It returns the public key factory for schnorr signatures.
func (Signer) GetSignatureFactory ¶
func (s Signer) GetSignatureFactory() crypto.SignatureFactory
GetSignatureFactory implements crypto.Signer. It returns the signature factory for schnorr signatures.
func (Signer) Sign ¶
Sign implements crypto.Signer. It signs the message in parameter and returns the signature, or an error if it cannot sign.
Example ¶
signerA := NewSigner() message := []byte("42") signature, err := signerA.Sign(message) if err != nil { panic("signer failed: " + err.Error()) } err = signerA.GetPublicKey().Verify(message, signature) if err != nil { panic("invalid signature: " + err.Error()) } fmt.Println("Success")
Output: Success