Record Class EIP712TypedData

java.lang.Object
java.lang.Record
com.tnsai.payment.x402.EIP712TypedData
Record Components:
domainSeparator - 32-byte EIP-712 domain separator
structHash - 32-byte message struct hash

public record EIP712TypedData(byte[] domainSeparator, byte[] structHash) extends Record
The two 32-byte values an EVM wallet needs in order to produce an EIP-712 signature.

This record is intentionally shallow — it does not carry the raw typed-data tree, only the canonical hashes derived from it:

  • domainSeparator() — the keccak256(EIP712Domain(...)) value scoped to the contract that will verify the signature.
  • structHash() — the keccak256(message struct) value for the specific operation being authorised (e.g. transferWithAuthorization).

The signer multiplies these into the standard EIP-712 digest keccak256(0x1901 || domainSeparator || structHash) before applying secp256k1. Building the two inputs is the broker's job; the wallet only signs them.

P3 of TNS-449 adds the transferWithAuthorization-shaped builder that produces this record from a PaymentRequirement. P2 ships the shape only.

Since:
0.10.5 (TNS-449 P2)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Expected length, in bytes, of each component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    EIP712TypedData(byte[] domainSeparator, byte[] structHash)
    Creates an instance of a EIP712TypedData record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Defensive copy on accessor — same reason as the constructor.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    byte[]
    Defensive copy on accessor — same reason as the constructor.
    Hex render of both hashes, useful for logging and debugging.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • HASH_LENGTH_BYTES

      public static final int HASH_LENGTH_BYTES
      Expected length, in bytes, of each component.
      See Also:
  • Constructor Details

    • EIP712TypedData

      public EIP712TypedData(byte[] domainSeparator, byte[] structHash)
      Creates an instance of a EIP712TypedData record class.
      Parameters:
      domainSeparator - the value for the domainSeparator record component
      structHash - the value for the structHash record component
  • Method Details

    • domainSeparator

      public byte[] domainSeparator()
      Defensive copy on accessor — same reason as the constructor.
    • structHash

      public byte[] structHash()
      Defensive copy on accessor — same reason as the constructor.
    • toString

      public String toString()
      Hex render of both hashes, useful for logging and debugging.
      Specified by:
      toString in class Record
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.