예제 #1
0
 public SecretBox(byte[] seed) {
   checkLength(seed, SEED_LENGTH);
   this.seed = seed;
   this.secretKey = CryptoUtils.zeros(SECRETKEY_BYTES * 2);
   byte[] publicKey = CryptoUtils.zeros(PUBLICKEY_BYTES);
   isValid(
       sodium().crypto_sign_ed25519_seed_keypair(publicKey, secretKey, seed),
       "Failed to generate a key pair");
   this.pubKey = Base58.encode(publicKey);
 }
예제 #2
0
 public static byte[] computeSeedFromSaltAndPassword(String salt, String password) {
   try {
     byte[] seed =
         SCrypt.scrypt(
             CryptoUtils.decodeAscii(password),
             CryptoUtils.decodeAscii(salt),
             SCRYPT_PARAMS_N,
             SCRYPT_PARAMS_r,
             SCRYPT_PARAMS_p,
             SEED_LENGTH);
     return seed;
   } catch (GeneralSecurityException e) {
     throw new TechnicalException("Unable to salt password, using Scrypt library", e);
   }
 }
예제 #3
0
 public String sign(String message) {
   byte[] messageBinary = CryptoUtils.decodeUTF8(message);
   return CryptoUtils.encodeBase64(sign(messageBinary));
 }