diff --git a/sample/ecdh.cpp b/sample/ecdh.cpp index 4fca3c0..14ab70d 100644 --- a/sample/ecdh.cpp +++ b/sample/ecdh.cpp @@ -3,43 +3,48 @@ */ #include #include -#include -#include -#include +#include -typedef mcl::FpT Fp; -typedef mcl::FpT Zn; +typedef mcl::FpT Fp; +typedef mcl::FpT Fr; typedef mcl::EcT Ec; +void put(const char *msg, const Ec& P) +{ + std::cout << msg << P.getStr(mcl::IoEcAffine | 16) << std::endl; +} + int main() { /* Ec is an elliptic curve over Fp - the cyclic group of

is isomorphic to Zn + the cyclic group of

is isomorphic to Fr */ Ec P; - mcl::initCurve(MCL_SECP192K1, &P); + mcl::initCurve(MCL_SECP256K1, &P); + put("P=", P); + /* Alice setups a private key a and public key aP */ - Zn a; + Fr a; Ec aP; a.setByCSPRNG(); Ec::mul(aP, P, a); // aP = a * P; - std::cout << "aP=" << aP << std::endl; + put("aP=", aP); /* Bob setups a private key b and public key bP */ - Zn b; + Fr b; Ec bP; b.setByCSPRNG(); Ec::mul(bP, P, b); // bP = b * P; - std::cout << "bP=" << bP << std::endl; + put("bP=", bP); Ec abP, baP;