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

org.bouncycastle.pqc.crypto.mayo

## Class MayoRetryTest

- java.lang.Object
- - junit.framework.Assert
  - - junit.framework.TestCase
    - - org.bouncycastle.pqc.crypto.mayo.MayoRetryTest

- All Implemented Interfaces:
    junit.framework.Test

      public class MayoRetryTest
      extends junit.framework.TestCase

  Regression test for the retry path in `MayoSigner.generateSignature(byte[])`.

  The retry loop `for (int ctr = 0; ctr <= 255; ctr++)` accumulates three `long[]` buffers (`Mtmp`, `Pv`, `vPv`) with mulAdd-style (accumulate-into) calls. All three are allocated once before the loop, so on a retry they must be re-zeroed. The reference C implementation (MAYO-C `compute_M_and_VPV`) declares `Pv` inside the function as `uint64_t Pv[...] = {0}`, i.e. fresh per attempt, while `mayo_sign` memsets `Mtmp` and the `VP1V` target on failure.

  The Java port hoisted `Pv`'s allocation out of the loop. Without clearing `Pv` on retry, the second attempt computes `Pv = P1*V0^T + P1*V1^T` (stale data carried over), corrupting the signature. The KAT vectors never trigger a retry, so this is invisible to the KAT battery.

  This test forces exactly one retry by overriding `sampleSolution` to fail the first attempt, then asserts the produced signature still verifies.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MayoRetryTest()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `testRetryProducesValidSignature()`

    - ### Methods inherited from class junit.framework.TestCase

      `assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString`

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

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

- - ### Constructor Detail

    - #### MayoRetryTest

          public MayoRetryTest()

  - ### Method Detail

    - #### testRetryProducesValidSignature

          public void testRetryProducesValidSignature()
                                               throws java.lang.Exception

      Throws:
        `java.lang.Exception`