Documentation
¶
Overview ¶
Package tkeysign provides a connection to the mldsa signer app running on the TKey. You're expected to pass an existing connection to it, so use it like this:
tk := tkeyclient.New() err := tk.Connect(port) err := tk.LoadApp(appBinary, secretPhrase) signer := tkeysign.New(tk)
Then use it like this to get the public key of the TKey:
pubkey, err := signer.GetPubkey()
And like this to sign a message:
signature, err := signer.Sign(message)
Index ¶
- Constants
- type Signer
- func (s Signer) Close() error
- func (s Signer) ComputeMu(pubkey, message []byte) []byte
- func (s Signer) GetAppNameVersion() (*tkeyclient.NameVersion, error)
- func (s Signer) GetFWDigest(len int) ([]byte, error)
- func (s Signer) GetPubkey() ([]byte, error)
- func (s Signer) SignExtMu(mu []byte) ([]byte, error)
Constants ¶
const MLDSAMuSize = 64
MLDSAMuSize is the size of the external mu input (FIPS 204 CRHBYTES) in bytes.
const MLDSAPubKeySize = 1312
MLDSAPubKeySize is the size of an ML-DSA-44 (Dilithium2) public key in bytes.
const MLDSASigSize = 2420
MLDSASigSize is the size of an ML-DSA-44 (Dilithium2) signature in bytes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
func New ¶
func New(tk *tkeyclient.TillitisKey) Signer
New allocates a struct for communicating with the mldsa signer app running on the TKey. You're expected to pass an existing connection to it, so use it like this:
tk := tkeyclient.New() err := tk.Connect(port) signer := tkeysign.New(tk)
func (Signer) ComputeMu ¶
computeMu derives the 64-byte message representative mu from the public key and message following FIPS 204 ML-DSA.Sign (Algorithm 2, external-mu variant):
tr = SHAKE256(pk, 64) mu = SHAKE256(tr || 0x00 || 0x00 || message, 64)
The two zero bytes encode format byte 0 (ML-DSA, not HashML-DSA) and an empty context string length.
func (Signer) GetAppNameVersion ¶
func (s Signer) GetAppNameVersion() (*tkeyclient.NameVersion, error)
GetAppNameVersion gets the name and version of the running app in the same style as the stick itself.
func (Signer) GetFWDigest ¶
GetFWDigest asks the signer app to hash len bytes of the firmware.
It returns the resulting SHA512 digest or an error.
func (Signer) SignExtMu ¶
SignExtMu signs a pre-computed 64-byte message representative (mu) and returns an ML-DSA-44 signature. The device app uses mldsa_signature_extmu internally, so the caller must provide exactly MLDSAMuSize (64) bytes. Use computeMu (in the CLI) to derive mu from the public key and message following FIPS 204: tr = SHAKE256(pk, 64); mu = SHAKE256(tr||0x00||0x00||msg, 64).