demo

bls demo

API

curveType

object

blsId
equal to mclBnFr ; create by blsId_malloc()
blsSecretKey
equal to mclBnFr ; create by blsSecretKey_malloc()
blsPrivateKey
equal to mclBnG1 ; create by blsPrivateKeyKey_malloc()
blsPublicKey
equal to mclBnG2 ; create by blsPublicKey_malloc()
blsSignature ; create by blsSignatureKey_malloc()
equal to mclG1
all objects are deleted by bls_free()

api

int blsInit(int curve, int maxUnitSize)
curve = curveType, maxUnitSize = 6
string blsGetCurveOrder()
return the order of a group
string blsGetFieldOrder()
return the order of an finite field
blsGetGeneratorOfG2(blsPublicKey pub)
set pub to a generator of G2
blsIdSetInt(blsId id, int x)
set id by x
blsIdSetDecStr(blsId id, string s)
set id by decimal string s
blsIdSetHexStr(blsId id, string s)
set id by hexagonal string s
string blsIdGetDecStr(blsId id)
get decimal string of id
string blsIdGetHexStr(blsId id)
return hexiagonal string of id
Uint8Array blsIdSerialize(blsId id)
return Uint8Array of serialized id
Uint8Array blsSecretKeySerialize(blsSecretKey sec)
return Uint8Array of serialized sec
Uint8Array blsPublicKeySerialize(blsPublicKey pub)
return Uint8Array of serialized pub
Uint8Array blsSignatureSerialize(blsSignature sig)
return Uint8Array of serialized sig
blsIdDeserialize(blsId id, Uint8Array a)
set id by a
blsSecretKeyDeserialize(blsSecretKey sec, Uint8Array a)
set sec by a
blsPublicKeyDeserialize(blsPublicKey pub, Uint8Array a)
set pub by a
blsSignatureDeserialize(blsSignature sig, Uint8Array a)
set sig by a
blsIdIsEqual(blsId lhs, blsId rhs)
return 1 if lhs == rhs
blsSecretKeyIsEqual(blsSecretKey lhs, blsSecretKey rhs)
return 1 if lhs == rhs
blsPublicKeyIsEqual(blsPublicKey lhs, blsPublicKey rhs)
return 1 if lhs == rhs
blsSignatureIsEqual(blsSignature lhs, blsSignature rhs)
return 1 if lhs == rhs
blsSecretKeyAdd(blsSecretKey sec, blsSecretKey rhs)
sec += rhs
blsPublicKeyAdd(blsPublicKey pub, blsPublicKey rhs)
sec += rhs
blsSignatureAdd(blsSignature sig, blsSignature rhs)
sec += rhs
blsHashToSecretKey(blsSecretKey sec, (string|Uint8Array) s)
set sec by hash(s)
blsSecretKeySetByCSPRNG(blsSecretKey sec)
set sec by random number generator
blsGetPublicKey(blsPublicKey pub, blsSecretKey sec)
set public key pub by secret key sec
blsSecretKeyShare(blsSecretKey sec, array of blsSecretKey msk, blsId id)
share secret key sec by array of blsSecretKey msk with id
blsPublicKeyShare(blsPublicKey pub, array of blsPublicKey mpk, blsId id)
share public key pub by array of blsPublicKey mpk with id
blsSecretKeyRecover(blsSecretKey sec, array of blsSecretKey secVec, array of blsId idVec)
recover sec by n array of secVec and idVec
blsPublicKeyRecover(blsPublicKey pub, array of blsPublicKey pubVec, array of blsId idVec)
recover pub by n array of pubVec and idVec
blsSignatureRecover(blsSignature sig, array of blsSignature sigVec, array of blsId idVec)
recover sig by n array of sigVec and idVec
blsSign(blsSignature sig, blsSecretKey sec, (string|Uint8Array) m)
set sig by signing message m with sec
blsVerify(blsSignature sig, blsPublicKey pub, (string|Uint8Array) m)
verify sig by pub and message m