File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -797,6 +797,37 @@ func FuzzConvertFixedSignature(f *testing.F) {
797797 })
798798}
799799
800+ // FuzzConvertFixedSchnorrSignature tests that conversion of fixed 64-byte
801+ // Schnorr signatures to and from the btcec format does not panic or mutate the
802+ // signatures.
803+ func FuzzConvertFixedSchnorrSignature (f * testing.F ) {
804+ f .Fuzz (func (t * testing.T , data []byte ) {
805+ var sig Sig
806+ if len (data ) > len (sig .bytes [:]) {
807+ return
808+ }
809+ copy (sig .bytes [:], data )
810+ sig .ForceSchnorr ()
811+
812+ btcecSig , err := sig .ToSignature ()
813+ if err != nil {
814+ return
815+ }
816+
817+ sig2 , err := NewSigFromSignature (btcecSig )
818+ require .NoError (t , err , "failed to parse signature" )
819+
820+ btcecSig2 , err := sig2 .ToSignature ()
821+ require .NoError (
822+ t , err , "failed to reconvert signature to btcec format" ,
823+ )
824+
825+ btcecBytes := btcecSig .Serialize ()
826+ btcecBytes2 := btcecSig2 .Serialize ()
827+ require .Equal (t , btcecBytes , btcecBytes2 , "signature mismatch" )
828+ })
829+ }
830+
800831// prefixWithFailCode adds a failure code prefix to data.
801832func prefixWithFailCode (data []byte , code FailCode ) []byte {
802833 var codeBytes [2 ]byte
You can’t perform that action at this time.
0 commit comments