MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestSignatureValidity

Function TestSignatureValidity

crypto/secp256k1/secp256_test.go:63–84  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestSignatureValidity(t *testing.T) {
64 pubkey, seckey := generateKeyPair()
65 msg := csprngEntropy(32)
66 sig, err := Sign(msg, seckey)
67 if err != nil {
68 t.Errorf("signature error: %s", err)
69 }
70 compactSigCheck(t, sig)
71 if len(pubkey) != 65 {
72 t.Errorf("pubkey length mismatch: want: 65 have: %d", len(pubkey))
73 }
74 if len(seckey) != 32 {
75 t.Errorf("seckey length mismatch: want: 32 have: %d", len(seckey))
76 }
77 if len(sig) != 65 {
78 t.Errorf("sig length mismatch: want: 65 have: %d", len(sig))
79 }
80 recid := int(sig[64])
81 if recid > 4 || recid < 0 {
82 t.Errorf("sig recid mismatch: want: within 0 to 4 have: %d", int(sig[64]))
83 }
84}
85
86func TestInvalidRecoveryID(t *testing.T) {
87 _, seckey := generateKeyPair()

Callers

nothing calls this directly

Calls 5

csprngEntropyFunction · 0.85
SignFunction · 0.85
compactSigCheckFunction · 0.85
ErrorfMethod · 0.80
generateKeyPairFunction · 0.70

Tested by

no test coverage detected