Skip to content

Spec

Documentation for tests/osaka/eip7951_p256verify_precompiles/spec.py@0c700940.

Defines EIP-7951 specification constants and functions.

Spec dataclass

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

Source code in tests/osaka/eip7951_p256verify_precompiles/spec.py
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
@dataclass(frozen=True)
class Spec:
    """
    Parameters from the EIP-7951 specifications as defined at
    https://eips.ethereum.org/EIPS/eip-7951.
    """

    # Address
    P256VERIFY = 0x100

    # Gas constants
    P256VERIFY_GAS = 3450

    # Curve Parameters
    P = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF  ## Base field modulus
    A = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC  ## Curve Coefficient
    B = 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B  ## Curve Coefficient
    N = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551  ## Subgroup Order

    # Other constants
    SUCCESS_RETURN_VALUE = b"\x01".rjust(32, b"\x00")
    INVALID_RETURN_VALUE = b""
    DELEGATION_DESIGNATION = Bytes("ef0100")

    # Test constants (from https://github.com/C2SP/wycheproof/blob/4a6c2bf5dc4c0b67c770233ad33961ee653996a0/testvectors/ecdsa_secp256r1_sha256_test.json#L35)
    H0 = H(0xBB5A52F42F9C9261ED4361F59422A1E30036E7C32B270C8807A419FECA605023)
    R0 = R(0x2BA3A8BE6B94D5EC80A6D9D1190A436EFFE50D85A1EEE859B8CC6AF9BD5C2E18)
    S0 = S(0x4CD60B855D442F5B3C7B11EB6C4E0AE7525FE710FAB9AA7C77A67F79E6FADD76)
    X0 = X(0x2927B10512BAE3EDDCFE467828128BAD2903269919F7086069C8C4DF6C732838)
    Y0 = Y(0xC7787964EAAC00E5921FB1498A60F4606766B3D9685001558D1A974E7341513E)

    @staticmethod
    def delegation_designation(address: Address) -> Bytes:
        """Return delegation designation for the given address."""
        return Bytes(Spec.DELEGATION_DESIGNATION + bytes(address))