From 0d6d8737af82dfc9cfdf744bbdfa0c26a5693f91 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Tue, 6 Jun 2017 07:19:17 +0900 Subject: reorder apis of bls --- include/bls/bls.h | 112 +++++++++++++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/include/bls/bls.h b/include/bls/bls.h index 634a699..69fafcd 100644 --- a/include/bls/bls.h +++ b/include/bls/bls.h @@ -50,24 +50,75 @@ typedef struct { @note init() is not thread safe */ BLS_DLL_API int blsInit(int curve, int maxUnitSize); + BLS_DLL_API size_t blsGetOpUnitSize(void); // return strlen(buf) if success else 0 BLS_DLL_API int blsGetCurveOrder(char *buf, size_t maxBufSize); BLS_DLL_API int blsGetFieldOrder(char *buf, size_t maxBufSize); +// 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); +BLS_DLL_API size_t blsPublicKeySerialize(void *buf, size_t maxBufSize, const blsPublicKey *pub); +BLS_DLL_API size_t blsSignatureSerialize(void *buf, size_t maxBufSize, const blsSignature *sig); + +// return 1 if same else 0 +BLS_DLL_API int blsIDDeserialize(blsId *id, const void *buf, size_t bufSize); +BLS_DLL_API int blsSecretKeyDeserialize(blsSecretKey *sec, const void *buf, size_t bufSize); +BLS_DLL_API int blsPublicKeyDeserialize(blsPublicKey *pub, const void *buf, size_t bufSize); +BLS_DLL_API int blsSignatureDeserialize(blsSignature *sig, const void *buf, size_t bufSize); + // return 1 if same else 0 BLS_DLL_API int blsIdIsEqual(const blsId *lhs, const blsId *rhs); +BLS_DLL_API int blsSecretKeyIsEqual(const blsSecretKey *lhs, const blsSecretKey *rhs); +BLS_DLL_API int blsPublicKeyIsEqual(const blsPublicKey *lhs, const blsPublicKey *rhs); +BLS_DLL_API int blsSignatureIsEqual(const blsSignature *lhs, const blsSignature *rhs); + +// add +BLS_DLL_API void blsSecretKeyAdd(blsSecretKey *sec, const blsSecretKey *rhs); +BLS_DLL_API void blsPublicKeyAdd(blsPublicKey *pub, const blsPublicKey *rhs); +BLS_DLL_API void blsSignatureAdd(blsSignature *sig, const blsSignature *rhs); + +// hash buf and set +BLS_DLL_API int blsHashToSecretKey(blsSecretKey *sec, const void *buf, size_t bufSize); +/* + set secretKey if system has /dev/urandom or CryptGenRandom + return 0 if success else -1 +*/ +BLS_DLL_API int blsSecretKeySetByCSPRNG(blsSecretKey *sec); + +BLS_DLL_API void blsGetPublicKey(blsPublicKey *pub, const blsSecretKey *sec); +BLS_DLL_API void blsGetPop(blsSignature *sig, const blsSecretKey *sec); -// mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r // return 0 if success -BLS_DLL_API int blsIdSetLittleEndian(blsId *id, const void *buf, size_t bufSize); -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); +BLS_DLL_API int blsSecretKeyShare(blsSecretKey *sec, const blsSecretKey* msk, size_t k, const blsId *id); +BLS_DLL_API int blsPublicKeyShare(blsPublicKey *pub, const blsPublicKey *mpk, size_t k, const blsId *id); + +BLS_DLL_API int blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey *secVec, const blsId *idVec, size_t n); +BLS_DLL_API int blsPublicKeyRecover(blsPublicKey *pub, const blsPublicKey *pubVec, const blsId *idVec, size_t n); +BLS_DLL_API int blsSignatureRecover(blsSignature *sig, const blsSignature *sigVec, const blsId *idVec, size_t n); + +BLS_DLL_API void blsSign(blsSignature *sig, const blsSecretKey *sec, const char *m, size_t size); + +// return 1 if valid +BLS_DLL_API int blsVerify(const blsSignature *sig, const blsPublicKey *pub, const char *m, size_t size); +BLS_DLL_API int blsVerifyPop(const blsSignature *sig, const blsPublicKey *pub); + +////////////////////////////////////////////////////////////////////////// +// the following apis will be removed + +// mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r +BLS_DLL_API int blsIdSetLittleEndian(blsId *id, const void *buf, size_t bufSize); /* return written byte size if success else 0 */ 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 @@ -75,11 +126,8 @@ BLS_DLL_API size_t blsIdGetLittleEndian(void *buf, size_t maxBufSize, const blsI 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 1 if same else 0 -BLS_DLL_API int blsSecretKeyIsEqual(const blsSecretKey *lhs, const blsSecretKey *rhs); - -// mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r // 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); BLS_DLL_API int blsSecretKeySetHexStr(blsSecretKey *sec, const char *buf, size_t bufSize); @@ -87,64 +135,16 @@ BLS_DLL_API int blsSecretKeySetHexStr(blsSecretKey *sec, const char *buf, size_t return written byte size if success else 0 */ BLS_DLL_API size_t blsSecretKeyGetLittleEndian(void *buf, size_t maxBufSize, const blsSecretKey *sec); -/* - hash buf and set -*/ -BLS_DLL_API int blsHashToSecretKey(blsSecretKey *sec, const void *buf, size_t bufSize); -/* - set secretKey if system has /dev/urandom or CryptGenRandom - return 0 if success else -1 -*/ -BLS_DLL_API int blsSecretKeySetByCSPRNG(blsSecretKey *sec); /* return strlen(buf) if success else 0 buf is '\0' terminated */ BLS_DLL_API size_t blsSecretKeyGetDecStr(char *buf, size_t maxBufSize, const blsSecretKey *sec); BLS_DLL_API size_t blsSecretKeyGetHexStr(char *buf, size_t maxBufSize, const blsSecretKey *sec); -BLS_DLL_API void blsSecretKeyAdd(blsSecretKey *sec, const blsSecretKey *rhs); - -BLS_DLL_API void blsGetPublicKey(blsPublicKey *pub, const blsSecretKey *sec); -BLS_DLL_API void blsSign(blsSignature *sig, const blsSecretKey *sec, const char *m, size_t size); -// return 0 if success -BLS_DLL_API int blsSecretKeyShare(blsSecretKey *sec, const blsSecretKey* msk, size_t k, const blsId *id); -// return 0 if success -BLS_DLL_API int blsSecretKeyRecover(blsSecretKey *sec, const blsSecretKey *secVec, const blsId *idVec, size_t n); -BLS_DLL_API void blsGetPop(blsSignature *sig, const blsSecretKey *sec); - -// return 1 if same else 0 -BLS_DLL_API int blsPublicKeyIsEqual(const blsPublicKey *lhs, const blsPublicKey *rhs); -// return 0 if success -BLS_DLL_API int blsPublicKeyDeserialize(blsPublicKey *pub, const void *buf, size_t bufSize); -/* - return written byte size if success else 0 -*/ -BLS_DLL_API size_t blsPublicKeySerialize(void *buf, size_t maxBufSize, const blsPublicKey *pub); BLS_DLL_API int blsPublicKeySetHexStr(blsPublicKey *pub, const char *buf, size_t bufSize); BLS_DLL_API size_t blsPublicKeyGetHexStr(char *buf, size_t maxBufSize, const blsPublicKey *pub); -BLS_DLL_API void blsPublicKeyAdd(blsPublicKey *pub, const blsPublicKey *rhs); -// return 0 if success -BLS_DLL_API int blsPublicKeyShare(blsPublicKey *pub, const blsPublicKey *mpk, size_t k, const blsId *id); -// return 0 if success -BLS_DLL_API int blsPublicKeyRecover(blsPublicKey *pub, const blsPublicKey *pubVec, const blsId *idVec, size_t n); - -// return 1 if same else 0 -BLS_DLL_API int blsSignatureIsEqual(const blsSignature *lhs, const blsSignature *rhs); - -// return 0 if success -BLS_DLL_API int blsSignatureDeserialize(blsSignature *sig, const void *buf, size_t bufSize); -/* - return written byte size if success else 0 -*/ -BLS_DLL_API size_t blsSignatureSerialize(void *buf, size_t maxBufSize, const blsSignature *sig); BLS_DLL_API int blsSignatureSetHexStr(blsSignature *sig, const char *buf, size_t bufSize); BLS_DLL_API size_t blsSignatureGetHexStr(char *buf, size_t maxBufSize, const blsSignature *sig); -BLS_DLL_API void blsSignatureAdd(blsSignature *sig, const blsSignature *rhs); -// return 0 if success -BLS_DLL_API int blsSignatureRecover(blsSignature *sig, const blsSignature *sigVec, const blsId *idVec, size_t n); -BLS_DLL_API int blsVerify(const blsSignature *sig, const blsPublicKey *pub, const char *m, size_t size); - -BLS_DLL_API int blsVerifyPop(const blsSignature *sig, const blsPublicKey *pub); #ifdef __cplusplus } -- cgit v1.2.3