From 2707ef159e0d988b8e4c0d9ed644a9e47deae3f4 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 5 Jun 2017 21:58:19 +0900 Subject: use struts of bn.h --- include/bls/bls.hpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'include/bls/bls.hpp') diff --git a/include/bls/bls.hpp b/include/bls/bls.hpp index 1ac58d9..3eda465 100644 --- a/include/bls/bls.hpp +++ b/include/bls/bls.hpp @@ -6,16 +6,13 @@ @license modified new BSD license http://opensource.org/licenses/BSD-3-Clause */ -#ifndef MBN_FP_UNIT_SIZE - #error "define MBN_FP_UNIT_SIZE 4(or 6)" -#endif +#include #include #include #include #include #ifdef _MSC_VER - #pragma comment(lib, "mcl.lib") #pragma comment(lib, "bls.lib") #endif @@ -62,7 +59,7 @@ struct Id; @param maxUnitSize [in] 4 or 6 (specify same value used in compiling for validation) @note init() is not thread safe */ -void init(int curve = CurveFp254BNb, int maxUnitSize = MBN_FP_UNIT_SIZE); +void init(int curve = CurveFp254BNb, int maxUnitSize = MCLBN_FP_UNIT_SIZE); size_t getOpUnitSize(); void getCurveOrder(std::string& str); void getFieldOrder(std::string& str); @@ -77,7 +74,7 @@ class Id; r = 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d sizeof(uint64_t) * keySize byte */ -const size_t keySize = MBN_FP_UNIT_SIZE; +const size_t keySize = MCLBN_FP_UNIT_SIZE; typedef std::vector SecretKeyVec; typedef std::vector PublicKeyVec; @@ -85,12 +82,12 @@ typedef std::vector SignatureVec; typedef std::vector IdVec; class Id { - uint64_t self_[MBN_FP_UNIT_SIZE]; + mclBnFr self_; friend class PublicKey; friend class SecretKey; template friend struct WrapArray; - impl::Id& getInner() { return *reinterpret_cast(self_); } - const impl::Id& getInner() const { return *reinterpret_cast(self_); } + impl::Id& getInner() { return *reinterpret_cast(this); } + const impl::Id& getInner() const { return *reinterpret_cast(this); } public: Id(unsigned int id = 0); bool operator==(const Id& rhs) const; @@ -113,10 +110,10 @@ public: s ; secret key */ class SecretKey { - uint64_t self_[MBN_FP_UNIT_SIZE]; + mclBnFr self_; template friend struct WrapArray; - impl::SecretKey& getInner() { return *reinterpret_cast(self_); } - const impl::SecretKey& getInner() const { return *reinterpret_cast(self_); } + impl::SecretKey& getInner() { return *reinterpret_cast(this); } + const impl::SecretKey& getInner() const { return *reinterpret_cast(this); } public: SecretKey() : self_() {} bool operator==(const SecretKey& rhs) const; @@ -178,12 +175,12 @@ public: sQ ; public key */ class PublicKey { - uint64_t self_[MBN_FP_UNIT_SIZE * 2 * 3]; + mclBnG2 self_; friend class SecretKey; friend class Signature; template friend struct WrapArray; - impl::PublicKey& getInner() { return *reinterpret_cast(self_); } - const impl::PublicKey& getInner() const { return *reinterpret_cast(self_); } + impl::PublicKey& getInner() { return *reinterpret_cast(this); } + const impl::PublicKey& getInner() const { return *reinterpret_cast(this); } public: PublicKey() : self_() {} bool operator==(const PublicKey& rhs) const; @@ -217,11 +214,11 @@ public: s H(m) ; signature */ class Signature { - uint64_t self_[MBN_FP_UNIT_SIZE * 3]; + mclBnG1 self_; friend class SecretKey; template friend struct WrapArray; - impl::Signature& getInner() { return *reinterpret_cast(self_); } - const impl::Signature& getInner() const { return *reinterpret_cast(self_); } + impl::Signature& getInner() { return *reinterpret_cast(this); } + const impl::Signature& getInner() const { return *reinterpret_cast(this); } public: Signature() : self_() {} bool operator==(const Signature& rhs) const; -- cgit v1.2.3