aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-03-15 05:07:20 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-03-15 05:07:20 +0800
commitd085930d574264ae30c1091a9948c21b3160feb8 (patch)
treece192c0cd0bcc7e3e9a8402a3147409392159277 /include
parenta148e716c06551b5ac143477c919548c9a682a03 (diff)
downloaddexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.tar
dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.tar.gz
dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.tar.bz2
dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.tar.lz
dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.tar.xz
dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.tar.zst
dexon-bls-d085930d574264ae30c1091a9948c21b3160feb8.zip
add UNIT option to select bn256 or bn384
Diffstat (limited to 'include')
-rw-r--r--include/bls.hpp19
-rw-r--r--include/bls_if.h13
2 files changed, 20 insertions, 12 deletions
diff --git a/include/bls.hpp b/include/bls.hpp
index 194f669..f0a3650 100644
--- a/include/bls.hpp
+++ b/include/bls.hpp
@@ -6,6 +6,9 @@
@license modified new BSD license
http://opensource.org/licenses/BSD-3-Clause
*/
+#ifndef BLS_MAX_OP_UNIT_SIZE
+ #error "define BLS_MAX_OP_UNIT_SIZE 4(or 6)"
+#endif
#include <vector>
#include <string>
#include <iosfwd>
@@ -46,8 +49,10 @@ struct Id;
/*
initialize this library
call this once before using the other method
+ @param curve [in] type of curve
+ @param maxUnitSize [in] 4 or 6 (specify same value used in compiling for validation)
*/
-void init(int curve = CurveFp254BNb);
+void init(int curve = CurveFp254BNb, int maxUnitSize = BLS_MAX_OP_UNIT_SIZE);
class SecretKey;
class PublicKey;
@@ -57,9 +62,9 @@ class Id;
/*
the value of secretKey and Id must be less than
r = 0x2523648240000001ba344d8000000007ff9f800000000010a10000000000000d
- sizeof(uint64_t) * keySize = 32-byte
+ sizeof(uint64_t) * keySize byte
*/
-const size_t keySize = 4;
+const size_t keySize = BLS_MAX_OP_UNIT_SIZE;
typedef std::vector<SecretKey> SecretKeyVec;
typedef std::vector<PublicKey> PublicKeyVec;
@@ -67,7 +72,7 @@ typedef std::vector<Sign> SignVec;
typedef std::vector<Id> IdVec;
class Id {
- uint64_t self_[6]; // 384-bit
+ uint64_t self_[BLS_MAX_OP_UNIT_SIZE];
friend class PublicKey;
friend class SecretKey;
template<class T, class G> friend struct WrapArray;
@@ -92,7 +97,7 @@ public:
s ; secret key
*/
class SecretKey {
- uint64_t self_[6]; // 384-bit
+ uint64_t self_[BLS_MAX_OP_UNIT_SIZE];
template<class T, class G> friend struct WrapArray;
impl::SecretKey& getInner() { return *reinterpret_cast<impl::SecretKey*>(self_); }
const impl::SecretKey& getInner() const { return *reinterpret_cast<const impl::SecretKey*>(self_); }
@@ -150,7 +155,7 @@ public:
sQ ; public key
*/
class PublicKey {
- uint64_t self_[6 * 2 * 3]; // 384-bit x 2 x 3
+ uint64_t self_[BLS_MAX_OP_UNIT_SIZE * 2 * 3];
friend class SecretKey;
friend class Sign;
template<class T, class G> friend struct WrapArray;
@@ -187,7 +192,7 @@ public:
s H(m) ; sign
*/
class Sign {
- uint64_t self_[6 * 3]; // 384-bit x 3
+ uint64_t self_[BLS_MAX_OP_UNIT_SIZE * 3];
friend class SecretKey;
template<class T, class G> friend struct WrapArray;
impl::Sign& getInner() { return *reinterpret_cast<impl::Sign*>(self_); }
diff --git a/include/bls_if.h b/include/bls_if.h
index d02d325..194d14f 100644
--- a/include/bls_if.h
+++ b/include/bls_if.h
@@ -6,6 +6,9 @@
@license modified new BSD license
http://opensource.org/licenses/BSD-3-Clause
*/
+#ifndef BLS_MAX_OP_UNIT_SIZE
+ #error "define BLS_MAX_OP_UNIT_SIZE 4(or 6)"
+#endif
#include <stdint.h> // for uint64_t, uint8_t
#include <stdlib.h> // for size_t
@@ -25,22 +28,22 @@ enum {
};
typedef struct {
- uint64_t buf[6];
+ uint64_t buf[BLS_MAX_OP_UNIT_SIZE];
} blsId;
typedef struct {
- uint64_t buf[6];
+ uint64_t buf[BLS_MAX_OP_UNIT_SIZE];
} blsSecretKey;
typedef struct {
- uint64_t buf[6 * 2 * 3];
+ uint64_t buf[BLS_MAX_OP_UNIT_SIZE * 2 * 3];
} blsPublicKey;
typedef struct {
- uint64_t buf[6 * 3];
+ uint64_t buf[BLS_MAX_OP_UNIT_SIZE * 3];
} blsSign;
-void blsInit(int curve);
+void blsInit(int curve, int maxUnitSize);
blsId *blsIdCreate(void);
void blsIdDestroy(blsId *id);