public class NEP2
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static ScryptParams |
DEFAULT_SCRYPT_PARAMS |
static int |
DKLEN |
static int |
N_STANDARD |
static byte |
NEP2_FLAGBYTE |
static byte |
NEP2_PREFIX_1 |
static byte |
NEP2_PREFIX_2 |
static int |
NEP2_PRIVATE_KEY_LENGTH |
static int |
P_STANDARD |
static int |
R_STANDARD |
| Constructor and Description |
|---|
NEP2() |
| Modifier and Type | Method and Description |
|---|---|
static ECKeyPair |
decrypt(java.lang.String password,
java.lang.String nep2String)
Decrypts the given encrypted private key in NEP-2 format with the given password and standard
scrypt parameters.
|
static ECKeyPair |
decrypt(java.lang.String password,
java.lang.String nep2String,
ScryptParams scryptParams)
Decrypts the given encrypted private key in NEP-2 format with the given password and scrypt
parameters.
|
static java.lang.String |
encrypt(java.lang.String password,
ECKeyPair ecKeyPair)
Encrypts the private key of the given key pair with the given password using standard Scrypt
parameters.
|
static java.lang.String |
encrypt(java.lang.String password,
ECKeyPair ecKeyPair,
int n,
int p,
int r)
Encrypts the private key of the given EC key pair following the NEP-2 standard.
|
static java.lang.String |
encrypt(java.lang.String password,
ECKeyPair ecKeyPair,
ScryptParams scryptParams)
Encrypts the private key of the given EC key pair following the NEP-2 standard.
|
static byte[] |
getAddressHash(ECKeyPair ecKeyPair) |
static byte[] |
performCipherOperation(int mode,
byte[] data,
byte[] encryptKey) |
public static final int DKLEN
public static final int NEP2_PRIVATE_KEY_LENGTH
public static final byte NEP2_PREFIX_1
public static final byte NEP2_PREFIX_2
public static final byte NEP2_FLAGBYTE
public static final int N_STANDARD
public static final int P_STANDARD
public static final int R_STANDARD
public static final ScryptParams DEFAULT_SCRYPT_PARAMS
public static ECKeyPair decrypt(java.lang.String password, java.lang.String nep2String) throws CipherException, NEP2InvalidFormat, NEP2InvalidPassphrase
password - The passphrase used for decryption.nep2String - The NEP-2 ecnrypted private key.NEP2InvalidFormat - throws if the encrypted NEP2 has an invalid format.CipherException - throws if failed encrypt the created wallet.NEP2InvalidPassphrase - throws if the passphrase is not valid.public static ECKeyPair decrypt(java.lang.String password, java.lang.String nep2String, ScryptParams scryptParams) throws NEP2InvalidFormat, CipherException, NEP2InvalidPassphrase
password - The passphrase used for decryption.nep2String - The NEP-2 ecnrypted private key.scryptParams - The scrypt parameters used for encryption.NEP2InvalidFormat - throws if the encrypted NEP2 has an invalid format.CipherException - throws if failed encrypt the created wallet.NEP2InvalidPassphrase - throws if the passphrase is not valid.public static java.lang.String encrypt(java.lang.String password,
ECKeyPair ecKeyPair)
throws CipherException
password - The passphrase used for encryption.ecKeyPair - the ECKeyPair to be encryptedCipherException - throws if the key pair cannot be encrypted.public static java.lang.String encrypt(java.lang.String password,
ECKeyPair ecKeyPair,
ScryptParams scryptParams)
throws CipherException
password - the passphrase to be used to encryptecKeyPair - the ECKeyPair to be encryptedscryptParams - the scrypt parameters used for encryption.CipherException - thrown when the AES/ECB/NoPadding cipher operation failspublic static java.lang.String encrypt(java.lang.String password,
ECKeyPair ecKeyPair,
int n,
int p,
int r)
throws CipherException
password - the passphrase to be used to encryptecKeyPair - the ECKeyPair to be encryptedn - the "n" parameter for SCrypt.generate(byte[], byte[], int, int, int, int) methodp - the "p" parameter for SCrypt.generate(byte[], byte[], int, int, int, int) methodr - the "r" parameter for SCrypt.generate(byte[], byte[], int, int, int, int) methodCipherException - thrown when the AES/ECB/NoPadding cipher operation failspublic static byte[] performCipherOperation(int mode,
byte[] data,
byte[] encryptKey)
throws CipherException
CipherExceptionpublic static byte[] getAddressHash(ECKeyPair ecKeyPair)