A browser friendly implementation of bls-signatures.
npm install chia-bls
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.
- AugSchemeMPL
- BasicSchemeMPL
- PopSchemeMPL
- PrivateKey
- JacobianPoint
- Byte Utils
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 a Uint8Array.
- Returns a PrivateKey.
- privateKey is a PrivateKey.
- message is a Uint8Array.
- Returns a JacobianPoint signature.
- privateKey is a PrivateKey.
- message is a Uint8Array.
- prependPublicKey is a JacobianPoint public key.
- Returns a JacobianPoint signature.
- publicKey is a JacobianPoint public key.
- message is a Uint8Array.
- signature is a JacobianPoint signature.
- Returns a boolean for if the signature is valid.
- signatures is an Array of signatures.
- Returns an aggregated JacobianPoint.
- publicKeys is an Array of public keys.
- messages is an Array.
- signature is a JacobianPoint signature.
- Returns a boolean for if the signatures are valid.
- privateKey is a PrivateKey.
- index is a number.
- Returns the hardened child PrivateKey at the index.
- privateKey is a PrivateKey.
- index is a number.
- Returns the unhardened child PrivateKey at the index.
- publicKey is a JacobianPoint public key.
- index is a number.
- 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 a Uint8Array.
- Returns a PrivateKey.
- privateKey is a PrivateKey.
- message is a Uint8Array.
- Returns a JacobianPoint signature.
- publicKey is a JacobianPoint public key.
- message is a Uint8Array.
- signature is a JacobianPoint signature.
- Returns a boolean for if the signature is valid.
- signatures is an Array of signatures.
- Returns an aggregated JacobianPoint.
- publicKeys is an Array of public keys.
- messages is an Array.
- signature is a JacobianPoint signature.
- Returns a boolean for if the signatures are valid.
- privateKey is a PrivateKey.
- index is a number.
- Returns the hardened child PrivateKey at the index.
- privateKey is a PrivateKey.
- index is a number.
- Returns the unhardened child PrivateKey at the index.
- publicKey is a JacobianPoint public key.
- index is a number.
- 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 a Uint8Array.
- Returns a PrivateKey.
- privateKey is a PrivateKey.
- message is a Uint8Array.
- Returns a JacobianPoint signature.
- publicKey is a JacobianPoint public key.
- message is a Uint8Array.
- signature is a JacobianPoint signature.
- Returns a boolean for if the signature is valid.
- signatures is an Array of signatures.
- Returns an aggregated JacobianPoint.
- publicKeys is an Array of public keys.
- messages is an Array.
- signature is a JacobianPoint signature.
- Returns a boolean for if the signatures are valid.
- privateKey is a PrivateKey.
- Returns a JacobianPoint proof of possession.
- publicKey is a JacobianPoint public key.
- proof is a JacobianPoint proof of possession.
- Returns a boolean for if the proof of possession is valid.
- publicKeys is an Array of public keys.
- message is a Uint8Array.
- signature is a JacobianPoint.
- Returns a boolean for if the signature is valid.
- privateKey is a PrivateKey.
- index is a number.
- Returns the hardened child PrivateKey at the index.
- privateKey is a PrivateKey.
- index is a number.
- Returns the unhardened child PrivateKey at the index.
- publicKey is a JacobianPoint public key.
- index is a number.
- Returns the unhardened child JacobianPoint public key at the index.
- bytes is a Uint8Array.
- Returns a PrivateKey.
- hex is a hex string.
- Returns a PrivateKey.
- seed is a Uint8Array.
- Returns a PrivateKey derived from the seed.
- value is a bigint.
- Returns a PrivateKey.
- privateKeys is an Array.
- Returns an aggregated PrivateKey.
- value is a bigint.
- Returns a derived JacobianPoint public key.
- Returns a Uint8Array representation.
- Returns a hex string representation.
- Returns a string representation.
- value is a PrivateKey.
- 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 a Uint8Array.
- isExtension is a boolean.
- Returns a JacobianPoint.
- hex is a hex string.
- isExtension is a boolean.
- 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 a Uint8Array.
- Returns a JacobianPoint G1Element.
- bytes is a Uint8Array.
- Returns a JacobianPoint G2Element.
- hex is a hex string.
- Returns a JacobianPoint G1Element.
- hex is a hex string.
- Returns a JacobianPoint G2Element.
- x, y, and z are Fq or Fq2.
- isInfinity is a boolean.
- 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 a JacobianPoint.
- Returns a JacobianPoint that is the sum of the points.
- value is an Fq or bigint.
- Returns a JacobianPoint that is scalar multiplied.
- value is a JacobianPoint.
- 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 a number.
- size is a number of bytes.
- endian is either "big" or "little".
- signed is a boolean, by default false.
- Returns a Uint8Array.
- bytes is a Uint8Array.
- endian is either "big" or "little".
- signed is a boolean, by default false.
- Returns a number.
- value is a number.
- Returns a Uint8Array encoded the way that Chia Network's CLVM does.
- bytes is a Uint8Array.
- Returns a number decoded the way that Chia Network's CLVM does.
- value is a bigint.
- size is a number of bytes.
- endian is either "big" or "little".
- signed is a boolean, by default false.
- Returns a Uint8Array.
- bytes is a Uint8Array.
- endian is either "big" or "little".
- signed is a boolean, by default false.
- Returns a bigint.
- value is a bigint.
- Returns a Uint8Array encoded the way that Chia Network's CLVM does.
- bytes is a Uint8Array.
- Returns a bigint decoded the way that Chia Network's CLVM does.
- lists is an Array.
- Returns a concatenated Uint8Array.
- a is a Uint8Array.
- b is a Uint8Array.
- Returns a boolean for if the bytes are exactly equal.
- bytes is a Uint8Array.
- Returns a hex string.
- hex is a hex string.
- Returns a Uint8Array.