Bouncy Castle Cryptography Library 1.87

org.bouncycastle.pqc.crypto.ntruprime
Class UtilsTest

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.bouncycastle.pqc.crypto.ntruprime.UtilsTest
All Implemented Interfaces:
junit.framework.Test

public class UtilsTest
extends junit.framework.TestCase

Tests for the arithmetic in NTRU Prime's Utils.

The polynomial products are computed by Karatsuba in int arithmetic and reduced once per coefficient, and getModFreeze() is a multiply-shift reduction, where both used to reduce every partial sum through a division routine. The KATs only reach the inputs their seeds produce, so these tests compare the arithmetic with a plain reference - a schoolbook product in long arithmetic and the % operator - for every parameter set, including the largest operands the callers can pass, which are what the int arithmetic's bounds depend on.


Constructor Summary
UtilsTest()
           
 
Method Summary
 void testCiphertextDiffMask()
           
 void testDecodeTruncated()
          A truncated encoding is rejected rather than decoded with the missing bytes taken as anything.
 void testEncodeDecode()
          Decoding agrees with the reference's Decode, read with unsigned bytes and long arithmetic, for random byte strings, which are mostly non-canonical encodings holding larger bytes than a valid one can, and for valid encodings; encoding agrees with the reference's Encode.
 void testInverseInRQ()
           
 void testInvertiblePolynomialInR3()
           
 void testModFreeze()
           
 void testMultiplicationInR3()
           
 void testMultiplicationInRQ()
           
 void testOneThirdInverseInRQ()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
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, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UtilsTest

public UtilsTest()
Method Detail

testModFreeze

public void testModFreeze()

testMultiplicationInRQ

public void testMultiplicationInRQ()

testMultiplicationInR3

public void testMultiplicationInR3()

testInverseInRQ

public void testInverseInRQ()

testOneThirdInverseInRQ

public void testOneThirdInverseInRQ()

testInvertiblePolynomialInR3

public void testInvertiblePolynomialInR3()

testCiphertextDiffMask

public void testCiphertextDiffMask()

testEncodeDecode

public void testEncodeDecode()
Decoding agrees with the reference's Decode, read with unsigned bytes and long arithmetic, for random byte strings, which are mostly non-canonical encodings holding larger bytes than a valid one can, and for valid encodings; encoding agrees with the reference's Encode.


testDecodeTruncated

public void testDecodeTruncated()
A truncated encoding is rejected rather than decoded with the missing bytes taken as anything.


Bouncy Castle Cryptography Library 1.87