/** * Creates a new GF2Polynomial of the given <i>length</i> and random value. * * @param length the desired number of bits to store * @param rand SecureRandom to use for randomization */ public GF2Polynomial(int length, Random rand) { int l = length; if (l < 1) { l = 1; } blocks = ((l - 1) >> 5) + 1; value = new int[blocks]; len = l; randomize(rand); }
/** * Creates a new GF2Polynomial of the given <i>length</i> and random value. * * @param length the desired number of bits to store * @param rand SecureRandom to use for randomization */ public GF2Polynomial(int length, Random rand) { int l = length; if (l < 1) { l = 1; } blocks = ((l - 1) >> 5) + 1; value = new int[blocks]; len = l; randomize(rand); }
/** * Assign a random value to this GF2nPolynomialElement using the specified * source of randomness. * * @param rand the source of randomness */ private void randomize(Random rand) { polynomial.expandN(mDegree); polynomial.randomize(rand); }
/** * Assign a random value to this GF2nPolynomialElement using the specified * source of randomness. * * @param rand the source of randomness */ private void randomize(Random rand) { polynomial.expandN(mDegree); polynomial.randomize(rand); }
/** * Tests random polynomials of degree (n+1) until an irreducible is found * and stores the result in <i>field polynomial</i>. This can take very * long for huge degrees. * * @return true */ private boolean testRandom() { int l; boolean done = false; fieldPolynomial = new GF2Polynomial(mDegree + 1); l = 0; while (!done) { l++; fieldPolynomial.randomize(); fieldPolynomial.setBit(mDegree); fieldPolynomial.setBit(0); if (fieldPolynomial.isIrreducible()) { done = true; return done; } } return done; }
/** * Tests random polynomials of degree (n+1) until an irreducible is found * and stores the result in <i>field polynomial</i>. This can take very * long for huge degrees. * * @return true */ private boolean testRandom() { int l; boolean done = false; fieldPolynomial = new GF2Polynomial(mDegree + 1); l = 0; while (!done) { l++; fieldPolynomial.randomize(); fieldPolynomial.setBit(mDegree); fieldPolynomial.setBit(0); if (fieldPolynomial.isIrreducible()) { done = true; return done; } } return done; }