Package com.codahale.xsalsa20poly1305
Class Keys
- java.lang.Object
-
- com.codahale.xsalsa20poly1305.Keys
-
public class Keys extends java.lang.ObjectUtility methods for generating XSalsa20Poly1305 keys.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]generatePrivateKey()generates a Curve25519 private key.static byte[]generatePublicKey(byte[] privateKey)Generates a Curve25519 public key given a Curve25519 private key.static byte[]generateSecretKey()Generates a 32-byte secret key.static byte[]sharedSecret(byte[] publicKey, byte[] privateKey)Calculate the X25519/HSalsa20 shared secret for the given public key and private key.
-
-
-
Method Detail
-
generateSecretKey
public static byte[] generateSecretKey()
Generates a 32-byte secret key.- Returns:
- a 32-byte secret key
-
generatePrivateKey
public static byte[] generatePrivateKey()
generates a Curve25519 private key.- Returns:
- a Curve25519 private key
-
generatePublicKey
public static byte[] generatePublicKey(byte[] privateKey)
Generates a Curve25519 public key given a Curve25519 private key.- Parameters:
privateKey- a Curve25519 private key- Returns:
- the public key matching
privateKey
-
sharedSecret
public static byte[] sharedSecret(byte[] publicKey, byte[] privateKey)Calculate the X25519/HSalsa20 shared secret for the given public key and private key.- Parameters:
publicKey- the recipient's public keyprivateKey- the sender's private key- Returns:
- a 32-byte secret key only re-calculable by the sender and recipient
-
-