use of com.github.zhenwei.core.pqc.math.linearalgebra.Vector in project LinLong-Java by zhenwei1108.
the class McElieceCCA2Primitives method encryptionPrimitive.
/**
* The McEliece encryption primitive.
*
* @param pubKey the public key
* @param m the message vector
* @param z the error vector
* @return <tt>m*G + z</tt>
*/
public static GF2Vector encryptionPrimitive(BCMcElieceCCA2PublicKey pubKey, GF2Vector m, GF2Vector z) {
GF2Matrix matrixG = pubKey.getG();
Vector mG = matrixG.leftMultiplyLeftCompactForm(m);
return (GF2Vector) mG.add(z);
}
use of com.github.zhenwei.core.pqc.math.linearalgebra.Vector in project LinLong-Java by zhenwei1108.
the class McElieceCCA2Primitives method encryptionPrimitive.
public static GF2Vector encryptionPrimitive(McElieceCCA2PublicKeyParameters pubKey, GF2Vector m, GF2Vector z) {
GF2Matrix matrixG = pubKey.getG();
Vector mG = matrixG.leftMultiplyLeftCompactForm(m);
return (GF2Vector) mG.add(z);
}
use of com.github.zhenwei.core.pqc.math.linearalgebra.Vector in project LinLong-Java by zhenwei1108.
the class McElieceCCA2Primitives method encryptionPrimitive.
/**
* The McEliece encryption primitive.
*
* @param pubKey the public key
* @param m the message vector
* @param z the error vector
* @return <tt>m*G + z</tt>
*/
public static GF2Vector encryptionPrimitive(McElieceCCA2PublicKeyParameters pubKey, GF2Vector m, GF2Vector z) {
GF2Matrix matrixG = pubKey.getG();
Vector mG = matrixG.leftMultiplyLeftCompactForm(m);
return (GF2Vector) mG.add(z);
}
use of com.github.zhenwei.core.pqc.math.linearalgebra.Vector in project LinLong-Java by zhenwei1108.
the class McElieceCipher method messageEncrypt.
/**
* Encrypt a plain text.
*
* @param input the plain text
* @return the cipher text
*/
public byte[] messageEncrypt(byte[] input) {
if (!forEncryption) {
throw new IllegalStateException("cipher initialised for decryption");
}
GF2Vector m = computeMessageRepresentative(input);
GF2Vector z = new GF2Vector(n, t, sr);
GF2Matrix g = ((McEliecePublicKeyParameters) key).getG();
Vector mG = g.leftMultiply(m);
GF2Vector mGZ = (GF2Vector) mG.add(z);
return mGZ.getEncoded();
}