support old and new versions of libsecp256k1

This commit is contained in:
Doug Hoyte
2023-01-10 12:53:09 -05:00
parent c47d07e985
commit 5e62399844

View File

@ -76,7 +76,15 @@ bool verifySig(secp256k1_context* ctx, std::string_view sig, std::string_view ha
secp256k1_xonly_pubkey pubkeyParsed; secp256k1_xonly_pubkey pubkeyParsed;
if (!secp256k1_xonly_pubkey_parse(ctx, &pubkeyParsed, (const uint8_t*)pubkey.data())) throw herr("verify sig: bad pubkey"); if (!secp256k1_xonly_pubkey_parse(ctx, &pubkeyParsed, (const uint8_t*)pubkey.data())) throw herr("verify sig: bad pubkey");
return secp256k1_schnorrsig_verify(ctx, (const uint8_t*)sig.data(), (const uint8_t*)hash.data(), &pubkeyParsed); return secp256k1_schnorrsig_verify(
ctx,
(const uint8_t*)sig.data(),
(const uint8_t*)hash.data(),
#ifdef SECP256K1_SCHNORRSIG_EXTRAPARAMS_INIT // old versions of libsecp256k1 didn't take a msg size param, this define added just after
hash.size(),
#endif
&pubkeyParsed
);
} }
void verifyNostrEvent(secp256k1_context *secpCtx, const NostrIndex::Event *flat, const tao::json::value &origJson) { void verifyNostrEvent(secp256k1_context *secpCtx, const NostrIndex::Event *flat, const tao::json::value &origJson) {