src/java.base/share/classes/sun/security/util/math/intpoly/IntegerPolynomial448.java
equal
deleted
inserted
replaced
24 */ |
24 */ |
25 |
25 |
26 package sun.security.util.math.intpoly; |
26 package sun.security.util.math.intpoly; |
27 |
27 |
28 import java.math.BigInteger; |
28 import java.math.BigInteger; |
|
29 |
|
30 /** |
|
31 * An IntegerFieldModuloP designed for use with the Curve448. |
|
32 * The representation uses 16 signed long values. |
|
33 */ |
29 |
34 |
30 public class IntegerPolynomial448 extends IntegerPolynomial { |
35 public class IntegerPolynomial448 extends IntegerPolynomial { |
31 |
36 |
32 private static final int POWER = 448; |
37 private static final int POWER = 448; |
33 private static final int NUM_LIMBS = 16; |
38 private static final int NUM_LIMBS = 16; |
36 = TWO.pow(POWER).subtract(TWO.pow(POWER / 2)) |
41 = TWO.pow(POWER).subtract(TWO.pow(POWER / 2)) |
37 .subtract(BigInteger.valueOf(1)); |
42 .subtract(BigInteger.valueOf(1)); |
38 |
43 |
39 public IntegerPolynomial448() { |
44 public IntegerPolynomial448() { |
40 super(BITS_PER_LIMB, NUM_LIMBS, MODULUS); |
45 super(BITS_PER_LIMB, NUM_LIMBS, MODULUS); |
|
46 } |
|
47 |
|
48 private void modReduceIn(long[] limbs, int index, long x) { |
|
49 limbs[index - NUM_LIMBS] += x; |
|
50 limbs[index - NUM_LIMBS / 2] += x; |
|
51 } |
|
52 |
|
53 @Override |
|
54 protected void finalCarryReduceLast(long[] limbs) { |
|
55 long carry = limbs[numLimbs - 1] >> bitsPerLimb; |
|
56 limbs[numLimbs - 1] -= carry << bitsPerLimb; |
|
57 modReduceIn(limbs, numLimbs, carry); |
41 } |
58 } |
42 |
59 |
43 @Override |
60 @Override |
44 protected void mult(long[] a, long[] b, long[] r) { |
61 protected void mult(long[] a, long[] b, long[] r) { |
45 |
62 |