MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / compactSigCheck

Function compactSigCheck

crypto/secp256k1/secp256_test.go:50–61  ·  view source on GitHub ↗

tests for malleability highest bit of signature ECDSA s value must be 0, in the 33th byte.

(t *testing.T, sig []byte)

Source from the content-addressed store, hash-verified

48// tests for malleability
49// highest bit of signature ECDSA s value must be 0, in the 33th byte.
50func compactSigCheck(t *testing.T, sig []byte) {
51 var b = int(sig[32])
52 if b < 0 {
53 t.Errorf("highest bit is negative: %d", b)
54 }
55 if ((b >> 7) == 1) != ((b & 0x80) == 0x80) {
56 t.Errorf("highest bit: %d bit >> 7: %d", b, b>>7)
57 }
58 if (b & 0x80) == 0x80 {
59 t.Errorf("highest bit: %d bit & 0x80: %d", b, b&0x80)
60 }
61}
62
63func TestSignatureValidity(t *testing.T) {
64 pubkey, seckey := generateKeyPair()

Callers 2

TestSignatureValidityFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected