Package nxt.crypto

Class Crypto

java.lang.Object
nxt.crypto.Crypto

public final class Crypto extends Object
  • Method Details

    • getSecureRandom

      public static SecureRandom getSecureRandom()
    • getMessageDigest

      public static MessageDigest getMessageDigest(String algorithm)
    • sha256

      public static MessageDigest sha256()
    • ripemd160

      public static MessageDigest ripemd160()
    • sha3

      public static MessageDigest sha3()
    • getKeySeed

      public static byte[] getKeySeed(byte[] privateKey, byte[]... nonces)
    • getPublicKey

      public static byte[] getPublicKey(byte[] privateKey)
    • getPrivateKey

      public static byte[] getPrivateKey(byte[] keySeed)
    • getPrivateKey

      public static byte[] getPrivateKey(String secretPhrase)
    • curve

      public static void curve(byte[] Z, byte[] k, byte[] P)
    • sign

      public static byte[] sign(byte[] message, byte[] privateKey)
    • verify

      public static boolean verify(byte[] signature, byte[] message, byte[] publicKey)
    • getSharedKey

      public static byte[] getSharedKey(byte[] myPrivateKey, byte[] theirPublicKey)
    • getSharedKey

      public static byte[] getSharedKey(byte[] myPrivateKey, byte[] theirPublicKey, byte[] nonce)
    • aesEncrypt

      public static byte[] aesEncrypt(byte[] plaintext, byte[] key)
    • aesGCMEncrypt

      public static byte[] aesGCMEncrypt(byte[] plaintext, byte[] key)
    • aesDecrypt

      public static byte[] aesDecrypt(byte[] ivCiphertext, byte[] key)
    • aesGCMDecrypt

      public static byte[] aesGCMDecrypt(byte[] ivCiphertext, byte[] key)
    • isCanonicalPublicKey

      public static boolean isCanonicalPublicKey(byte[] publicKey)
    • isCanonicalSignature

      public static boolean isCanonicalSignature(byte[] signature)
    • clamp

      public static void clamp(byte[] key)
      Clamping is used to protect a key against common attacks on Ed25519 and Curve25519. In our case the lowest 3 bits of the first byte of the key of are cleared, the highest bit of the last byte is cleared, and the second highest bit of the last byte is set.
      Parameters:
      key - the key to clamp