Class Ristretto255.RistrettoPoint
java.lang.Object
com.codevasp.lazysodium.interfaces.Ristretto255.RistrettoPoint
- Enclosing interface:
- Ristretto255
-
Method Summary
Modifier and TypeMethodDescriptionstatic Ristretto255.RistrettoPointbase(LazySodium ls) Returns the base point of the Ristretto255 group.encode()Encodes the point using theLazySodium's associatedMessageEncoder.booleanstatic Ristretto255.RistrettoPointfromBytes(LazySodium ls, byte[] bytes) Creates a newRistretto255.RistrettoPointfrom the binary representation.static Ristretto255.RistrettoPointfromHex(LazySodium ls, String hex) Creates a newRistretto255.RistrettoPointfrom the hexadecimal representation.static Ristretto255.RistrettoPointfromString(LazySodium ls, 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. the standard hash-to-group algorithm.static Ristretto255.RistrettoPointhashToPoint(LazySodium ls, String encodedInput) Maps the encoded input to aRistretto255.RistrettoPoint, using theLazySodium's associatedMessageEncoder.minus(Ristretto255.RistrettoPoint other) Subtracts the given point from this point.negate()Returns the additive inverse of this point.plus(Ristretto255.RistrettoPoint other) Adds the given point to this point.static Ristretto255.RistrettoPointrandom(LazySodium ls) Returns a random element of the Ristretto255 group.Multiplies this point by a given scalar.times(BigInteger n) Multiplies this point by a given scalar.byte[]toBytes()Returns this point's canonical encoding.toHex()Returns the hexadecimal notation of this point's canonical encoding.toString()static Ristretto255.RistrettoPointzero(LazySodium ls) Returns the zero element (identity element) of the Ristretto255 group.
-
Method Details
-
zero
Returns the zero element (identity element) of the Ristretto255 group.- Parameters:
ls- theLazySodiuminstance- Returns:
- the identity element of Ristretto255
-
random
Returns a random element of the Ristretto255 group.- Parameters:
ls- theLazySodiuminstance- Returns:
- a random element of Ristretto255
-
base
Returns the base point of the Ristretto255 group.- Parameters:
ls- theLazySodiuminstance- Returns:
- the base point of Ristretto255
- Throws:
SodiumException
-
fromHex
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
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
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, 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
-
toString
-
equals
-
hashCode
public int hashCode() -
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
Encodes the point using theLazySodium's associatedMessageEncoder.- Returns:
- the encoded point
-
scalarMult
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
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
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
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
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.
-