Search in sources :

Example 1 with Vector

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

Example 2 with Vector

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

Example 3 with Vector

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

Example 4 with Vector

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

Aggregations

GF2Matrix (com.github.zhenwei.core.pqc.math.linearalgebra.GF2Matrix)4 GF2Vector (com.github.zhenwei.core.pqc.math.linearalgebra.GF2Vector)4 Vector (com.github.zhenwei.core.pqc.math.linearalgebra.Vector)4