eth2.0-specs/specs/altair/bls.md

2.3 KiB

Ethereum 2.0 Altair BLS extensions

Table of contents

Introduction

A number of extensions are defined to handle BLS signatures in the Altair upgrade.

Knowledge of the phase 0 specification is assumed, including type definitions.

Constants

Name Value
G2_POINT_AT_INFINITY BLSSignature(b'\xc0' + b'\x00' * 95)

Extensions

eth_aggregate_pubkeys

An additional function AggregatePKs is defined to extend the IETF BLS signature draft standard v4 spec referenced in the phase 0 document.

def eth_aggregate_pubkeys(pubkeys: Sequence[BLSPubkey]) -> BLSPubkey:
    """
    Return the aggregate public key for the public keys in ``pubkeys``.

    NOTE: the ``+`` operation should be interpreted as elliptic curve point addition, which takes as input
    elliptic curve points that must be decoded from the input ``BLSPubkey``s.
    This implementation is for demonstrative purposes only and ignores encoding/decoding concerns.
    Refer to the BLS signature draft standard for more information.
    """
    assert len(pubkeys) > 0
    for pubkey in pubkeys:
        # Ensure that the given inputs are valid pubkeys
        assert bls.KeyValidate(pubkey)

    result = copy(pubkeys[0])
    for pubkey in pubkeys[1:]:
        result += pubkey
    return result

eth_fast_aggregate_verify

def eth_fast_aggregate_verify(pubkeys: Sequence[BLSPubkey], message: Bytes32, signature: BLSSignature) -> bool:
    """
    Wrapper to ``bls.FastAggregateVerify`` accepting the ``G2_POINT_AT_INFINITY`` signature when ``pubkeys`` is empty.
    """
    if len(pubkeys) == 0 and signature == G2_POINT_AT_INFINITY:
        return True
    return bls.FastAggregateVerify(pubkeys, message, signature)