Documentation ¶
Index ¶
- Variables
- func NewKeypair() (*PublicKey, *PrivateKey)
- type Curve
- type EcSignature
- type EdSignature
- type Point
- func (p *Point) Add(q *Point) *Point
- func (p *Point) Bytes() []byte
- func (p *Point) Double() *Point
- func (p *Point) Equals(q *Point) bool
- func (p *Point) IsInf() bool
- func (p *Point) IsOnCurve() bool
- func (p *Point) Mult(k *math.Int) *Point
- func (p *Point) Neg() *Point
- func (p *Point) String() string
- func (p *Point) X() *math.Int
- func (p *Point) Y() *math.Int
- type PrivateKey
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
var ( ErrSigInvalidPrvKey = errors.New("private key not suitable for EdDSA") ErrSigNotEdDSA = errors.New("not a EdDSA signature") ErrSigNotEcDSA = errors.New("not a EcDSA signature") ErrSigInvalidEcDSA = errors.New("invalid EcDSA signature") ErrSigHashSizeMismatch = errors.New("hash size mismatch") ErrSigInvalid = errors.New("invalid signature") )
Error codes for signing / verifying
Functions ¶
func NewKeypair ¶
func NewKeypair() (*PublicKey, *PrivateKey)
NewKeypair creates a new Ed25519 key pair.
Types ¶
type Curve ¶
type Curve struct { // P is the generator of the underlying field "F_p" // = 2^255 - 19 P *math.Int // N is the order of G N *math.Int // curve D = 121665/121666 D *math.Int // Gx is the x-coord of the base point Gx *math.Int // Gy is the y-coord of the base point Gy *math.Int // Ox is the x-coord of the identity point (Infinity) Ox *math.Int // Oy is the y-coord of the identity point (Infinity) Oy *math.Int // contains filtered or unexported fields }
Curve is the Ed25519 elliptic curve (twisted Edwards curve):
a x^2 + y^2 = 1 + d x^2 y^2, d = -121665/121666, a = -1
type EcSignature ¶
EcSignature is a ECDSA signature
func NewEcSignatureFromBytes ¶
func NewEcSignatureFromBytes(data []byte) (*EcSignature, error)
NewEcSignatureFromBytes creates a ECDSA signature from its binary representation.
func (*EcSignature) Bytes ¶
func (s *EcSignature) Bytes() []byte
Bytes returns the binary representation of a ECDSA signature.
type EdSignature ¶
EdSignature is a EdDSA signature
func NewEdSignatureFromBytes ¶
func NewEdSignatureFromBytes(data []byte) (*EdSignature, error)
NewEdSignatureFromBytes builds a EdDSA signature from its binary representation.
func (*EdSignature) Bytes ¶
func (s *EdSignature) Bytes() []byte
Bytes returns the binary representation of an EdDSA signature
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point (x,y) on the curve
func NewPointFromBytes ¶
NewPointFromBytes reconstructs a Point from binary representation.
func (*Point) Mult ¶
Mult multiplies a Point on the curve with a scalar value k using a Montgomery multiplication approach
type PrivateKey ¶
PrivateKey is a Ed25519 private key.
func NewPrivateKeyFromD ¶
func NewPrivateKeyFromD(d *math.Int) *PrivateKey
NewPrivateKeyFromD returns a private key for a given factor. The 'nonce' value (generated from the seed in the "standard case") is now generated by hashing the key material itself.
func NewPrivateKeyFromSeed ¶
func NewPrivateKeyFromSeed(seed []byte) *PrivateKey
NewPrivateKeyFromSeed returns a private key for a given seed. If the seed has no matching length, no key is returned
func (*PrivateKey) Bytes ¶
func (prv *PrivateKey) Bytes() []byte
Bytes returns the binary representation of a private key.
func (*PrivateKey) EcSign ¶
func (prv *PrivateKey) EcSign(msg []byte) (*EcSignature, error)
EcSign creates an EcDSA signature for a message.
func (*PrivateKey) EdSign ¶
func (prv *PrivateKey) EdSign(msg []byte) (*EdSignature, error)
EdSign creates an EdDSA signature (R,S) for a message
func (*PrivateKey) Mult ¶
func (prv *PrivateKey) Mult(n *math.Int) *PrivateKey
Mult returns a new private key with d' = n*d mod N
func (*PrivateKey) Public ¶
func (prv *PrivateKey) Public() *PublicKey
Public returns the public key for a private key.
type PublicKey ¶
type PublicKey struct {
Q *Point
}
PublicKey is a point on the Ed25519 curve.
func NewPublicKeyFromBytes ¶
NewPublicKeyFromBytes creates a new public key from a binary representation.
func (*PublicKey) EcVerify ¶
func (pub *PublicKey) EcVerify(msg []byte, sig *EcSignature) (bool, error)
EcVerify checks a EcDSA signature of a message.