Bls.sign
Signs the payload with the provided private key.
Imports
Named
import { Bls } from 'ox'
Examples
import { Bls, Hex } from 'ox'
const signature = Bls.sign({
payload: Hex.random(32),
privateKey: '0x...'
})
Serializing
Signatures can be serialized to hex or bytes using BlsPoint.toHex
or BlsPoint.toBytes
:
import { Bls, BlsPoint, Hex } from 'ox'
const signature = Bls.sign({ payload: Hex.random(32), privateKey: '0x...' })
const const signatureHex: BlsPoint.G2HexsignatureHex = BlsPoint.toHex(signature)
const const signatureBytes: BlsPoint.G2BytessignatureBytes = BlsPoint.toBytes(signature)
They can also be deserialized from hex or bytes using BlsPoint.fromHex
or BlsPoint.fromBytes
:
import { Bls, BlsPoint } from 'ox'
const signatureHex = '0x...'
const const signature: {
x: {
c0: bigint;
c1: bigint;
};
y: {
c0: bigint;
c1: bigint;
};
z: {
c0: bigint;
c1: bigint;
};
}signature = BlsPoint.fromHex(signatureHex, 'G2')
Definition
function sign<size>(
options: sign.Options<size>,
): size extends 'short-key:long-sig' ? BlsPoint.G2 : BlsPoint.G1
Source: src/core/Bls.ts
Parameters
options
- Type:
sign.Options<size>
The signing options.
options.payload
- Type:
0x${string} | Uint8Array
Payload to sign.
options.privateKey
- Type:
0x${string} | Uint8Array
BLS private key.
options.size
- Type:
Size | size
- Optional
Size of the signature to compute.
'long-key:short-sig'
: 48 bytes'short-key:long-sig'
: 96 bytes
options.suite
- Type:
string
- Optional
Ciphersuite to use for signing. Defaults to "Basic".
Return Type
BLS Point.
size extends 'short-key:long-sig' ? BlsPoint.G2 : BlsPoint.G1