27 size_t rpos, rlen, spos, slen;
30 unsigned char tmpsig[64] = {0};
37 if (pos == inputlen || input[pos] != 0x30) {
43 if (pos == inputlen) {
46 lenbyte = input[pos++];
49 if (pos + lenbyte > inputlen) {
56 if (pos == inputlen || input[pos] != 0x02) {
62 if (pos == inputlen) {
65 lenbyte = input[pos++];
68 if (pos + lenbyte > inputlen) {
71 while (lenbyte > 0 && input[pos] == 0) {
75 if (lenbyte >=
sizeof(
size_t)) {
80 rlen = (rlen << 8) + input[pos];
87 if (rlen > inputlen - pos) {
94 if (pos == inputlen || input[pos] != 0x02) {
100 if (pos == inputlen) {
103 lenbyte = input[pos++];
104 if (lenbyte & 0x80) {
106 if (pos + lenbyte > inputlen) {
109 while (lenbyte > 0 && input[pos] == 0) {
113 if (lenbyte >=
sizeof(
size_t)) {
117 while (lenbyte > 0) {
118 slen = (slen << 8) + input[pos];
125 if (slen > inputlen - pos) {
132 while (rlen > 0 && input[rpos] == 0) {
140 memcpy(tmpsig + 32 - rlen, input + rpos, rlen);
144 while (slen > 0 && input[spos] == 0) {
152 memcpy(tmpsig + 64 - slen, input + spos, slen);
161 memset(tmpsig, 0, 64);
175 if (vchSig.size() == 0) {
188 if (vchSig.size() != 65)
190 int recid = (vchSig[0] - 27) & 3;
191 bool fComp = ((vchSig[0] - 27) & 4) != 0;
200 unsigned char pub[65];
203 Set(pub, pub + publen);
221 unsigned char pub[65];
224 Set(pub, pub + publen);
230 assert((nChild >> 31) == 0);
232 unsigned char out[64];
242 unsigned char pub[33];
245 pubkeyChild.
Set(pub, pub + publen);
252 code[5] = (
nChild >> 24) & 0xFF; code[6] = (
nChild >> 16) & 0xFF;
253 code[7] = (
nChild >> 8) & 0xFF; code[8] = (
nChild >> 0) & 0xFF;
262 nChild = (code[5] << 24) | (code[6] << 16) | (code[7] << 8) | code[8];
288 assert(secp256k1_context_verify == NULL);
290 assert(secp256k1_context_verify != NULL);
299 assert(secp256k1_context_verify != NULL);
301 secp256k1_context_verify = NULL;
SECP256K1_API int secp256k1_ecdsa_recoverable_signature_parse_compact(const secp256k1_context *ctx, secp256k1_ecdsa_recoverable_signature *sig, const unsigned char *input64, int recid) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
void Decode(const unsigned char code[74])
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
SECP256K1_API int secp256k1_ecdsa_signature_normalize(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sigout, const secp256k1_ecdsa_signature *sigin) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(3)
bool Derive(CPubKey &pubkeyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode &cc) const
Derive BIP32 child pubkey.
unsigned int size() const
Simple read-only vector-like interface to the pubkey data.
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid()) ...
SECP256K1_API int secp256k1_ec_pubkey_serialize(const secp256k1_context *ctx, unsigned char *output, size_t *outputlen, const secp256k1_pubkey *pubkey, unsigned int flags) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
Recover a public key from a compact signature.
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx)
#define SECP256K1_EC_UNCOMPRESSED
#define SECP256K1_EC_COMPRESSED
bool Decompress()
Turn this public key into an uncompressed public key.
const unsigned char * begin() const
void Encode(unsigned char code[74]) const
bool Derive(CExtPubKey &out, unsigned int nChild) const
void BIP32Hash(const ChainCode &chainCode, unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64])
static secp256k1_context * ctx
unsigned char vchFingerprint[4]
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_parse(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *input, size_t inputlen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
bool Verify(const uint256 &hash, const std::vector< unsigned char > &vchSig) const
const unsigned char * end() const
void Set(const T pbegin, const T pend)
Initialize a public key using begin/end iterators to byte data.
#define SECP256K1_CONTEXT_VERIFY
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_recover(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const secp256k1_ecdsa_recoverable_signature *sig, const unsigned char *msg32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
SECP256K1_API int secp256k1_ecdsa_signature_parse_compact(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *input64) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
void * memcpy(void *a, const void *b, size_t c)
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
static bool CheckLowS(const std::vector< unsigned char > &vchSig)
static int ecdsa_signature_parse_der_lax(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *input, size_t inputlen)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_verify(const secp256k1_context *ctx, const secp256k1_ecdsa_signature *sig, const unsigned char *msg32, const secp256k1_pubkey *pubkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)