Package com.goterl.lazysodium.interfaces
Class Ristretto255.RistrettoPoint
- java.lang.Object
-
- com.goterl.lazysodium.interfaces.Ristretto255.RistrettoPoint
-
- Enclosing interface:
- Ristretto255
public static final class Ristretto255.RistrettoPoint extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Ristretto255.RistrettoPointbase(LazySodium ls)Returns the base point of the Ristretto255 group.java.lang.Stringencode()Encodes the point using theLazySodium's associatedMessageEncoder.booleanequals(java.lang.Object o)static Ristretto255.RistrettoPointfromBytes(LazySodium ls, byte[] bytes)Creates a newRistretto255.RistrettoPointfrom the binary representation.static Ristretto255.RistrettoPointfromHex(LazySodium ls, java.lang.String hex)Creates a newRistretto255.RistrettoPointfrom the hexadecimal representation.static Ristretto255.RistrettoPointfromString(LazySodium ls, java.lang.String encoded)Creates a newRistretto255.RistrettoPointfrom the encoded representation, using theLazySodium's associatedMessageEncoder.inthashCode()static Ristretto255.RistrettoPointhashToPoint(LazySodium ls, byte[] input)Maps the input to aRistretto255.RistrettoPoint, by calculating the SHA-512 hash and mapping it to the Ristretto 255 group, usingcrypto_code_ristretto255_from_hash, i.e.static Ristretto255.RistrettoPointhashToPoint(LazySodium ls, java.lang.String encodedInput)Maps the encoded input to aRistretto255.RistrettoPoint, using theLazySodium's associatedMessageEncoder.Ristretto255.RistrettoPointminus(Ristretto255.RistrettoPoint other)Subtracts the given point from this point.Ristretto255.RistrettoPointnegate()Returns the additive inverse of this point.Ristretto255.RistrettoPointplus(Ristretto255.RistrettoPoint other)Adds the given point to this point.static Ristretto255.RistrettoPointrandom(LazySodium ls)Returns a random element of the Ristretto255 group.Ristretto255.RistrettoPointscalarMult(java.math.BigInteger n)Multiplies this point by a given scalar.Ristretto255.RistrettoPointtimes(java.math.BigInteger n)Multiplies this point by a given scalar.byte[]toBytes()Returns this point's canonical encoding.java.lang.StringtoHex()Returns the hexadecimal notation of this point's canonical encoding.java.lang.StringtoString()static Ristretto255.RistrettoPointzero(LazySodium ls)Returns the zero element (identity element) of the Ristretto255 group.
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toHex
public java.lang.String toHex()
Returns the hexadecimal notation of this point's canonical encoding.- Returns:
- the point in hexadecimal notation
-
toBytes
public byte[] toBytes()
Returns this point's canonical encoding.- Returns:
- the point
-
encode
public java.lang.String encode()
Encodes the point using theLazySodium's associatedMessageEncoder.- Returns:
- the encoded point
-
scalarMult
public Ristretto255.RistrettoPoint scalarMult(java.math.BigInteger n) throws SodiumException
Multiplies this point by a given scalar.- Parameters:
n- the scalar to multiply by- Returns:
- the multiplied point
- Throws:
SodiumException- if the result is zero
-
times
public Ristretto255.RistrettoPoint times(java.math.BigInteger n) throws SodiumException
Multiplies this point by a given scalar.- Parameters:
n- the scalar to multiply by- Returns:
- the multiplied point
- Throws:
SodiumException- if the result is zero
-
plus
public Ristretto255.RistrettoPoint plus(Ristretto255.RistrettoPoint other) throws SodiumException
Adds the given point to this point. Addition is commutative.- Parameters:
other- the point to add- Returns:
- the sum of both points
- Throws:
SodiumException- when the operation failed
-
minus
public Ristretto255.RistrettoPoint minus(Ristretto255.RistrettoPoint other) throws SodiumException
Subtracts the given point from this point.- Parameters:
other- the point to subtract- Returns:
- the difference of both points.
- Throws:
SodiumException- when the operation failed
-
negate
public Ristretto255.RistrettoPoint negate() throws SodiumException
Returns the additive inverse of this point. This is equivalent to0 - pwhere 0 denotes the additive identity.- Returns:
- the additive inverse
- Throws:
SodiumException- when the operation failed.
-
zero
public static Ristretto255.RistrettoPoint zero(LazySodium ls)
Returns the zero element (identity element) of the Ristretto255 group.- Parameters:
ls- theLazySodiuminstance- Returns:
- the identity element of Ristretto255
-
random
public static Ristretto255.RistrettoPoint random(LazySodium ls)
Returns a random element of the Ristretto255 group.- Parameters:
ls- theLazySodiuminstance- Returns:
- a random element of Ristretto255
-
base
public static Ristretto255.RistrettoPoint base(LazySodium ls) throws SodiumException
Returns the base point of the Ristretto255 group.- Parameters:
ls- theLazySodiuminstance- Returns:
- the base point of Ristretto255
- Throws:
SodiumException
-
fromHex
public static Ristretto255.RistrettoPoint fromHex(LazySodium ls, java.lang.String hex)
Creates a newRistretto255.RistrettoPointfrom the hexadecimal representation. The hexadecimal representation must be a valid canonical encoding.- Parameters:
ls- theLazySodiuminstancehex- the Ristretto255 canonical encoding in hexadecimal notation- Returns:
- the corresponding
Ristretto255.RistrettoPoint
-
fromString
public static Ristretto255.RistrettoPoint fromString(LazySodium ls, java.lang.String encoded)
Creates a newRistretto255.RistrettoPointfrom the encoded representation, using theLazySodium's associatedMessageEncoder. The decoded bytes must be a valid canonical encoding.- Parameters:
ls- theLazySodiuminstanceencoded- the encoded Ristretto255 point- Returns:
- the corresponding
Ristretto255.RistrettoPoint
-
fromBytes
public static Ristretto255.RistrettoPoint fromBytes(LazySodium ls, byte[] bytes)
Creates a newRistretto255.RistrettoPointfrom the binary representation. The binary representation must be a valid canonical encoding.- Parameters:
ls- theLazySodiuminstancebytes- the Ristretto255 canonical encoding- Returns:
- the corresponding
Ristretto255.RistrettoPoint
-
hashToPoint
public static Ristretto255.RistrettoPoint hashToPoint(LazySodium ls, java.lang.String encodedInput) throws SodiumException
Maps the encoded input to aRistretto255.RistrettoPoint, using theLazySodium's associatedMessageEncoder. The resulting bytes are hashed using SHA-512 and mapped to the Ristretto 255 group, usingcrypto_code_ristretto255_from_hash, i.e. the standard hash-to-group algorithm.- Parameters:
ls- theLazySodiuminstanceencodedInput- the encoded bytes- Returns:
- the mapped
Ristretto255.RistrettoPoint - Throws:
SodiumException- if the mapping failed
-
hashToPoint
public static Ristretto255.RistrettoPoint hashToPoint(LazySodium ls, byte[] input) throws SodiumException
Maps the input to aRistretto255.RistrettoPoint, by calculating the SHA-512 hash and mapping it to the Ristretto 255 group, usingcrypto_code_ristretto255_from_hash, i.e. the standard hash-to-group algorithm.- Parameters:
ls- theLazySodiuminstanceinput- the input bytes- Returns:
- the mapped
Ristretto255.RistrettoPoint - Throws:
SodiumException- if the mapping failed
-
-