Documentation ¶
Index ¶
- func AppendPrivateKey[Private any](out []byte, sch PrivateKeyScheme[Private], priv *Private) []byte
- func AppendPublicKey[Public any](out []byte, sch PublicKeyScheme[Public], pub *Public) []byte
- func TestScheme[Priv, Pub any](t *testing.T, scheme Scheme[Priv, Pub])
- type Dual
- func (s Dual[LPriv, LPub, RPriv, RPub]) DerivePublic(priv *DualKey[LPriv, RPriv]) DualKey[LPub, RPub]
- func (s Dual[LPriv, LPub, RPriv, RPub]) Generate(rng io.Reader) (DualKey[LPub, RPub], DualKey[LPriv, RPriv], error)
- func (s Dual[LPriv, LPub, RPriv, RPub]) MarshalPrivate(dst []byte, x *DualKey[LPriv, RPriv])
- func (s Dual[LPriv, LPub, RPriv, RPub]) MarshalPublic(dst []byte, x *DualKey[LPub, RPub])
- func (s Dual[LPriv, LPub, RPriv, RPub]) ParsePrivate(x []byte) (DualKey[LPriv, RPriv], error)
- func (s Dual[LPriv, LPub, RPriv, RPub]) ParsePublic(x []byte) (DualKey[LPub, RPub], error)
- func (s Dual[LPriv, LPub, RPriv, RPub]) PrivateKeySize() int
- func (s Dual[LPriv, LPub, RPriv, RPub]) PublicKeySize() int
- func (s Dual[LPriv, LPub, RPriv, RPub]) Sign(dst []byte, priv *DualKey[LPriv, RPriv], input []byte)
- func (s Dual[LPriv, LPub, RPriv, RPub]) SignatureSize() int
- func (s Dual[LPriv, LPub, RPriv, RPub]) Verify(pub *DualKey[LPub, RPub], input []byte, sig []byte) bool
- type DualKey
- type Input512
- type PrivateKeyScheme
- type PublicKeyScheme
- type Purpose
- func (s Purpose[Private, Public, XOF]) DerivePublic(priv *Private) Public
- func (s Purpose[Private, Public, XOF]) Generate(rng io.Reader) (Public, Private, error)
- func (s Purpose[Private, Public, XOF]) MarshalPrivate(dst []byte, priv *Private)
- func (s Purpose[Private, Public, XOF]) MarshalPublic(dst []byte, pub *Public)
- func (s Purpose[Private, Public, XOF]) ParsePrivate(data []byte) (Private, error)
- func (s Purpose[Private, Public, XOF]) ParsePublic(data []byte) (Public, error)
- func (s Purpose[Private, Public, XOF]) PrivateKeySize() int
- func (s Purpose[Private, Public, XOF]) PublicKeySize() int
- func (s Purpose[Private, Public, XOF]) Sign(dst []byte, priv *Private, msg []byte)
- func (s Purpose[Private, Public, XOF]) Sign512(dst []byte, priv *Private, input *Input512)
- func (s Purpose[Private, Public, XOF]) SignatureSize() int
- func (s Purpose[Private, Public, XOF]) Verify(pub *Public, msg, sig []byte) bool
- func (s Purpose[Private, Public, XOF]) Verify512(pub *Public, input *Input512, sig []byte) bool
- type Scheme
- type Scheme512
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendPrivateKey ¶
func AppendPrivateKey[Private any](out []byte, sch PrivateKeyScheme[Private], priv *Private) []byte
func AppendPublicKey ¶
func AppendPublicKey[Public any](out []byte, sch PublicKeyScheme[Public], pub *Public) []byte
AppendPublicKey appends the marshaled form of pub to out, using sch to marshal the public key.
Types ¶
type Dual ¶
Dual is a signing scheme composed of two signing schemes
func (Dual[LPriv, LPub, RPriv, RPub]) DerivePublic ¶
func (Dual[LPriv, LPub, RPriv, RPub]) MarshalPrivate ¶
func (Dual[LPriv, LPub, RPriv, RPub]) MarshalPublic ¶
func (Dual[LPriv, LPub, RPriv, RPub]) ParsePrivate ¶
func (Dual[LPriv, LPub, RPriv, RPub]) ParsePublic ¶
func (Dual[LPriv, LPub, RPriv, RPub]) PrivateKeySize ¶
func (Dual[LPriv, LPub, RPriv, RPub]) PublicKeySize ¶
func (Dual[LPriv, LPub, RPriv, RPub]) SignatureSize ¶
type Input512 ¶
type Input512 = [64]byte
Input512 is the input to a signature in Scheme512. Input512 must be high entropy.
type PrivateKeyScheme ¶
type PublicKeyScheme ¶
type PublicKeyScheme[Public any] interface { // MarshalPublic marshals a public key to binary data // MarshalPublic panics if dst is not >= PublicKeySize() MarshalPublic(dst []byte, pub *Public) // ParsePublic attempts to parse a public key from bytes ParsePublic([]byte) (Public, error) // PublicKeySize returns the size of a public key PublicKeySize() int }
type Purpose ¶
type Purpose[Private, Public, XOF any] struct { Scheme Scheme512[Private, Public] Purpose string XOF xof.Scheme[XOF] }
Purpose allows keys to sign with multiple contexts
func NewPurpose ¶
func (Purpose[Private, Public, XOF]) DerivePublic ¶
func (s Purpose[Private, Public, XOF]) DerivePublic(priv *Private) Public
func (Purpose[Private, Public, XOF]) MarshalPrivate ¶
func (Purpose[Private, Public, XOF]) MarshalPublic ¶
func (Purpose[Private, Public, XOF]) ParsePrivate ¶
func (Purpose[Private, Public, XOF]) ParsePublic ¶
func (Purpose[Private, Public, XOF]) PrivateKeySize ¶
func (Purpose[Private, Public, XOF]) PublicKeySize ¶
func (Purpose[Private, Public, XOF]) SignatureSize ¶
type Scheme ¶
type Scheme[Private, Public any] interface { // Generate creates a public and private key Generate(rng io.Reader) (pub Public, priv Private, err error) // DerivePublic derives the Public key which corresponds to the private key DerivePublic(*Private) Public // Sign uses priv to produce a signature for msg and writes it to dst. // dst must be at least SignatureSize Sign(dst []byte, priv *Private, msg []byte) // Verify checks if sig is a valid signature produced by pub for msg Verify(pub *Public, msg []byte, sig []byte) bool // SignatureSize returns the size of a public key SignatureSize() int PublicKeyScheme[Public] PrivateKeyScheme[Private] }
Scheme is a scheme for digital signatures with variable length inputs
type Scheme512 ¶
type Scheme512[Private, Public any] interface { // Generate creates a public and private key Generate(rng io.Reader) (pub Public, priv Private, err error) // DerivePublic derives the Public key which corresponds to the private key DerivePublic(*Private) Public // Sign512 uses priv to produce a signature for msg and writes it to dst. // dst must be at least SignatureSize Sign512(dst []byte, priv *Private, input *Input512) // Verify512 checks if sig is a valid signature produced by pub for msg Verify512(pub *Public, input *Input512, sig []byte) bool // SignatureSize returns the size of a public key SignatureSize() int PublicKeyScheme[Public] PrivateKeyScheme[Private] }
Scheme512 is a scheme for digital signatures on 512 bits of input. Schemes implementing Scheme512 can have a maximum security of 256 bits against signature collisions. Forging signatures for a given input can have a maximum of 512 bits of security, but most implementations typically provide less.