Debian Codegraph @

ext/ed25519_jruby/net/i2p/crypto/eddsa/math/bigint/BigIntegerScalarOps.java

raw symbols SCIP
1 /**
2 * EdDSA-Java by str4d
3 *
4 * To the extent possible under law, the person who associated CC0 with
5 * EdDSA-Java has waived all copyright and related or neighboring rights
6 * to EdDSA-Java.
7 *
8 * You should have received a copy of the CC0 legalcode along with this
9 * work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
10 *
11 */
12 package net.i2p.crypto.eddsa.math.bigint;
13
14 import java.math.BigInteger;
15
16 import net.i2p.crypto.eddsa.math.Field;
17 import net.i2p.crypto.eddsa.math.ScalarOps;
18
19 public class BigIntegerScalarOps implements ScalarOps {
20 private final BigInteger l;
21 private final BigIntegerLittleEndianEncoding enc;
22
23 public BigIntegerScalarOps(Field f, BigInteger l) {
24 this.l = l;
25 enc = new BigIntegerLittleEndianEncoding();
26 enc.setField(f);
27 }
28
29 public byte[] reduce(byte[] s) {
30 return enc.encode(enc.toBigInteger(s).mod(l));
31 }
32
33 public byte[] multiplyAndAdd(byte[] a, byte[] b, byte[] c) {
34 return enc.encode(enc.toBigInteger(a).multiply(enc.toBigInteger(b)).add(enc.toBigInteger(c)).mod(l));
35 }
36
37 }