All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fitbur.bouncycastle.pqc.math.ntru.polynomial.ModularResultant Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.fitbur.bouncycastle.pqc.math.ntru.polynomial;

import java.math.BigInteger;

import com.fitbur.bouncycastle.pqc.math.ntru.euclid.BigIntEuclidean;

/**
 * A resultant modulo a BigInteger
 */
public class ModularResultant
    extends Resultant
{
    BigInteger modulus;

    ModularResultant(BigIntPolynomial rho, BigInteger res, BigInteger modulus)
    {
        super(rho, res);
        this.modulus = modulus;
    }

    /**
     * Calculates a rho modulo m1*m2 from
     * two resultants whose rhos are modulo m1 and m2.
*
res is set to null. * * @param modRes1 * @param modRes2 * @return rho modulo modRes1.modulus * modRes2.modulus, and null for res. */ static ModularResultant com.fitburbineRho(ModularResultant modRes1, ModularResultant modRes2) { BigInteger mod1 = modRes1.modulus; BigInteger mod2 = modRes2.modulus; BigInteger prod = mod1.multiply(mod2); BigIntEuclidean er = BigIntEuclidean.calculate(mod2, mod1); BigIntPolynomial rho1 = (BigIntPolynomial)modRes1.rho.clone(); rho1.mult(er.x.multiply(mod2)); BigIntPolynomial rho2 = (BigIntPolynomial)modRes2.rho.clone(); rho2.mult(er.y.multiply(mod1)); rho1.add(rho2); rho1.mod(prod); return new ModularResultant(rho1, null, prod); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy