44import net .i2p .crypto .eddsa .math .ScalarOps ;
55
66public 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