Skip to content

Spec

Documentation for tests/istanbul/eip152_blake2/spec.py@28e339e9.

Defines EIP-152 specification constants and functions.

Spec dataclass

Parameters from the EIP-152 specifications as defined at https://eips.ethereum.org/EIPS/eip-152#specification.

If the parameter is not currently used within the tests, it is commented out.

Source code in tests/istanbul/eip152_blake2/spec.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@dataclass(frozen=True)
class Spec:
    """
    Parameters from the EIP-152 specifications as defined at
    https://eips.ethereum.org/EIPS/eip-152#specification.

    If the parameter is not currently used within the tests, it is commented
    out.
    """

    BLAKE2_PRECOMPILE_ADDRESS = 0x09

    # The following constants are used to define the bytes length of the
    # parameters passed to the BLAKE2 precompile.
    BLAKE2_PRECOMPILE_ROUNDS_LENGTH = 4
    # BLAKE2_PRECOMPILE_M_LENGTH = 128
    BLAKE2_PRECOMPILE_T_0_LENGTH = 8
    BLAKE2_PRECOMPILE_T_1_LENGTH = 8
    BLAKE2_PRECOMPILE_F_LENGTH = 1

    # Constants for BLAKE2b and BLAKE2s spec defined at
    # https://datatracker.ietf.org/doc/html/rfc7693#section-3.2
    BLAKE2B_PRECOMPILE_ROUNDS = 12
    BLAKE2B_PRECOMPILE_H_LENGTH = 64

SpecTestVectors

Defines common test parameters for the BLAKE2b precompile.

Source code in tests/istanbul/eip152_blake2/spec.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class SpecTestVectors:
    """Defines common test parameters for the BLAKE2b precompile."""

    # The following constants are used to define common test parameters
    # Origin of vectors defined at
    # https://datatracker.ietf.org/doc/html/rfc7693.html#appendix-A
    BLAKE2_STATE_VECTOR = (
        "48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1"
        "361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f"
        "79217e1319cde05b"
    )
    BLAKE2_MESSAGE_BLOCK_VECTOR = (
        "616263000000000000000000000000000000000"
        "00000000000000000000000000000000000000000000000000000000000000000"
        "00000000000000000000000000000000000000000000000000000000000000000"
        "00000000000000000000000000000000000000000000000000000000000000000"
        "0000000000000000000000"
    )
    BLAKE2_OFFSET_COUNTER_0 = 3
    BLAKE2_OFFSET_COUNTER_1 = 0