HashToField (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.crypto.hash2curve

## Class HashToField

- java.lang.Object
- - org.bouncycastle.crypto.hash2curve.HashToField

-     public class HashToField
      extends java.lang.Object

  Generic implementation of hash to field

  This implementation is restricted to hashing to a field where the field being hashed to is derived from an Elliptic curve

  The HashToField function can be used to hash to any field such as a scalar field (group order) This implementation is not suitable for such cases as described in more detail in the GenericOPRFHashToScalar function. Instead, this class is strictly used to implement HashToField when hashing is done to curve order as this is the way the function is used in HashToEllipticCurve operations.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ECCurve` | `curve`
    `protected byte[]` | `dst`
    `protected int` | `L` Security parameter for the suite
    `protected int` | `m`
    `protected MessageExpansion` | `messageExpansion`
    `protected java.math.BigInteger` | `p`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HashToField(byte[] dst, ECCurve curve, MessageExpansion messageExpansion, int L)` Constructs a new instance of the HashToCurveField class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.math.BigInteger[][]` | `process(byte[] message, int count)` Processes the input message and hashes it into a multidimensional array of elements in a finite field derived from an elliptic curve.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### dst

          protected final byte[] dst

    - #### curve

          protected final ECCurve curve

    - #### messageExpansion

          protected final MessageExpansion messageExpansion

    - #### L

          protected int L

      Security parameter for the suite

    - #### m

          protected int m

    - #### p

          protected java.math.BigInteger p

  - ### Constructor Detail

    - #### HashToField

          public HashToField(byte[] dst,
                             ECCurve curve,
                             MessageExpansion messageExpansion,
                             int L)

      Constructs a new instance of the HashToCurveField class.

      This constructor allows the creation of a hash-to-field mechanism tied to an elliptic curve, with parameters specifying domain separation, message expansion mechanics, security level, and the count of resulting field elements.

      Parameters:
        `dst` - The domain separation tag, used to separate different domains of usage to ensure distinct use cases do not produce the same output for the same input.
        `curve` - The elliptic curve from which the field to hash to is derived.
        `messageExpansion` - The mechanism for expanding input messages, ensuring the required cryptographic properties for subsequent field hashing.
        `L` - The security parameter for the suite, determining the byte length of individual elements used in the computation.

  - ### Method Detail

    - #### process

          public java.math.BigInteger[][] process(byte[] message,
                                                  int count)

      Processes the input message and hashes it into a multidimensional array of elements in a finite field derived from an elliptic curve. The hashing mechanism leverages message expansion and modular arithmetic to ensure cryptographic security.
      Parameters:
        `message` - The input message to be hashed into field elements.
        `count` - The number of resulting field elements to be produced during the hashing process.
      Returns:
        A two-dimensional array of BigInteger, where each entry represents a field element derived from the input message.