package ed25519
import (
_
)
func ( *PrivateKey) error {
return fips140.PCT("Ed25519 sign and verify PCT", func() error {
return pairwiseTest()
})
}
func ( *PrivateKey) error {
:= []byte("PCT")
:= Sign(, )
, := NewPublicKey(.PublicKey())
if != nil {
return
}
return Verify(, , )
}
func ( *PrivateKey, []byte) []byte {
:= make([]byte, signatureSize)
return signWithDom(, , , domPrefixPure, "")
}
func ( *PublicKey, , []byte) error {
return verifyWithDom(, , , domPrefixPure, "")
}
var fipsSelfTest = sync.OnceFunc(func() {
fips140.CAST("Ed25519 sign and verify", func() error {
:= [32]byte{
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
}
:= []byte("CAST")
:= []byte{
0xbd, 0xe7, 0xa5, 0xf3, 0x40, 0x73, 0xb9, 0x5a,
0x2e, 0x6d, 0x63, 0x20, 0x0a, 0xd5, 0x92, 0x9b,
0xa2, 0x3d, 0x00, 0x44, 0xb4, 0xc5, 0xfd, 0x62,
0x1d, 0x5e, 0x33, 0x2f, 0xe4, 0x61, 0x42, 0x31,
0x5b, 0x10, 0x53, 0x13, 0x4d, 0xcb, 0xd1, 0x1b,
0x2a, 0xf6, 0xcd, 0x0e, 0xdb, 0x9a, 0xd3, 0x1e,
0x35, 0xdb, 0x0b, 0xcf, 0x58, 0x90, 0x4f, 0xd7,
0x69, 0x38, 0xed, 0x30, 0x51, 0x0f, 0xaa, 0x03,
}
:= &PrivateKey{seed: }
precomputePrivateKey()
, := NewPublicKey(.PublicKey())
if != nil {
return
}
:= signWithoutSelfTest(, )
if !bytes.Equal(, ) {
return errors.New("unexpected result")
}
return verifyWithoutSelfTest(, , )
})
})