/** * @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.getP().hashCode(); return code * 37 + params.getH().hashCode(); }
/** * @return the matrix used to compute square roots in <tt>(GF(2^m))^t</tt> */ public PolynomialGF2mSmallM[] getQInv() { return params.getQInv(); }
public void initCipherDecrypt(McElieceCCA2PrivateKeyParameters privKey) { this.messDigest = privKey.getParameters().getDigest(); n = privKey.getN(); k = privKey.getK(); t = privKey.getT(); }
public static GF2Vector[] decryptionPrimitive( McElieceCCA2PrivateKeyParameters privKey, GF2Vector c) { // obtain values from private key int k = privKey.getK(); Permutation p = privKey.getP(); GF2mField field = privKey.getField(); PolynomialGF2mSmallM gp = privKey.getGoppaPoly(); GF2Matrix h = privKey.getH(); PolynomialGF2mSmallM[] q = privKey.getQInv(); // compute inverse permutation P^-1 Permutation pInv = p.computeInverse(); // multiply c with permutation P^-1 GF2Vector cPInv = (GF2Vector)c.multiply(pInv); // compute syndrome of cP^-1 GF2Vector syndVec = (GF2Vector)h.rightMultiply(cPInv); // decode syndrome GF2Vector errors = GoppaCode.syndromeDecode(syndVec, field, gp, q); GF2Vector mG = (GF2Vector)cPInv.add(errors); // multiply codeword and error vector with P mG = (GF2Vector)mG.multiply(p); errors = (GF2Vector)errors.multiply(p); // extract plaintext vector (last k columns of mG) GF2Vector m = mG.extractRightVector(k); // return vectors return new GF2Vector[]{m, errors}; }
public void initCipherDecrypt(McElieceCCA2PrivateKeyParameters privKey) { this.messDigest = privKey.getParameters().getDigest(); n = privKey.getN(); t = privKey.getT(); }
/** * @return the length of the code */ public int getN() { return params.getN(); }
public PrivateKey generatePrivate(PrivateKeyInfo pki) throws IOException { // get the inner type inside the BIT STRING ASN1Primitive innerType = pki.parsePrivateKey().toASN1Primitive(); McElieceCCA2PrivateKey key = McElieceCCA2PrivateKey.getInstance(innerType); return new BCMcElieceCCA2PrivateKey(new McElieceCCA2PrivateKeyParameters(key.getN(), key.getK(), key.getField(), key.getGoppaPoly(), key.getP(), null)); }
/** * @return the irreducible Goppa polynomial */ public PolynomialGF2mSmallM getGoppaPoly() { return params.getGoppaPoly(); }
/** * @return the finite field */ public GF2mField getField() { return params.getField(); }
/** * @return the canonical check matrix */ public GF2Matrix getH() { return params.getH(); }
/** * @return the permutation vector */ public Permutation getP() { return params.getP(); }
/** * @return the dimension of the code */ public int getK() { return params.getK(); }
try McElieceCCA2PrivateKey privateKey = new McElieceCCA2PrivateKey(getN(), getK(), getField(), getGoppaPoly(), getP(), Utils.getDigAlgId(params.getDigest())); AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PQCObjectIdentifiers.mcElieceCca2);
public void initCipherDecrypt(McElieceCCA2PrivateKeyParameters privKey) { this.messDigest = privKey.getParameters().getDigest(); n = privKey.getN(); k = privKey.getK(); t = privKey.getT(); }
public int getKeySize(McElieceCCA2KeyParameters key) throws IllegalArgumentException { if (key instanceof McElieceCCA2PublicKeyParameters) { return ((McElieceCCA2PublicKeyParameters)key).getN(); } if (key instanceof McElieceCCA2PrivateKeyParameters) { return ((McElieceCCA2PrivateKeyParameters)key).getN(); } throw new IllegalArgumentException("unsupported type"); }
return new BCMcElieceCCA2PrivateKey(new McElieceCCA2PrivateKeyParameters(key.getN(), key.getK(), key.getField(), key.getGoppaPoly(), key.getP(), Utils.getDigest(key.getDigest()).getAlgorithmName()));
/** * @return the degree of the Goppa polynomial (error correcting capability) */ public int getT() { return params.getGoppaPoly().getDegree(); }