Package com.goterl.lazysodium.interfaces
Class Ed25519.Ed25519Point
java.lang.Object
com.goterl.lazysodium.interfaces.Ed25519.Ed25519Point
- Enclosing interface:
Ed25519
-
Method Summary
Modifier and TypeMethodDescriptionstatic Ed25519.Ed25519Pointbase(LazySodium ls) Returns the base point of the Ed25519 group.encode()Encodes the point using theLazySodium's associatedMessageEncoder.booleanstatic Ed25519.Ed25519PointfromBytes(LazySodium ls, byte[] bytes) Creates a newEd25519.Ed25519Pointfrom the binary representation.static Ed25519.Ed25519PointfromHex(LazySodium ls, String hex) Creates a newEd25519.Ed25519Pointfrom the hexadecimal representation.static Ed25519.Ed25519PointfromString(LazySodium ls, String encoded) Creates a newEd25519.Ed25519Pointfrom the encoded representation, using theLazySodium's associatedMessageEncoder.inthashCode()static Ed25519.Ed25519PointhashToPoint(LazySodium ls, byte[] input) Maps the input to aEd25519.Ed25519Point, by calculating the SHA-512 hash and mapping it to the Ed25519 group, usingcrypto_code_ed25519_from_uniform, i.e.static Ed25519.Ed25519PointhashToPoint(LazySodium ls, String encodedInput) minus(Ed25519.Ed25519Point other) Subtracts the given point from this point.negate()Returns the additive inverse of this point.plus(Ed25519.Ed25519Point other) Adds the given point to this point.static Ed25519.Ed25519Pointrandom(LazySodium ls) Returns a random element of the Ed25519 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 Ed25519.Ed25519Pointzero(LazySodium ls) Returns the zero element (identity element) of the Ed25519 group.
-
Method Details
-
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.
-
zero
Returns the zero element (identity element) of the Ed25519 group.- Parameters:
ls- theLazySodiuminstance- Returns:
- the identity element of Ed25519
-
random
Returns a random element of the Ed25519 group.- Parameters:
ls- theLazySodiuminstance- Returns:
- a random element of Ed25519
-
base
Returns the base point of the Ed25519 group.- Parameters:
ls- theLazySodiuminstance- Returns:
- the base point of Ed25519
- Throws:
SodiumException
-
fromHex
Creates a newEd25519.Ed25519Pointfrom the hexadecimal representation. The hexadecimal representation must be a valid canonical encoding.- Parameters:
ls- theLazySodiuminstancehex- the Ed25519 canonical encoding in hexadecimal notation- Returns:
- the corresponding
Ed25519.Ed25519Point
-
fromString
Creates a newEd25519.Ed25519Pointfrom the encoded representation, using theLazySodium's associatedMessageEncoder. The decoded bytes must be a valid canonical encoding.- Parameters:
ls- theLazySodiuminstanceencoded- the encoded Ed25519 point- Returns:
- the corresponding
Ed25519.Ed25519Point
-
fromBytes
Creates a newEd25519.Ed25519Pointfrom the binary representation. The binary representation must be a valid canonical encoding.- Parameters:
ls- theLazySodiuminstancebytes- the Ed25519 canonical encoding- Returns:
- the corresponding
Ed25519.Ed25519Point
-
hashToPoint
public static Ed25519.Ed25519Point hashToPoint(LazySodium ls, String encodedInput) throws SodiumException Maps the encoded input to aEd25519.Ed25519Point, using theLazySodium's associatedMessageEncoder. The resulting bytes are hashed using SHA-512 and mapped to the Ed25519 group, usingcrypto_code_ed25519_from_uniform, i.e. the standard hash-to-group algorithm.- Parameters:
ls- theLazySodiuminstanceencodedInput- the encoded bytes- Returns:
- the mapped
Ed25519.Ed25519Point - Throws:
SodiumException- if the mapping failed
-
hashToPoint
Maps the input to aEd25519.Ed25519Point, by calculating the SHA-512 hash and mapping it to the Ed25519 group, usingcrypto_code_ed25519_from_uniform, i.e. the standard hash-to-group algorithm.- Parameters:
ls- theLazySodiuminstanceinput- the input bytes- Returns:
- the mapped
Ed25519.Ed25519Point - Throws:
SodiumException- if the mapping failed
-