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

org.bouncycastle.pqc.math.ntru.polynomial.ModularResultant Maven / Gradle / Ivy

Go to download

The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8.

There is a newer version: 1.79
Show newest version
package org.bouncycastle.pqc.math.ntru.polynomial;

import java.math.BigInteger;

import org.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 combineRho(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