Closed Loopite closed 2 years ago
Hi, Finally, I found something interesting :
QByteArray const pubKey { QByteArray::fromHex("044aeaf55040fa16de37303d13ca1dde85f4ca9baa36e2963a27a1c0c1165fe2b11511a626b232de4ed05b204bd9eccaf1b79f5752e14dd1e847aa2f4db6a52768") };
Integer r { "0xF01D6B9018AB421DD410404CB869072065522BF85734008F105CF385A023A80F" };
Integer s { "0xA3243A18521B20DC80A8798A1A36463FFE8279574127DA214D39E6B34134305B" };
/** Init the publicKey. */
ECDSA<ECP, SHA256>::PublicKey publicKeyMaker;
publicKeyMaker.AccessGroupParameters().Initialize(ASN1::secp256k1());
StringSource ss(pubKey.toHex(), true, new CryptoPP::HexDecoder);
ECP::Point point;
publicKeyMaker.GetGroupParameters().GetCurve().DecodePoint(point, ss, ss.MaxRetrievable());
/** Init verifier. */
ECDSA<ECP, SHA256>::Verifier verifier(publicKeyMaker);
/** Verify */
if (r >= publicKeyMaker.GetGroupParameters().GetSubgroupOrder())
std::cout << "R is too large" << std::endl;
else
std::cout << "R is OK" << std::endl;
if (s >= publicKeyMaker.GetGroupParameters().GetSubgroupOrder())
std::cout << "S is too large" << std::endl;
else
std::cout << "S is OK" << std::endl;
std::vector<uint8_t> ct = {0x31, 0x32, 0x33, 0x34, 0x30, 0x30};
size_t siglen { verifier.SignatureLength() };
std::vector<uint8_t> sig(siglen);
r.Encode(sig.data() + 0, siglen / 2);
s.Encode(sig.data() + (siglen / 2), siglen / 2);
//std::cout << "Verify: " << verifier.VerifyMessage(ct.constdata(), ct.size(), sig.data(), siglen) << std::endl;
logPrint("isValid = " + QString::number(verifier.VerifyMessage((const byte*) ct.data(), ct.size(), (byte*) sig.data(), sig.size())));
The program is still crashing, are you able to tell me why ? Thanks.
Please ask questions on the mailing list.
It's not a question @noloader ... It's a bug. Signatures don't work as well as expected. So the verification produces the same bug... I can't verify a signature from R and S or to generate a R and a S with high/low option. Do you understand ? It's very problematic.
Crypto++ Issue Report
Hello, please consider this configuration :
Hi, I've recently an error about signature validation.
I generate sig thought my function which is :
And my program crashs when I call the verify function :
I'm doing currently my tests in my main :
I have this output :
I watched the documentation here : https://www.cryptopp.com/wiki/Elliptic_Curve_Digital_Signature_Algorithm#Test_Program Moreover, I would like a low-s signature generation and verification. I don't know if the CRYPTO++ Secp256k1 implementation does it by default.
I hope you'll be able to help me. Best regards, Loopite