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

org.bouncycastle.math.ec

## Class WNafUtil

- java.lang.Object
- - org.bouncycastle.math.ec.WNafUtil

-     public abstract class WNafUtil
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `PRECOMP_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WNafUtil()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `configureBasepoint(ECPoint p)`
    `static int[]` | `generateCompactNaf(java.math.BigInteger k)`
    `static int[]` | `generateCompactWindowNaf(int width, java.math.BigInteger k)`
    `static byte[]` | `generateJSF(java.math.BigInteger g, java.math.BigInteger h)`
    `static byte[]` | `generateNaf(java.math.BigInteger k)`
    `static byte[]` | `generateWindowNaf(int width, java.math.BigInteger k)` Computes the Window NAF (non-adjacent Form) of an integer.
    `static int` | `getNafWeight(java.math.BigInteger k)`
    `static int` | `getWindowSize(int bits)` Determine window width to use for a scalar multiplication of the given size.
    `static int` | `getWindowSize(int bits, int maxWidth)` Determine window width to use for a scalar multiplication of the given size.
    `static int` | `getWindowSize(int bits, int[] windowSizeCutoffs)` Determine window width to use for a scalar multiplication of the given size.
    `static int` | `getWindowSize(int bits, int[] windowSizeCutoffs, int maxWidth)` Determine window width to use for a scalar multiplication of the given size.
    `static WNafPreCompInfo` | `getWNafPreCompInfo(ECPoint p)`
    `static WNafPreCompInfo` | `getWNafPreCompInfo(PreCompInfo preCompInfo)`
    `static WNafPreCompInfo` | `precompute(ECPoint p, int minWidth, boolean includeNegated)`
    `static WNafPreCompInfo` | `precomputeWithPointMap(ECPoint p, ECPointMap pointMap, WNafPreCompInfo fromWNaf, boolean includeNegated)`

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

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

- - ### Field Detail

    - #### PRECOMP_NAME

          public static final java.lang.String PRECOMP_NAME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### WNafUtil

          public WNafUtil()

  - ### Method Detail

    - #### configureBasepoint

          public static void configureBasepoint(ECPoint p)

    - #### generateCompactNaf

          public static int[] generateCompactNaf(java.math.BigInteger k)

    - #### generateCompactWindowNaf

          public static int[] generateCompactWindowNaf(int width,
                                                       java.math.BigInteger k)

    - #### generateJSF

          public static byte[] generateJSF(java.math.BigInteger g,
                                           java.math.BigInteger h)

    - #### generateNaf

          public static byte[] generateNaf(java.math.BigInteger k)

    - #### generateWindowNaf

          public static byte[] generateWindowNaf(int width,
                                                 java.math.BigInteger k)

      Computes the Window NAF (non-adjacent Form) of an integer.
      Parameters:
        `width` - The width `w` of the Window NAF. The width is defined as the minimal number `w`, such that for any `w` consecutive digits in the resulting representation, at most one is non-zero.
        `k` - The integer of which the Window NAF is computed.
      Returns:
        The Window NAF of the given width, such that the following holds: `k = ∑i=0l-1 ki2i` , where the `ki` denote the elements of the returned `byte[]`.

    - #### getNafWeight

          public static int getNafWeight(java.math.BigInteger k)

    - #### getWNafPreCompInfo

          public static WNafPreCompInfo getWNafPreCompInfo(ECPoint p)

    - #### getWNafPreCompInfo

          public static WNafPreCompInfo getWNafPreCompInfo(PreCompInfo preCompInfo)

    - #### getWindowSize

          public static int getWindowSize(int bits)

      Determine window width to use for a scalar multiplication of the given size.
      Parameters:
        `bits` - the bit-length of the scalar to multiply by
      Returns:
        the window size to use

    - #### getWindowSize

          public static int getWindowSize(int bits,
                                          int maxWidth)

      Determine window width to use for a scalar multiplication of the given size.
      Parameters:
        `bits` - the bit-length of the scalar to multiply by
        `maxWidth` - the maximum window width to return
      Returns:
        the window size to use

    - #### getWindowSize

          public static int getWindowSize(int bits,
                                          int[] windowSizeCutoffs)

      Determine window width to use for a scalar multiplication of the given size.
      Parameters:
        `bits` - the bit-length of the scalar to multiply by
        `windowSizeCutoffs` - a monotonically increasing list of bit sizes at which to increment the window width
      Returns:
        the window size to use

    - #### getWindowSize

          public static int getWindowSize(int bits,
                                          int[] windowSizeCutoffs,
                                          int maxWidth)

      Determine window width to use for a scalar multiplication of the given size.
      Parameters:
        `bits` - the bit-length of the scalar to multiply by
        `windowSizeCutoffs` - a monotonically increasing list of bit sizes at which to increment the window width
        `maxWidth` - the maximum window width to return
      Returns:
        the window size to use

    - #### precompute

          public static WNafPreCompInfo precompute(ECPoint p,
                                                   int minWidth,
                                                   boolean includeNegated)

    - #### precomputeWithPointMap

          public static WNafPreCompInfo precomputeWithPointMap(ECPoint p,
                                                               ECPointMap pointMap,
                                                               WNafPreCompInfo fromWNaf,
                                                               boolean includeNegated)