From 6761619ba6f7cd79bb215a479cbc20f8fd428874 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 26 Aug 2019 15:25:55 +0900 Subject: [PATCH] use secp256k1 in sample/ecdh.cpp --- sample/ecdh.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) 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;