Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

BLSSig

Git Source

test top This library implements the verification of the BLS signature scheme over the BN254 curve following the rust implementation at https://github.com/EspressoSystems/jellyfish/blob/e1e683c287f20160738e6e737295dd8f9e70577a/primitives/src/signatures/bls_over_bn254.rs

Functions

_uint256FromBytesLittleEndian

function _uint256FromBytesLittleEndian(uint8[] memory input) private pure returns (uint256);

expand

Takes a sequence of bytes and turn in into another sequence of bytes with fixed size. Equivalent of https://github.com/arkworks-rs/algebra/blob/1f7b3c6b215e98fa3130b39d2967f6b43df41e04/ff/src/fields/field_hashers/expander/mod.rs#L37

function expand(bytes memory message) internal pure returns (bytes memory);

Parameters

NameTypeDescription
messagebytesmessage to be “expanded”

Returns

NameTypeDescription
<none>bytesfixed size array of bytes

hashToField

Hash a sequence of bytes to a field element in Fq. Equivalent of https://github.com/arkworks-rs/algebra/blob/1f7b3c6b215e98fa3130b39d2967f6b43df41e04/ff/src/fields/field_hashers/mod.rs#L65

function hashToField(bytes memory message) internal pure returns (uint256);

Parameters

NameTypeDescription
messagebytesinput message to be hashed

Returns

NameTypeDescription
<none>uint256field element in Fq

hashToCurve

Hash a sequence of bytes to a group element in BN254.G_1. We use the hash-and-pray algorithm for now. Rust implementation can be found at https://github.com/EspressoSystems/jellyfish/blob/e1e683c287f20160738e6e737295dd8f9e70577a/primitives/src/signatures/bls_over_bn254.rs#L318

function hashToCurve(bytes memory input) internal view returns (BN254.G1Point memory);

Parameters

NameTypeDescription
inputbytesmessage to be hashed

Returns

NameTypeDescription
<none>BN254.G1Pointgroup element in G_1

verifyBlsSig

Verify a bls signature. Reverts if the signature is invalid

function verifyBlsSig(bytes memory message, BN254.G1Point memory sig, BN254.G2Point memory pk)
    internal
    view;

Parameters

NameTypeDescription
messagebytesmessage to check the signature against
sigBN254.G1Pointsignature represented as a point in BN254.G_1
pkBN254.G2Pointpublic key represented as a point in BN254.G_2

Errors

BLSSigVerificationFailed

error BLSSigVerificationFailed();