On Wed, Feb 6, 2019 at 4:42 AM Luca Di Mauro <[email protected]> wrote:
>
> that value is constructed following this standard
> https://tools.ietf.org/id/draft-jivsov-ecc-compact-00.xml#NIST-SP800-133 , but
> unfortunately I cannot assume any other assumptions.
This may work for you.
#include "cryptlib.h"
#include "ecp.h"
#include "eccrypto.h"
#include "hex.h"
#include "oids.h"
#include "osrng.h"
#include <string>
#include <iostream>
#include <iomanip>
int main()
{
using namespace CryptoPP;
ECDSA<ECP, SHA256>::PublicKey pubKey;
pubKey.AccessGroupParameters().Initialize(ASN1::secp256r1());
std::string compactPoint = "02" /* compressed */
"937120662418500f3ad7c892b1db7e7c"
"2d85ec48c74e99d64dcb7083082bb4f3";
StringSource ss (compactPoint, true, new CryptoPP::HexDecoder);
ECP::Point point;
pubKey.GetGroupParameters().GetCurve().DecodePoint (point, ss,
ss.MaxRetrievable());
std::cout << "Result after decompression X: " << std::hex <<
point.x << std::endl;
std::cout << "Result after decompression Y: " << std::hex <<
point.y << std::endl;
return 0;
}
And then:
cryptopp$ g++ test.cxx ./libcryptopp.a -o test.exe
cryptopp$ ./test.exe
Result after decompression X:
937120662418500f3ad7c892b1db7e7c2d85ec48c74e99d64dcb7083082bb4f3h
Result after decompression Y:
cfcaf74eae3ceec5993928f04970cfef343b9a6b22727fa81926bd21f256ec56h
Jeff
--
You received this message because you are subscribed to "Crypto++ Users". More
information about Crypto++ and this group is available at
http://www.cryptopp.com and
http://groups.google.com/forum/#!forum/cryptopp-users.
---
You received this message because you are subscribed to the Google Groups
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.