aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-10-28 14:20:12 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-10-28 14:20:12 +0800
commit5f2112059cb6326f03e1ac5585b1df1bb6fdc55f (patch)
treebd63f32e9061849e86ec95c420b7f759c75bafb5
parent994b575d1aba98ec664155407c24d2cb33a15140 (diff)
downloaddexon-bls-5f2112059cb6326f03e1ac5585b1df1bb6fdc55f.tar
dexon-bls-5f2112059cb6326f03e1ac5585b1df1bb6fdc55f.tar.gz
dexon-bls-5f2112059cb6326f03e1ac5585b1df1bb6fdc55f.tar.bz2
dexon-bls-5f2112059cb6326f03e1ac5585b1df1bb6fdc55f.tar.lz
dexon-bls-5f2112059cb6326f03e1ac5585b1df1bb6fdc55f.tar.xz
dexon-bls-5f2112059cb6326f03e1ac5585b1df1bb6fdc55f.tar.zst
dexon-bls-5f2112059cb6326f03e1ac5585b1df1bb6fdc55f.zip
add blsSetRandFunc
-rw-r--r--include/bls/bls.h9
-rw-r--r--src/bls_c_impl.hpp4
2 files changed, 13 insertions, 0 deletions
diff --git a/include/bls/bls.h b/include/bls/bls.h
index 6b7cbdd..48ad855 100644
--- a/include/bls/bls.h
+++ b/include/bls/bls.h
@@ -184,6 +184,15 @@ BLS_DLL_API int blsHashToSecretKey(blsSecretKey *sec, const void *buf, mclSize b
return 0 if success else -1
*/
BLS_DLL_API int blsSecretKeySetByCSPRNG(blsSecretKey *sec);
+/*
+ set user-defined random function for setByCSPRNG
+ @param self [in] user-defined pointer
+ @param readFunc [in] user-defined function,
+ which writes random bufSize bytes to buf and returns bufSize if success else returns 0
+ @note if self == 0 and readFunc == 0 then set default random function
+ @note not threadsafe
+*/
+BLS_DLL_API void blsSetRandFunc(void *self, unsigned int (*readFunc)(void *self, void *buf, unsigned int bufSize));
#endif
BLS_DLL_API void blsGetPop(blsSignature *sig, const blsSecretKey *sec);
diff --git a/src/bls_c_impl.hpp b/src/bls_c_impl.hpp
index 255b209..f1c880e 100644
--- a/src/bls_c_impl.hpp
+++ b/src/bls_c_impl.hpp
@@ -392,6 +392,10 @@ int blsSecretKeySetByCSPRNG(blsSecretKey *sec)
{
return mclBnFr_setByCSPRNG(&sec->v);
}
+void blsSetRandFunc(void *self, unsigned int (*readFunc)(void *self, void *buf, unsigned int bufSize))
+{
+ return mclBn_setRandFunc(self, readFunc);
+}
#endif
void blsGetPop(blsSignature *sig, const blsSecretKey *sec)