Skip to content

Commit 4625342

Browse files
committed
Pulled out constant
1 parent 4b67b31 commit 4625342

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/net/i2p/crypto/eddsa/math/ed25519/Ed25519ScalarOps.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import net.i2p.crypto.eddsa.math.ScalarOps;
55

66
public class Ed25519ScalarOps implements ScalarOps {
7+
private static final BigInteger n2097151 = BigInteger.valueOf(2097151);
8+
79
private BigInteger load_3(byte[] in, int offset) {
810
BigInteger result = new BigInteger(1, new byte[] {in[offset]});
911
result = result.or(new BigInteger(1, new byte[] {in[offset+1]}).shiftLeft(8));
@@ -28,8 +30,6 @@ private BigInteger load_4(byte[] in, int offset) {
2830
* where l = 2^252 + 27742317777372353535851937790883648493.
2931
*/
3032
public byte[] reduce(byte[] s) {
31-
BigInteger n2097151 = BigInteger.valueOf(2097151);
32-
3333
long s0 = n2097151.and(load_3(s, 0)).longValue();
3434
long s1 = n2097151.and(load_4(s, 2).shiftRight(5)).longValue();
3535
long s2 = n2097151.and(load_3(s, 5).shiftRight(2)).longValue();
@@ -284,8 +284,6 @@ public byte[] reduce(byte[] s) {
284284
* where l = 2^252 + 27742317777372353535851937790883648493.
285285
*/
286286
public byte[] multiplyAndAdd(byte[] a, byte[] b, byte[] c) {
287-
BigInteger n2097151 = BigInteger.valueOf(2097151);
288-
289287
long a0 = n2097151.and(load_3(a, 0)).longValue();;
290288
long a1 = n2097151.and(load_4(a, 2).shiftRight(5)).longValue();
291289
long a2 = n2097151.and(load_3(a, 5).shiftRight(2)).longValue();

0 commit comments

Comments
 (0)