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.
seed
is aUint8Array
.- Returns a
PrivateKey
.
privateKey
is aPrivateKey
.message
is aUint8Array
.- Returns a
JacobianPoint
signature.
privateKey
is aPrivateKey
.message
is aUint8Array
.prependPublicKey
is aJacobianPoint
public key.- Returns a
JacobianPoint
signature.
publicKey
is aJacobianPoint
public key.message
is aUint8Array
.signature
is aJacobianPoint
signature.- Returns a
boolean
for if the signature is valid.
signatures
is anArray<JacobianPoint>
of signatures.- Returns an aggregated
JacobianPoint
.
publicKeys
is anArray<JacobianPoint>
of public keys.messages
is anArray<Uint8Array>
.signature
is aJacobianPoint
signature.- Returns a
boolean
for if the signatures are valid.
privateKey
is aPrivateKey
.index
is anumber
.- Returns the hardened child
PrivateKey
at the index.
privateKey
is aPrivateKey
.index
is anumber
.- Returns the unhardened child
PrivateKey
at the index.
publicKey
is aJacobianPoint
public key.index
is anumber
.- Returns the unhardened child
JacobianPoint
public 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.
seed
is aUint8Array
.- Returns a
PrivateKey
.
privateKey
is aPrivateKey
.message
is aUint8Array
.- Returns a
JacobianPoint
signature.
publicKey
is aJacobianPoint
public key.message
is aUint8Array
.signature
is aJacobianPoint
signature.- Returns a
boolean
for if the signature is valid.
signatures
is anArray<JacobianPoint>
of signatures.- Returns an aggregated
JacobianPoint
.
publicKeys
is anArray<JacobianPoint>
of public keys.messages
is anArray<Uint8Array>
.signature
is aJacobianPoint
signature.- Returns a
boolean
for if the signatures are valid.
privateKey
is aPrivateKey
.index
is anumber
.- Returns the hardened child
PrivateKey
at the index.
privateKey
is aPrivateKey
.index
is anumber
.- Returns the unhardened child
PrivateKey
at the index.
publicKey
is aJacobianPoint
public key.index
is anumber
.- Returns the unhardened child
JacobianPoint
public 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.
seed
is aUint8Array
.- Returns a
PrivateKey
.
privateKey
is aPrivateKey
.message
is aUint8Array
.- Returns a
JacobianPoint
signature.
publicKey
is aJacobianPoint
public key.message
is aUint8Array
.signature
is aJacobianPoint
signature.- Returns a
boolean
for if the signature is valid.
signatures
is anArray<JacobianPoint>
of signatures.- Returns an aggregated
JacobianPoint
.
publicKeys
is anArray<JacobianPoint>
of public keys.messages
is anArray<Uint8Array>
.signature
is aJacobianPoint
signature.- Returns a
boolean
for if the signatures are valid.
privateKey
is aPrivateKey
.- Returns a
JacobianPoint
proof of possession.
publicKey
is aJacobianPoint
public key.proof
is aJacobianPoint
proof of possession.- Returns a
boolean
for if the proof of possession is valid.
publicKeys
is anArray<JacobianPoint>
of public keys.message
is aUint8Array
.signature
is aJacobianPoint
.- Returns a
boolean
for if the signature is valid.
privateKey
is aPrivateKey
.index
is anumber
.- Returns the hardened child
PrivateKey
at the index.
privateKey
is aPrivateKey
.index
is anumber
.- Returns the unhardened child
PrivateKey
at the index.
publicKey
is aJacobianPoint
public key.index
is anumber
.- Returns the unhardened child
JacobianPoint
public key at the index.
bytes
is aUint8Array
.- Returns a
PrivateKey
.
hex
is a hexstring
.- Returns a
PrivateKey
.
seed
is aUint8Array
.- Returns a
PrivateKey
derived from the seed.
value
is abigint
.- Returns a
PrivateKey
.
privateKeys
is anArray<PrivateKey>
.- Returns an aggregated
PrivateKey
.
value
is abigint
.
- Returns a derived
JacobianPoint
public key.
- Returns a
Uint8Array
representation.
- Returns a hex
string
representation.
- Returns a
string
representation.
value
is aPrivateKey
.- Returns a
boolean
for if the values are equal.
This represents both G1Element and G2Element values, which are used for public keys and signatures, respectively.
bytes
is aUint8Array
.isExtension
is aboolean
.- Returns a
JacobianPoint
.
hex
is a hexstring
.isExtension
is aboolean
.- Returns a
JacobianPoint
.
- Returns a
JacobianPoint
G1Element.
- Returns a
JacobianPoint
G2Element.
- Returns a
JacobianPoint
G1Element at infinity.
- Returns a
JacobianPoint
G2Element at infinity.
bytes
is aUint8Array
.- Returns a
JacobianPoint
G1Element.
bytes
is aUint8Array
.- Returns a
JacobianPoint
G2Element.
hex
is a hexstring
.- Returns a
JacobianPoint
G1Element.
hex
is a hexstring
.- Returns a
JacobianPoint
G2Element.
x
,y
, andz
areFq
orFq2
.isInfinity
is aboolean
.
- Returns a
boolean
for if the point is on curve.
- Returns a
boolean
for if the point is valid.
- Returns a small
number
fingerprint that identifies the point.
- Returns an
AffinePoint
representation.
- Returns a
Uint8Array
representation.
- Returns a hex
string
representation.
- Returns a
string
representation.
- Returns a
JacobianPoint
that is double the value.
- Returns a
JacobianPoint
that is the opposite value.
value
is aJacobianPoint
.- Returns a
JacobianPoint
that is the sum of the points.
value
is anFq
orbigint
.- Returns a
JacobianPoint
that is scalar multiplied.
value
is aJacobianPoint
.- Returns a
boolean
for if the values are equal.
- Returns an exact
JacobianPoint
clone.
This is a collection of byte utils that can be directly imported and called, and are not part of a class.
value
is anumber
.size
is anumber
of bytes.endian
is either"big"
or"little"
.signed
is aboolean
, by defaultfalse
.- Returns a
Uint8Array
.
bytes
is aUint8Array
.endian
is either"big"
or"little"
.signed
is aboolean
, by defaultfalse
.- Returns a
number
.
value
is anumber
.- Returns a
Uint8Array
encoded the way that Chia Network's CLVM does.
bytes
is aUint8Array
.- Returns a
number
decoded the way that Chia Network's CLVM does.
value
is abigint
.size
is anumber
of bytes.endian
is either"big"
or"little"
.signed
is aboolean
, by defaultfalse
.- Returns a
Uint8Array
.
bytes
is aUint8Array
.endian
is either"big"
or"little"
.signed
is aboolean
, by defaultfalse
.- Returns a
bigint
.
value
is abigint
.- Returns a
Uint8Array
encoded the way that Chia Network's CLVM does.
bytes
is aUint8Array
.- Returns a
bigint
decoded the way that Chia Network's CLVM does.
lists
is anArray<Uint8Array>
.- Returns a concatenated
Uint8Array
.
a
is aUint8Array
.b
is aUint8Array
.- Returns a
boolean
for if the bytes are exactly equal.
bytes
is aUint8Array
.- Returns a hex
string
.
hex
is a hexstring
.- Returns a
Uint8Array
.