public McEliecePrivateKey(int n, int k, GF2mField field, PolynomialGF2mSmallM goppaPoly, Permutation p1, Permutation p2, GF2Matrix sInv) { this.n = n; this.k = k; this.encField = field.getEncoded(); this.encGp = goppaPoly.getEncoded(); this.encSInv = sInv.getEncoded(); this.encP1 = p1.getEncoded(); this.encP2 = p2.getEncoded(); }
/** * Create the one element. * * @param f the finite field * @return the one element in the given finite field */ public static GF2nPolynomialElement ONE(GF2nPolynomialField f) { GF2Polynomial polynomial = new GF2Polynomial(f.getDegree(), new int[]{1}); return new GF2nPolynomialElement(f, polynomial); }
public McElieceCCA2PrivateKey(int n, int k, GF2mField field, PolynomialGF2mSmallM goppaPoly, Permutation p, AlgorithmIdentifier digest) { this.n = n; this.k = k; this.encField = field.getEncoded(); this.encGp = goppaPoly.getEncoded(); this.encP = p.getEncoded(); this.digest = digest; }
/** * Copy constructor. * * @param gf2n the field */ public GF2nONBElement(GF2nONBElement gf2n) { mField = gf2n.mField; mDegree = mField.getDegree(); mLength = ((GF2nONBField)mField).getONBLength(); mBit = ((GF2nONBField)mField).getONBBit(); mPol = new long[mLength]; assign(gf2n.getElement()); }
/** * Compute the square root of this element. */ public void squareRootThis() { // increase performance polynomial.expandN((mDegree << 1) + 32); polynomial.reduceN(); for (int i = 0; i < mField.getDegree() - 1; i++) { squareThis(); } }
/** * @return the hash code of this key */ public int hashCode() { int code = params.getK(); code = code * 37 + params.getN(); code = code * 37 + params.getField().hashCode(); code = code * 37 + params.getGoppaPoly().hashCode(); code = code * 37 + params.getP1().hashCode(); code = code * 37 + params.getP2().hashCode(); return code * 37 + params.getSInv().hashCode(); }
/** * Create a new random GF2nPolynomialElement using the given field and * source of randomness. * * @param f the GF2nField to use * @param rand the source of randomness */ public GF2nPolynomialElement(GF2nPolynomialField f, Random rand) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(mDegree); randomize(rand); }
/** * Creates a new GF2nPolynomialElement using the given field and Bitstring. * * @param f the GF2nPolynomialField to use * @param bs the desired value as Bitstring */ public GF2nPolynomialElement(GF2nPolynomialField f, GF2Polynomial bs) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(bs); polynomial.expandN(mDegree); }
/** * Create the zero element. * * @param gf2n the finite field * @return the zero element in the given finite field */ public static GF2nONBElement ZERO(GF2nONBField gf2n) { long[] polynomial = new long[gf2n.getONBLength()]; return new GF2nONBElement(gf2n, polynomial); }
/** * Returns the fieldpolynomial as a new Bitstring. * * @return a copy of the fieldpolynomial as a new Bitstring */ public final GF2Polynomial getFieldPolynomial() { if (fieldPolynomial == null) { computeFieldPolynomial(); } return new GF2Polynomial(fieldPolynomial); }
/** * @param input an int arary * @return the int array as hex string */ public static String toHexString(int[] input) { return ByteUtils.toHexString(BigEndianConversions.toByteArray(input)); }
/** * Create the zero element. * * @param f the finite field * @return the zero element in the given finite field */ public static GF2nPolynomialElement ZERO(GF2nPolynomialField f) { GF2Polynomial polynomial = new GF2Polynomial(f.getDegree()); return new GF2nPolynomialElement(f, polynomial); }
/** * Create the zero element. * * @param gf2n the finite field * @return the zero element in the given finite field */ public static GF2nONBElement ZERO(GF2nONBField gf2n) { long[] polynomial = new long[gf2n.getONBLength()]; return new GF2nONBElement(gf2n, polynomial); }
/** * Returns the fieldpolynomial as a new Bitstring. * * @return a copy of the fieldpolynomial as a new Bitstring */ public final GF2Polynomial getFieldPolynomial() { if (fieldPolynomial == null) { computeFieldPolynomial(); } return new GF2Polynomial(fieldPolynomial); }
/** * Create the one element. * * @param f the finite field * @return the one element in the given finite field */ public static GF2nPolynomialElement ONE(GF2nPolynomialField f) { GF2Polynomial polynomial = new GF2Polynomial(f.getDegree(), new int[]{1}); return new GF2nPolynomialElement(f, polynomial); }
/** * Create the zero element. * * @param f the finite field * @return the zero element in the given finite field */ public static GF2nPolynomialElement ZERO(GF2nPolynomialField f) { GF2Polynomial polynomial = new GF2Polynomial(f.getDegree()); return new GF2nPolynomialElement(f, polynomial); }