aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/bls_if.h20
-rw-r--r--src/bls_if.cpp4
-rw-r--r--test/bls_if_test.cpp22
3 files changed, 41 insertions, 5 deletions
diff --git a/include/bls_if.h b/include/bls_if.h
index 7872778..79885a0 100644
--- a/include/bls_if.h
+++ b/include/bls_if.h
@@ -14,15 +14,27 @@
extern "C" {
#endif
-typedef struct blsSecretKey blsSecretKey;
-typedef struct blsPublicKey blsPublicKey;
-typedef struct blsSign blsSign;
-typedef struct blsId blsId;
+typedef struct {
+ uint64_t buf[4];
+} blsId;
+
+typedef struct {
+ uint64_t buf[4];
+} blsSecretKey;
+
+typedef struct {
+ uint64_t buf[4 * 2 * 3];
+} blsPublicKey;
+
+typedef struct {
+ uint64_t buf[4 * 3];
+} blsSign;
void blsInit(void);
blsId *blsIdCreate(void);
void blsIdDestroy(blsId *id);
+void blsIdPut(const blsId *id);
void blsIdCopy(blsId *dst, const blsId *src);
// return 0 if success
diff --git a/src/bls_if.cpp b/src/bls_if.cpp
index 7576c93..c64e868 100644
--- a/src/bls_if.cpp
+++ b/src/bls_if.cpp
@@ -57,6 +57,10 @@ void blsIdDestroy(blsId *id)
{
delete (bls::Id*)id;
}
+void blsIdPut(const blsId *id)
+{
+ std::cout << *(const bls::Id*)id << std::endl;
+}
void blsIdCopy(blsId *dst, const blsId *src)
{
*((bls::Id*)dst) = *((const bls::Id*)src);
diff --git a/test/bls_if_test.cpp b/test/bls_if_test.cpp
index 6c6e549..c2dc0a9 100644
--- a/test/bls_if_test.cpp
+++ b/test/bls_if_test.cpp
@@ -7,7 +7,6 @@ CYBOZU_TEST_AUTO(bls_if)
blsSecretKey *sec;
blsPublicKey *pub;
blsSign *sign;
-// blsId *id;
const char *msg = "this is a pen";
const size_t msgSize = strlen(msg);
@@ -30,3 +29,24 @@ CYBOZU_TEST_AUTO(bls_if)
blsPublicKeyDestroy(pub);
blsSecretKeyDestroy(sec);
}
+
+CYBOZU_TEST_AUTO(bls_if_use_stack)
+{
+ blsSecretKey sec;
+ blsPublicKey pub;
+ blsSign sign;
+ const char *msg = "this is a pen";
+ const size_t msgSize = strlen(msg);
+
+ blsInit();
+ blsSecretKeyInit(&sec);
+ blsSecretKeyPut(&sec);
+
+ blsSecretKeyGetPublicKey(&sec, &pub);
+ blsPublicKeyPut(&pub);
+
+ blsSecretKeySign(&sec, &sign, msg, msgSize);
+ blsSignPut(&sign);
+
+ printf("verify %d\n", blsSignVerify(&sign, &pub, msg, msgSize));
+}