org.bouncycastle.pqc.crypto.newhope.Reduce Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk15on Show documentation
Show all versions of bcprov-jdk15on Show documentation
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 and up.
The newest version!
package org.bouncycastle.pqc.crypto.newhope;
class Reduce
{
static final int QInv = 12287; // -inverse_mod(p,2^18)
static final int RLog = 18;
static final int RMask = (1 << RLog) - 1;
static short montgomery(int a)
{
int u = a * QInv;
u &= RMask;
u *= Params.Q;
u += a;
return (short)(u >>> RLog);
}
static short barrett(short a)
{
int t = a & 0xFFFF;
int u = (t * 5) >>> 16;
u *= Params.Q;
return (short)(t - u);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy