Search in sources :

Example 1 with SparseTernaryPolynomial

use of com.github.zhenwei.core.pqc.math.ntru.polynomial.SparseTernaryPolynomial in project LinLong-Java by zhenwei1108.

the class NTRUEngine method generateBlindingPoly.

/**
 * Deterministically generates a blinding polynomial from a seed and a message representative.
 *
 * @param seed
 * @param M    message representative
 * @return a blinding polynomial
 */
private Polynomial generateBlindingPoly(byte[] seed, byte[] M) {
    IndexGenerator ig = new IndexGenerator(seed, params);
    if (params.polyType == NTRUParameters.TERNARY_POLYNOMIAL_TYPE_PRODUCT) {
        SparseTernaryPolynomial r1 = new SparseTernaryPolynomial(generateBlindingCoeffs(ig, params.dr1));
        SparseTernaryPolynomial r2 = new SparseTernaryPolynomial(generateBlindingCoeffs(ig, params.dr2));
        SparseTernaryPolynomial r3 = new SparseTernaryPolynomial(generateBlindingCoeffs(ig, params.dr3));
        return new ProductFormPolynomial(r1, r2, r3);
    } else {
        int dr = params.dr;
        boolean sparse = params.sparse;
        int[] r = generateBlindingCoeffs(ig, dr);
        if (sparse) {
            return new SparseTernaryPolynomial(r);
        } else {
            return new DenseTernaryPolynomial(r);
        }
    }
}
Also used : ProductFormPolynomial(com.github.zhenwei.core.pqc.math.ntru.polynomial.ProductFormPolynomial) SparseTernaryPolynomial(com.github.zhenwei.core.pqc.math.ntru.polynomial.SparseTernaryPolynomial) DenseTernaryPolynomial(com.github.zhenwei.core.pqc.math.ntru.polynomial.DenseTernaryPolynomial)

Aggregations

DenseTernaryPolynomial (com.github.zhenwei.core.pqc.math.ntru.polynomial.DenseTernaryPolynomial)1 ProductFormPolynomial (com.github.zhenwei.core.pqc.math.ntru.polynomial.ProductFormPolynomial)1 SparseTernaryPolynomial (com.github.zhenwei.core.pqc.math.ntru.polynomial.SparseTernaryPolynomial)1