diff options
author | Roberto Tyley <roberto.tyley@gmail.com> | 2014-07-15 01:38:01 +0400 |
---|---|---|
committer | Roberto Tyley <roberto.tyley@gmail.com> | 2014-07-26 11:23:17 +0400 |
commit | 7cb752aaf746dc0b473afeb9e892b7fbc12666c5 (patch) | |
tree | cc4f91ddc18332b5adbe82e3fcb040d976c90105 /core/src/test/java/org/spongycastle/pqc/math/ntru/polynomial/test/PolynomialGenerator.java | |
parent | 551830f8ea5177042af2c7dd1fc90888bc67387d (diff) |
Execute become-spongy.sh
https://github.com/rtyley/spongycastle/blob/3040af/become-spongy.sh
Diffstat (limited to 'core/src/test/java/org/spongycastle/pqc/math/ntru/polynomial/test/PolynomialGenerator.java')
-rw-r--r-- | core/src/test/java/org/spongycastle/pqc/math/ntru/polynomial/test/PolynomialGenerator.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/core/src/test/java/org/spongycastle/pqc/math/ntru/polynomial/test/PolynomialGenerator.java b/core/src/test/java/org/spongycastle/pqc/math/ntru/polynomial/test/PolynomialGenerator.java new file mode 100644 index 00000000..a30fea4d --- /dev/null +++ b/core/src/test/java/org/spongycastle/pqc/math/ntru/polynomial/test/PolynomialGenerator.java @@ -0,0 +1,27 @@ +package org.spongycastle.pqc.math.ntru.polynomial.test; + +import java.util.Random; + +import org.spongycastle.pqc.math.ntru.polynomial.IntegerPolynomial; + +public class PolynomialGenerator +{ + /** + * Creates a random polynomial with <code>N</code> coefficients + * between <code>0</code> and <code>q-1</code>. + * + * @param N length of the polynomial + * @param q coefficients will all be below this number + * @return a random polynomial + */ + public static IntegerPolynomial generateRandom(int N, int q) + { + Random rng = new Random(); + int[] coeffs = new int[N]; + for (int i = 0; i < N; i++) + { + coeffs[i] = rng.nextInt(q); + } + return new IntegerPolynomial(coeffs); + } +}
\ No newline at end of file |