java.lang.Object
org.bouncycastle.pqc.crypto.mlkem.Reduce

class Reduceextends Object
Polynomial reduction operations for ML-KEM cryptography. Provides Montgomery reduction and Barrett reduction for polynomial arithmetic.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Both reductions are static and the class holds no fields, so an instance carries nothing; it exists only to give the helper class a documented entry point.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    static short
    barretReduce(short a)
    Barrett-reduces a coefficient into the range -q/2 to q/2.
    static short
    conditionalSubQ(short a)
    Adds q to a negative coefficient to make it non-negative.
    static short
    Scales a wide value down into the Montgomery representation.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Reduce

      Reduce()
      Both reductions are static and the class holds no fields, so an instance carries nothing; it exists only to give the helper class a documented entry point.
  • Method Details

    • montgomeryReduce

      public static short montgomeryReduce(int a)
      Scales a wide value down into the Montgomery representation.
      Parameters:
      a - the value to reduce, wide enough to hold the intermediate product
      Returns:
      a scaled down into the Montgomery representation, as a short
    • barretReduce

      public static short barretReduce(short a)
      Barrett-reduces a coefficient into the range -q/2 to q/2.
      Parameters:
      a - the coefficient to centre into the range -q/2 to q/2
      Returns:
      the reduced coefficient, as a short
    • conditionalSubQ

      public static short conditionalSubQ(short a)
      Adds q to a negative coefficient to make it non-negative.
      Parameters:
      a - the coefficient that may need q subtracting to become non-negative
      Returns:
      a if it was already non-negative, otherwise a plus q, as a short