public void testEncodeDecodeMod3Tight()
        {
            SecureRandom random = new SecureRandom();

            int[]  coeffs  = DenseTernaryPolynomial.GenerateRandom(1000, random).coeffs;
            byte[] data    = ArrayEncoder.EncodeMod3Tight(coeffs);
            int[]  coeffs2 = ArrayEncoder.DecodeMod3Tight(data, 1000);
            Assert.True(coeffs.SequenceEqual(coeffs2));
        }
        private void EncodeDecodeMod3Tight()
        {
            int[]  coeffs  = PolynomialGeneratorForTesting.generateRandom(1000).Coeffs;
            byte[] data    = ArrayEncoder.EncodeMod3Tight(coeffs);
            int[]  coeffs2 = ArrayEncoder.DecodeMod3Tight(data, 1000);

            if (!Compare.AreEqual(coeffs, coeffs2))
            {
                throw new Exception("ArrayEncoder EncodeDecodeMod3Tight test failed!");
            }
        }
Exemple #3
0
 /**
  * Reads data produced by {@link #toBinary3Tight()} from an input stream and converts it to a polynomial.
  *
  * @param is an input stream
  * @param N  number of coefficients
  * @return the decoded polynomial
  */
 public static IntegerPolynomial FromBinary3Tight(Stream stream, int N)
 {
     return(new IntegerPolynomial(ArrayEncoder.DecodeMod3Tight(stream, N)));
 }
Exemple #4
0
 /**
  * Converts a byte array produced by {@link #toBinary3Tight()} to a polynomial.
  *
  * @param b a byte array
  * @param N number of coefficients
  * @return the decoded polynomial
  */
 public static IntegerPolynomial FromBinary3Tight(byte[] b, int N)
 {
     return(new IntegerPolynomial(ArrayEncoder.DecodeMod3Tight(b, N)));
 }