Documentation
¶
Index ¶
- func GenerateKeyPair(cfg *params.Cfg, rng io.Reader) (*SigningKey, *VerifyingKey, error)
- type SigningKey
- func (sk *SigningKey) Bytes() ([]byte, error)
- func (sk SigningKey) EncodeExpanded() []byte
- func (sk *SigningKey) Public() *VerifyingKey
- func (sk *SigningKey) Sign(rng io.Reader, message []byte, opts crypto.SignerOpts, externalMu bool) ([]byte, error)
- func (sk *SigningKey) SignInternal(mu, rnd []byte) []byte
- type VerifyingKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateKeyPair ¶
func GenerateKeyPair(cfg *params.Cfg, rng io.Reader) (*SigningKey, *VerifyingKey, error)
GenerateKeyPair creates a new SigningKey and VerifyingKey pair using randomness from the provided io.Reader. The reader must be cryptographically secure. The keys are generated using a random seed of 32 bytes.
Types ¶
type SigningKey ¶
type SigningKey struct {
K [32]byte
// contains filtered or unexported fields
}
func FromSeed ¶
func FromSeed(cfg *params.Cfg, seed []byte) (*SigningKey, error)
FromSeed creates a SigningKey from a 32-byte seed using Algorithm 6 of FIPS 204 (ML-DSA.KeyGen_internal)
func SkDecode ¶
func SkDecode(cfg *params.Cfg, sk []byte) (*SigningKey, error)
Algorithm 25 We do not recommend using SkDecode. Users should prefer FromSeed instead. This implementation adds some extra validity checks beyond the FIPS-204 spec, however SkDecode should still only be run on inputs that come from trusted sources. This implementation is also much less efficient than the FIP-204, as it re-computes the full public key from the secret key material.
func (*SigningKey) Bytes ¶
func (sk *SigningKey) Bytes() ([]byte, error)
func (SigningKey) EncodeExpanded ¶
func (sk SigningKey) EncodeExpanded() []byte
We do not recommend actually ever using this. Store the seed instead.
func (*SigningKey) Public ¶
func (sk *SigningKey) Public() *VerifyingKey
func (*SigningKey) Sign ¶
func (sk *SigningKey) Sign(rng io.Reader, message []byte, opts crypto.SignerOpts, externalMu bool) ([]byte, error)
Sign takes a message and a context and returns a signature. Only pure ML-DSA is supported. Context must be less than 256 bytes long, or else this function will return an error.
func (*SigningKey) SignInternal ¶
func (sk *SigningKey) SignInternal(mu, rnd []byte) []byte
Algorithm 7
The message representative being signed is: Mprime
Additional randomness is passed as: rnd
We do not currently support the use fo an "external mu"
Returns a signature as a []byte
type VerifyingKey ¶
type VerifyingKey struct {
// contains filtered or unexported fields
}
func (*VerifyingKey) Bytes ¶
func (vk *VerifyingKey) Bytes() []byte
Serialize a public verifying key to bytes. Algorithm 22
func (*VerifyingKey) Verify ¶
Verify verifies a signature.
Only pure ML-DSA is supported. opts.HashFunc() must return 0.
opts may be nil, in which case empty context is used.
func (*VerifyingKey) VerifyInternal ¶
func (vk *VerifyingKey) VerifyInternal(mu, sigma []byte) bool
Algorithm 8
The message representitve for the signature is: Mprime
The signature being validated is: sigma
Returns true if the signature is valid. Returns false otherwise (even if an error occurs).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package field implements arithmetic in the field Z_q, where q = 8380417.
|
Package field implements arithmetic in the field Z_q, where q = 8380417. |
|
Package ring implements arithmetic in the degree-256 cyclotomic polynomial ring R_q where q = 8380417.
|
Package ring implements arithmetic in the degree-256 cyclotomic polynomial ring R_q where q = 8380417. |
|
Package util implements the generic underlying algorithms from [NIST FIPS 204].
|
Package util implements the generic underlying algorithms from [NIST FIPS 204]. |