public final class Ed25519 extends Object
It implements this twisted Edwards curve:
-x^2 + y^2 = 1 + (-121665 / 121666 mod 2^255-19)*x^2*y^2
| Modifier and Type | Field and Description |
|---|---|
static int |
PUBLIC_KEY_LEN |
static int |
SECRET_KEY_LEN |
static int |
SIGNATURE_LEN |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
getHashedScalar(byte[] privateKey) |
static void |
init()
Initializes Ed25519 if not yet initialized.
|
static byte[] |
scalarMultWithBaseToBytes(byte[] a)
Computes
a*B
where a = a[0]+256*a[1]+...+256^31 a[31] and
B is the Ed25519 base point (x,4/5) with x positive. |
static byte[] |
sign(byte[] message,
byte[] publicKey,
byte[] hashedPrivateKey)
Returns the EdDSA signature for the
message based on the hashedPrivateKey. |
static boolean |
verify(byte[] message,
byte[] signature,
byte[] publicKey)
Returns true if the EdDSA
signature with message, can be verified with publicKey. |
public static final int SECRET_KEY_LEN
public static final int PUBLIC_KEY_LEN
public static final int SIGNATURE_LEN
public static byte[] scalarMultWithBaseToBytes(byte[] a)
a*B
where a = a[0]+256*a[1]+...+256^31 a[31] and
B is the Ed25519 base point (x,4/5) with x positive.
Preconditions:
a[31] <= 127public static byte[] getHashedScalar(byte[] privateKey)
throws GeneralSecurityException
GeneralSecurityExceptionpublic static byte[] sign(byte[] message,
byte[] publicKey,
byte[] hashedPrivateKey)
throws GeneralSecurityException
message based on the hashedPrivateKey.message - to signpublicKey - scalarMultWithBaseToBytes(byte[]) of hashedPrivateKeyhashedPrivateKey - getHashedScalar(byte[]) of the private keymessage.GeneralSecurityException - if there is no SHA-512 algorithm defined in EngineFactory.MESSAGE_DIGEST.public static boolean verify(byte[] message,
byte[] signature,
byte[] publicKey)
throws GeneralSecurityException
signature with message, can be verified with publicKey.GeneralSecurityException - if there is no SHA-512 algorithm defined in EngineFactory.MESSAGE_DIGEST.public static void init()