A browser friendly implementation of bls-signatures in TypeScript, based off of the Python implementation.
BLS Signatures is a cryptographic library used by projects and blockchains such as the Chia blockchain. It is a type of elliptic curve cryptography.
This particular implementation is written with TypeScript, and is not bindings to native code. This allows it to be used in the browser as well. However, if you prefer native bindings, you should check out this library instead.
In this library, bytes are stored using the Uint8Array typed array class from the ECMAScript specification for multiplatform support.
By design, the functions and methods exposed by this library are synchronous and everything is exported for ease of use.
Since it is written in TypeScript, there are built-in typings for IntelliSense. The following documentation is non-exhaustive, but should be enough for most uses.
This scheme is from the BLS spec in the IETF. AugSchemeMPL is used by the Chia Network and is more secure but less efficient.
seedis aUint8Array.- Returns a
PrivateKey.
privateKeyis aPrivateKey.messageis aUint8Array.- Returns a
JacobianPointsignature.
privateKeyis aPrivateKey.messageis aUint8Array.prependPublicKeyis aJacobianPointpublic key.- Returns a
JacobianPointsignature.
publicKeyis aJacobianPointpublic key.messageis aUint8Array.signatureis aJacobianPointsignature.- Returns a
booleanfor if the signature is valid.
signaturesis anArray<JacobianPoint>of signatures.- Returns an aggregated
JacobianPoint.
publicKeysis anArray<JacobianPoint>of public keys.messagesis anArray<Uint8Array>.signatureis aJacobianPointsignature.- Returns a
booleanfor if the signatures are valid.
privateKeyis aPrivateKey.indexis anumber.- Returns the hardened child
PrivateKeyat the index.
privateKeyis aPrivateKey.indexis anumber.- Returns the unhardened child
PrivateKeyat the index.
publicKeyis aJacobianPointpublic key.indexis anumber.- Returns the unhardened child
JacobianPointpublic key at the index.
This scheme is from the BLS spec in the IETF. BasicSchemeMPL is very fast, but not as secure as the other schemes.
seedis aUint8Array.- Returns a
PrivateKey.
privateKeyis aPrivateKey.messageis aUint8Array.- Returns a
JacobianPointsignature.
publicKeyis aJacobianPointpublic key.messageis aUint8Array.signatureis aJacobianPointsignature.- Returns a
booleanfor if the signature is valid.
signaturesis anArray<JacobianPoint>of signatures.- Returns an aggregated
JacobianPoint.
publicKeysis anArray<JacobianPoint>of public keys.messagesis anArray<Uint8Array>.signatureis aJacobianPointsignature.- Returns a
booleanfor if the signatures are valid.
privateKeyis aPrivateKey.indexis anumber.- Returns the hardened child
PrivateKeyat the index.
privateKeyis aPrivateKey.indexis anumber.- Returns the unhardened child
PrivateKeyat the index.
publicKeyis aJacobianPointpublic key.indexis anumber.- Returns the unhardened child
JacobianPointpublic key at the index.
This scheme is from the BLS spec in the IETF. PopSchemeMPL is secure, but it requires registration, for example with Ethereum 2.0 Proof of Stake.
seedis aUint8Array.- Returns a
PrivateKey.
privateKeyis aPrivateKey.messageis aUint8Array.- Returns a
JacobianPointsignature.
publicKeyis aJacobianPointpublic key.messageis aUint8Array.signatureis aJacobianPointsignature.- Returns a
booleanfor if the signature is valid.
signaturesis anArray<JacobianPoint>of signatures.- Returns an aggregated
JacobianPoint.
publicKeysis anArray<JacobianPoint>of public keys.messagesis anArray<Uint8Array>.signatureis aJacobianPointsignature.- Returns a
booleanfor if the signatures are valid.
privateKeyis aPrivateKey.- Returns a
JacobianPointproof of possession.
publicKeyis aJacobianPointpublic key.proofis aJacobianPointproof of possession.- Returns a
booleanfor if the proof of possession is valid.
publicKeysis anArray<JacobianPoint>of public keys.messageis aUint8Array.signatureis aJacobianPoint.- Returns a
booleanfor if the signature is valid.
privateKeyis aPrivateKey.indexis anumber.- Returns the hardened child
PrivateKeyat the index.
privateKeyis aPrivateKey.indexis anumber.- Returns the unhardened child
PrivateKeyat the index.
publicKeyis aJacobianPointpublic key.indexis anumber.- Returns the unhardened child
JacobianPointpublic key at the index.
bytesis aUint8Array.- Returns a
PrivateKey.
hexis a hexstring.- Returns a
PrivateKey.
seedis aUint8Array.- Returns a
PrivateKeyderived from the seed.
valueis abigint.- Returns a
PrivateKey.
privateKeysis anArray<PrivateKey>.- Returns an aggregated
PrivateKey.
valueis abigint.
- Returns a derived
JacobianPointpublic key.
- Returns a
Uint8Arrayrepresentation.
- Returns a hex
stringrepresentation.
- Returns a
stringrepresentation.
valueis aPrivateKey.- Returns a
booleanfor if the values are equal.
This represents both G1Element and G2Element values, which are used for public keys and signatures, respectively.
bytesis aUint8Array.isExtensionis aboolean.- Returns a
JacobianPoint.
hexis a hexstring.isExtensionis aboolean.- Returns a
JacobianPoint.
- Returns a
JacobianPointG1Element.
- Returns a
JacobianPointG2Element.
- Returns a
JacobianPointG1Element at infinity.
- Returns a
JacobianPointG2Element at infinity.
bytesis aUint8Array.- Returns a
JacobianPointG1Element.
bytesis aUint8Array.- Returns a
JacobianPointG2Element.
hexis a hexstring.- Returns a
JacobianPointG1Element.
hexis a hexstring.- Returns a
JacobianPointG2Element.
x,y, andzareFqorFq2.isInfinityis aboolean.
- Returns a
booleanfor if the point is on curve.
- Returns a
booleanfor if the point is valid.
- Returns a small
numberfingerprint that identifies the point.
- Returns an
AffinePointrepresentation.
- Returns a
Uint8Arrayrepresentation.
- Returns a hex
stringrepresentation.
- Returns a
stringrepresentation.
- Returns a
JacobianPointthat is double the value.
- Returns a
JacobianPointthat is the opposite value.
valueis aJacobianPoint.- Returns a
JacobianPointthat is the sum of the points.
valueis anFqorbigint.- Returns a
JacobianPointthat is scalar multiplied.
valueis aJacobianPoint.- Returns a
booleanfor if the values are equal.
- Returns an exact
JacobianPointclone.
This is a collection of byte utils that can be directly imported and called, and are not part of a class.
valueis anumber.sizeis anumberof bytes.endianis either"big"or"little".signedis aboolean, by defaultfalse.- Returns a
Uint8Array.
bytesis aUint8Array.endianis either"big"or"little".signedis aboolean, by defaultfalse.- Returns a
number.
valueis anumber.- Returns a
Uint8Arrayencoded the way that Chia Network's CLVM does.
bytesis aUint8Array.- Returns a
numberdecoded the way that Chia Network's CLVM does.
valueis abigint.sizeis anumberof bytes.endianis either"big"or"little".signedis aboolean, by defaultfalse.- Returns a
Uint8Array.
bytesis aUint8Array.endianis either"big"or"little".signedis aboolean, by defaultfalse.- Returns a
bigint.
valueis abigint.- Returns a
Uint8Arrayencoded the way that Chia Network's CLVM does.
bytesis aUint8Array.- Returns a
bigintdecoded the way that Chia Network's CLVM does.
listsis anArray<Uint8Array>.- Returns a concatenated
Uint8Array.
ais aUint8Array.bis aUint8Array.- Returns a
booleanfor if the bytes are exactly equal.
bytesis aUint8Array.- Returns a hex
string.
hexis a hexstring.- Returns a
Uint8Array.
