32 lines
1.8 KiB
Java
32 lines
1.8 KiB
Java
package org.bouncycastle.pqc.crypto.mceliece;
|
|
|
|
import org.bouncycastle.pqc.math.linearalgebra.GF2Matrix;
|
|
import org.bouncycastle.pqc.math.linearalgebra.GF2Vector;
|
|
import org.bouncycastle.pqc.math.linearalgebra.GF2mField;
|
|
import org.bouncycastle.pqc.math.linearalgebra.GoppaCode;
|
|
import org.bouncycastle.pqc.math.linearalgebra.Permutation;
|
|
import org.bouncycastle.pqc.math.linearalgebra.PolynomialGF2mSmallM;
|
|
|
|
/* loaded from: classes6.dex */
|
|
final class McElieceCCA2Primitives {
|
|
public static GF2Vector encryptionPrimitive(McElieceCCA2PublicKeyParameters mcElieceCCA2PublicKeyParameters, GF2Vector gF2Vector, GF2Vector gF2Vector2) {
|
|
return (GF2Vector) mcElieceCCA2PublicKeyParameters.getG().leftMultiplyLeftCompactForm(gF2Vector).add(gF2Vector2);
|
|
}
|
|
|
|
public static GF2Vector[] decryptionPrimitive(McElieceCCA2PrivateKeyParameters mcElieceCCA2PrivateKeyParameters, GF2Vector gF2Vector) {
|
|
int k = mcElieceCCA2PrivateKeyParameters.getK();
|
|
Permutation p = mcElieceCCA2PrivateKeyParameters.getP();
|
|
GF2mField field = mcElieceCCA2PrivateKeyParameters.getField();
|
|
PolynomialGF2mSmallM goppaPoly = mcElieceCCA2PrivateKeyParameters.getGoppaPoly();
|
|
GF2Matrix h = mcElieceCCA2PrivateKeyParameters.getH();
|
|
PolynomialGF2mSmallM[] qInv = mcElieceCCA2PrivateKeyParameters.getQInv();
|
|
GF2Vector gF2Vector2 = (GF2Vector) gF2Vector.multiply(p.computeInverse());
|
|
GF2Vector syndromeDecode = GoppaCode.syndromeDecode((GF2Vector) h.rightMultiply(gF2Vector2), field, goppaPoly, qInv);
|
|
GF2Vector gF2Vector3 = (GF2Vector) ((GF2Vector) gF2Vector2.add(syndromeDecode)).multiply(p);
|
|
return new GF2Vector[]{gF2Vector3.extractRightVector(k), (GF2Vector) syndromeDecode.multiply(p)};
|
|
}
|
|
|
|
private McElieceCCA2Primitives() {
|
|
}
|
|
}
|