add bn384.hpp

dev
MITSUNARI Shigeo 8 years ago
parent 4bb4df62bf
commit 50a0ed560f
  1. 39
      include/mcl/bn384.hpp
  2. 15
      test/bn384_test.cpp

@ -0,0 +1,39 @@
#pragma once
/**
@file
@brief preset class for 384-bit optimal ate pairing over BN curves
@author MITSUNARI Shigeo(@herumi)
@license modified new BSD license
http://opensource.org/licenses/BSD-3-Clause
*/
#include <mcl/bn.hpp>
namespace mcl { namespace bn384 {
namespace local {
struct FpTag;
struct FrTag;
}
typedef mcl::FpT<local::FpTag, 384> Fp;
typedef mcl::bn::BNT<Fp> BN;
typedef BN::Fp2 Fp2;
typedef BN::Fp6 Fp6;
typedef BN::Fp12 Fp12;
typedef BN::G1 G1;
typedef BN::G2 G2;
typedef BN::Fp12 GT;
/* the order of G1 is r */
typedef mcl::FpT<local::FrTag, 384> Fr;
static inline void bn384init(const mcl::bn::CurveParam& cp = mcl::bn::CurveFp382_2, fp::Mode mode = fp::FP_AUTO)
{
BN::init(cp, mode);
G1::setCompressedExpression();
G2::setCompressedExpression();
Fr::init(BN::param.r);
}
} } // mcl::bn384

@ -1,20 +1,13 @@
#include <cybozu/test.hpp>
#include <cybozu/benchmark.hpp>
#include <mcl/bn384.hpp>
#include <mcl/bn.hpp>
typedef mcl::FpT<mcl::FpTag, 384> Fp;
typedef mcl::FpT<mcl::ZnTag, 384> Fr;
typedef mcl::bn::BNT<Fp> BN;
typedef BN::Fp2 Fp2;
typedef BN::Fp6 Fp6;
typedef BN::Fp12 Fp12;
typedef BN::G1 G1;
typedef BN::G2 G2;
typedef BN::Fp12 GT;
using namespace mcl::bn384;
void testCurve(const mcl::bn::CurveParam& cp)
{
BN::init(cp);
bn384init(cp);
G1 P;
G2 Q;
BN::mapToG1(P, 1);
@ -39,4 +32,6 @@ CYBOZU_TEST_AUTO(pairing)
{
testCurve(mcl::bn::CurveFp382_1);
testCurve(mcl::bn::CurveFp382_2);
// support 256-bit pairing
testCurve(mcl::bn::CurveFp254BNb);
}

Loading…
Cancel
Save