aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-06-07 04:32:43 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-06-07 04:32:43 +0800
commit6a59ca023e4bef10f1f4f1eea3903ccdecea2d5e (patch)
tree0b71303dd490e8d37017a3d4ddf6dc69380638d7
parent4fcee45075236077da84982b09ad2133da06497d (diff)
downloaddexon-bls-6a59ca023e4bef10f1f4f1eea3903ccdecea2d5e.tar
dexon-bls-6a59ca023e4bef10f1f4f1eea3903ccdecea2d5e.tar.gz
dexon-bls-6a59ca023e4bef10f1f4f1eea3903ccdecea2d5e.tar.bz2
dexon-bls-6a59ca023e4bef10f1f4f1eea3903ccdecea2d5e.tar.lz
dexon-bls-6a59ca023e4bef10f1f4f1eea3903ccdecea2d5e.tar.xz
dexon-bls-6a59ca023e4bef10f1f4f1eea3903ccdecea2d5e.tar.zst
dexon-bls-6a59ca023e4bef10f1f4f1eea3903ccdecea2d5e.zip
add blsIdSetInt
-rw-r--r--include/bls/bls.h24
-rw-r--r--src/bls_c.cpp4
2 files changed, 17 insertions, 11 deletions
diff --git a/include/bls/bls.h b/include/bls/bls.h
index 32fdd7f..97bd5e7 100644
--- a/include/bls/bls.h
+++ b/include/bls/bls.h
@@ -56,6 +56,19 @@ BLS_DLL_API size_t blsGetOpUnitSize(void);
BLS_DLL_API int blsGetCurveOrder(char *buf, size_t maxBufSize);
BLS_DLL_API int blsGetFieldOrder(char *buf, size_t maxBufSize);
+BLS_DLL_API void blsIdSetInt(blsId *id, int x);
+// return 0 if success
+BLS_DLL_API int blsIdSetDecStr(blsId *id, const char *buf, size_t bufSize);
+BLS_DLL_API int blsIdSetHexStr(blsId *id, const char *buf, size_t bufSize);
+
+/*
+ return strlen(buf) if success else 0
+ buf is '\0' terminated
+*/
+BLS_DLL_API size_t blsIdGetDecStr(char *buf, size_t maxBufSize, const blsId *id);
+BLS_DLL_API size_t blsIdGetHexStr(char *buf, size_t maxBufSize, const blsId *id);
+
+
// return written byte size if success else 0
BLS_DLL_API size_t blsIdSerialize(void *buf, size_t maxBufSize, const blsId *id);
BLS_DLL_API size_t blsSecretKeySerialize(void *buf, size_t maxBufSize, const blsSecretKey *sec);
@@ -116,17 +129,6 @@ BLS_DLL_API int blsIdSetLittleEndian(blsId *id, const void *buf, size_t bufSize)
BLS_DLL_API size_t blsIdGetLittleEndian(void *buf, size_t maxBufSize, const blsId *id);
// return 0 if success
-BLS_DLL_API int blsIdSetDecStr(blsId *id, const char *buf, size_t bufSize);
-BLS_DLL_API int blsIdSetHexStr(blsId *id, const char *buf, size_t bufSize);
-
-/*
- return strlen(buf) if success else 0
- buf is '\0' terminated
-*/
-BLS_DLL_API size_t blsIdGetDecStr(char *buf, size_t maxBufSize, const blsId *id);
-BLS_DLL_API size_t blsIdGetHexStr(char *buf, size_t maxBufSize, const blsId *id);
-
-// return 0 if success
// mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r
BLS_DLL_API int blsSecretKeySetLittleEndian(blsSecretKey *sec, const void *buf, size_t bufSize);
BLS_DLL_API int blsSecretKeySetDecStr(blsSecretKey *sec, const char *buf, size_t bufSize);
diff --git a/src/bls_c.cpp b/src/bls_c.cpp
index 87a77d1..a6c24e2 100644
--- a/src/bls_c.cpp
+++ b/src/bls_c.cpp
@@ -783,6 +783,10 @@ int blsVerifyPop(const blsSignature *sig, const blsPublicKey *pub)
return ((const bls2::Signature*)sig)->verify(*(const bls2::PublicKey*)pub);
}
+void blsIdSetInt(blsId *id, int x)
+{
+ mclBnFr_setInt(&id->v, x);
+}
size_t blsIdSerialize(void *buf, size_t maxBufSize, const blsId *id)
{
return mclBnFr_serialize(buf, maxBufSize, &id->v);