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

org.bouncycastle.asn1.x9

## Class DHPublicKey

- java.lang.Object
- - org.bouncycastle.asn1.ASN1Object
  - - org.bouncycastle.asn1.x9.DHPublicKey

- All Implemented Interfaces:
    ASN1Encodable, Encodable

      public class DHPublicKey
      extends ASN1Object

  X9.42 definition of a DHPublicKey

           DHPublicKey ::= INTEGER

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DHPublicKey(java.math.BigInteger y)` Base constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static DHPublicKey` | `getInstance(ASN1TaggedObject obj, boolean explicit)` Return a DHPublicKey from the passed in tagged object.
    `static DHPublicKey` | `getInstance(java.lang.Object obj)` Return a DHPublicKey from the passed in object.
    `java.math.BigInteger` | `getY()` Return the public value Y for the key.
    `ASN1Primitive` | `toASN1Primitive()` Return an ASN.1 primitive representation of this object.

    - ### Methods inherited from class org.bouncycastle.asn1.ASN1Object

      `encodeTo, encodeTo, equals, getEncoded, getEncoded, hasEncodedTagValue, hashCode`

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

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

- - ### Constructor Detail

    - #### DHPublicKey

          public DHPublicKey(java.math.BigInteger y)

      Base constructor.
      Parameters:
        `y` - the public value Y.

  - ### Method Detail

    - #### getInstance

          public static DHPublicKey getInstance(ASN1TaggedObject obj,
                                                boolean explicit)

      Return a DHPublicKey from the passed in tagged object.
      Parameters:
        `obj` - a tagged object.
        `explicit` - true if the contents of the object is explictly tagged, false otherwise.
      Returns:
        a DHPublicKey

    - #### getInstance

          public static DHPublicKey getInstance(java.lang.Object obj)

      Return a DHPublicKey from the passed in object.
      Parameters:
        `obj` - an object for conversion or a byte[].
      Returns:
        a DHPublicKey

    - #### getY

          public java.math.BigInteger getY()

      Return the public value Y for the key.
      Returns:
        the Y value.

    - #### toASN1Primitive

          public ASN1Primitive toASN1Primitive()

      Return an ASN.1 primitive representation of this object.
      Specified by:
        `toASN1Primitive` in interface `ASN1Encodable`
      Specified by:
        `toASN1Primitive` in class `ASN1Object`
      Returns:
        an ASN1Integer.