public static MasterPublicKey decrypt(String passphrase,byte[] encrypted) throws HyperLedgerException {
  try {
    byte[] key=SCrypt.generate(passphrase.getBytes("UTF-8"),BITCOIN_SEED,16384,8,8,32);
    SecretKeySpec keyspec=new SecretKeySpec(key,"AES");
    Cipher cipher=Cipher.getInstance("AES/CBC/PKCS5Padding","BC");
    byte[] iv=Arrays.copyOfRange(encrypted,0,16);
    byte[] data=Arrays.copyOfRange(encrypted,16,encrypted.length);
    cipher.init(Cipher.DECRYPT_MODE,keyspec,new IvParameterSpec(iv));
    return MasterPublicKey.parse(new String(cipher.doFinal(data)));
  }
 catch (  UnsupportedEncodingException|InvalidAlgorithmParameterException|NoSuchPaddingException|NoSuchProviderException|NoSuchAlgorithmException|InvalidKeyException|BadPaddingException|IllegalBlockSizeException e) {
    throw new HyperLedgerException(e);
  }
}

public static MasterPublicKey decrypt ( String passphrase , byte [ ] encrypted ) throws HyperLedgerException { try { byte [ ] key = SCrypt . generate ( passphrase . getBytes ( "UTF-8" ) , BITCOIN_SEED , 16384 , 8 , 8 , 32 ) ; SecretKeySpec keyspec = new SecretKeySpec ( key , "AES" ) ; Cipher cipher = Cipher . getInstance ( "AES/CBC/PKCS5Padding" , "BC" ) ; byte [ ] iv = Arrays . copyOfRange ( encrypted , 0 , 16 ) ; byte [ ] data = Arrays . copyOfRange ( encrypted , 16 , encrypted . length ) ; cipher . init ( Cipher . DECRYPT_MODE , keyspec , new IvParameterSpec ( iv ) ) ; return MasterPublicKey . parse ( new String ( cipher . doFinal ( data ) ) ) ; } catch ( UnsupportedEncodingException | InvalidAlgorithmParameterException | NoSuchPaddingException | NoSuchProviderException | NoSuchAlgorithmException | InvalidKeyException | BadPaddingException | IllegalBlockSizeException e ) { throw new HyperLedgerException ( e ) ; } }
re - create a masterpublickey from encrypted serialization .
