org.bouncycastle.math.ec.custom.gm
Class SM9P256V1Field
java.lang.Object
org.bouncycastle.math.ec.custom.gm.SM9P256V1Field
- public class SM9P256V1Field
- extends java.lang.Object
Prime-field arithmetic for the SM9 256-bit Barreto-Naehrig base field F_q
(GM/T 0044.5-2016), used by the G1 curve SM9P256V1Curve.
Unlike SM2P256V1Field (whose sparse prime admits a fast Solinas
reduction and stores elements in the ordinary residue representation), the SM9
BN prime is a general 256-bit prime, so this field keeps elements in
Montgomery form (a·R mod q, R = 2^256) and multiplies with a
Montgomery (SOS) reduction. Fixed-limb Nat256 arithmetic makes the
field operations constant time (no data-dependent branches beyond the standard
conditional subtractions), unlike the variable-length the
generic would use.
The constants n0 = -q^-1 mod 2^32 and R^2 mod q are derived from q at class
load (a micro-optimisation would inline them as int[] literals as SM2 does).
|
Method Summary |
static void |
add(int[] x,
int[] y,
int[] z)
|
static int[] |
fromBigInteger(java.math.BigInteger x)
|
static void |
inv(int[] x,
int[] z)
|
static boolean |
isZero(int[] x)
|
static void |
multiply(int[] x,
int[] y,
int[] z)
|
static void |
negate(int[] x,
int[] z)
|
static void |
square(int[] x,
int[] z)
|
static void |
squareN(int[] x,
int n,
int[] z)
|
static void |
subtract(int[] x,
int[] y,
int[] z)
|
static java.math.BigInteger |
toBigInteger(int[] xMont)
|
static void |
twice(int[] x,
int[] z)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
add
public static void add(int[] x,
int[] y,
int[] z)
subtract
public static void subtract(int[] x,
int[] y,
int[] z)
negate
public static void negate(int[] x,
int[] z)
twice
public static void twice(int[] x,
int[] z)
multiply
public static void multiply(int[] x,
int[] y,
int[] z)
square
public static void square(int[] x,
int[] z)
squareN
public static void squareN(int[] x,
int n,
int[] z)
fromBigInteger
public static int[] fromBigInteger(java.math.BigInteger x)
toBigInteger
public static java.math.BigInteger toBigInteger(int[] xMont)
inv
public static void inv(int[] x,
int[] z)
isZero
public static boolean isZero(int[] x)