java.lang.Object
net.i2p.crypto.eddsa.math.ed25519.Ed25519ScalarOps
- All Implemented Interfaces:
Serializable, ScalarOps
Class for reducing a huge integer modulo the group order q and doing a combined multiply plus add plus reduce operation.
$q = 2^{252} + 27742317777372353535851937790883648493$.
- See Also:
Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionbyte[]multiplyAndAdd(byte[] a, byte[] b, byte[] c) $(ab+c) \bmod q$byte[]reduce(byte[] s) Reduction modulo the group order $q$.
Constructor Details
Ed25519ScalarOps
public Ed25519ScalarOps()Constructor. The reduction and fused multiply-add are pure arithmetic over their arguments, so an instance carries no state.
Method Details
reduce
public byte[] reduce(byte[] s) Reduction modulo the group order $q$.Input: $s[0]+256*s[1]+\dots+256^{63}*s[63] = s$
Output: $s[0]+256*s[1]+\dots+256^{31}*s[31] = s \bmod q$ where $q = 2^{252} + 27742317777372353535851937790883648493$.
multiplyAndAdd
public byte[] multiplyAndAdd(byte[] a, byte[] b, byte[] c) $(ab+c) \bmod q$Input:
- $a[0]+256*a[1]+\dots+256^{31}*a[31] = a$
- $b[0]+256*b[1]+\dots+256^{31}*b[31] = b$
- $c[0]+256*c[1]+\dots+256^{31}*c[31] = c$
Output: $result[0]+256*result[1]+\dots+256^{31}*result[31] = (ab+c) \bmod q$ where $q = 2^{252} + 27742317777372353535851937790883648493$.
See the comments in
reduce(byte[])for an explanation of the algorithm.- Specified by:
multiplyAndAddin interfaceScalarOps- Parameters:
a- the first multiplicand, a scalar in little-endian formb- the second multiplicand, a scalar in little-endian formc- the addend, a scalar in little-endian form- Returns:
- $(a*b + c) \bmod l$