Package org.polkadot.utils.crypto
Class Nacl
- java.lang.Object
-
- org.polkadot.utils.crypto.Nacl
-
public class Nacl extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNacl.Encrypted
-
Constructor Summary
Constructors Constructor Description Nacl()
-
Method Summary
Modifier and Type Method Description static byte[]naclDecrypt(byte[] encrypted, byte[] nonce, byte[] secret)Decrypts a message using the supplied secretKey and nonce Returns an decrypted message, using the `secret` and `nonce`.static Nacl.EncryptednaclEncrypt(byte[] message, byte[] secret)Encrypts a message using the supplied secretKey and nonce Returns an encrypted message, using the `secretKey` and `nonce`.static Nacl.EncryptednaclEncrypt(byte[] message, byte[] secret, byte[] nonce)static Types.KeypairnaclKeypairFromSeed(byte[] seed)Creates a new public/secret keypair from a seed.static byte[]naclSign(byte[] message, Types.Keypair keypair)Signs a message using the supplied secretKey Returns message signature of `message`, using the `secretKey`.static booleannaclVerify(byte[] message, byte[] signature, byte[] publicKey)Verifies the signature on the supplied message.
-
-
-
Method Detail
-
naclDecrypt
public static byte[] naclDecrypt(byte[] encrypted, byte[] nonce, byte[] secret)Decrypts a message using the supplied secretKey and nonce Returns an decrypted message, using the `secret` and `nonce`. **example** ```java naclDecrypt([...], [...], [...]); // => [...] ```
-
naclEncrypt
public static Nacl.Encrypted naclEncrypt(byte[] message, byte[] secret)
Encrypts a message using the supplied secretKey and nonce Returns an encrypted message, using the `secretKey` and `nonce`. If the `nonce` was not supplied, a random value is generated. **example** ```java naclEncrypt([...], [...]); // => [...] ```
-
naclEncrypt
public static Nacl.Encrypted naclEncrypt(byte[] message, byte[] secret, byte[] nonce)
-
naclKeypairFromSeed
public static Types.Keypair naclKeypairFromSeed(byte[] seed)
Creates a new public/secret keypair from a seed. Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed. **example** ```java naclKeypairFromSeed(...); // => { secretKey: [...], publicKey: [...] } ```
-
naclSign
public static byte[] naclSign(byte[] message, Types.Keypair keypair)Signs a message using the supplied secretKey Returns message signature of `message`, using the `secretKey`. **example** ```java naclSign([...], [...]); // => [...] ```
-
naclVerify
public static boolean naclVerify(byte[] message, byte[] signature, byte[] publicKey)Verifies the signature on the supplied message. Verifies the `signature` on `message` with the supplied `plublicKey`. Returns `true` on sucess, `false` otherwise. **example** ```java naclVerify([...], [...], [...]); // => true/false ```
-
-