Search in sources :

Example 6 with PolynomialGF2mSmallM

use of com.github.zhenwei.core.pqc.math.linearalgebra.PolynomialGF2mSmallM in project LinLong-Java by zhenwei1108.

the class McElieceCCA2Primitives method decryptionPrimitive.

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 };
}
Also used : GF2mField(com.github.zhenwei.core.pqc.math.linearalgebra.GF2mField) PolynomialGF2mSmallM(com.github.zhenwei.core.pqc.math.linearalgebra.PolynomialGF2mSmallM) GF2Matrix(com.github.zhenwei.core.pqc.math.linearalgebra.GF2Matrix) Permutation(com.github.zhenwei.core.pqc.math.linearalgebra.Permutation) GF2Vector(com.github.zhenwei.core.pqc.math.linearalgebra.GF2Vector)

Aggregations

GF2Matrix (com.github.zhenwei.core.pqc.math.linearalgebra.GF2Matrix)6 GF2mField (com.github.zhenwei.core.pqc.math.linearalgebra.GF2mField)6 Permutation (com.github.zhenwei.core.pqc.math.linearalgebra.Permutation)6 PolynomialGF2mSmallM (com.github.zhenwei.core.pqc.math.linearalgebra.PolynomialGF2mSmallM)6 GF2Vector (com.github.zhenwei.core.pqc.math.linearalgebra.GF2Vector)4 AsymmetricCipherKeyPair (com.github.zhenwei.core.crypto.AsymmetricCipherKeyPair)2 MaMaPe (com.github.zhenwei.core.pqc.math.linearalgebra.GoppaCode.MaMaPe)2 PolynomialRingGF2m (com.github.zhenwei.core.pqc.math.linearalgebra.PolynomialRingGF2m)1