CompressPubkey encodes a public key to 33-byte compressed format.
(x, y *big.Int)
| 150 | |
| 151 | // CompressPubkey encodes a public key to 33-byte compressed format. |
| 152 | func CompressPubkey(x, y *big.Int) []byte { |
| 153 | var ( |
| 154 | pubkey = S256().Marshal(x, y) |
| 155 | pubkeydata = (*C.uchar)(unsafe.Pointer(&pubkey[0])) |
| 156 | pubkeylen = C.size_t(len(pubkey)) |
| 157 | out = make([]byte, 33) |
| 158 | outdata = (*C.uchar)(unsafe.Pointer(&out[0])) |
| 159 | outlen = C.size_t(len(out)) |
| 160 | ) |
| 161 | if C.secp256k1_ext_reencode_pubkey(context, outdata, outlen, pubkeydata, pubkeylen) == 0 { |
| 162 | panic("libsecp256k1 error") |
| 163 | } |
| 164 | return out |
| 165 | } |
| 166 | |
| 167 | func checkSignature(sig []byte) error { |
| 168 | if len(sig) != 65 { |