public static DumpedPrivateKey fromBase58(@Nullable Network network, String base58)
            throws AddressFormatException, AddressFormatException.WrongNetwork {
        byte[] versionAndDataBytes = Base58.decodeChecked(base58);
        int version = versionAndDataBytes[0] & 0xFF;
        byte[] bytes = Arrays.copyOfRange(versionAndDataBytes, 1, versionAndDataBytes.length);
        if (network == null) {
            for (NetworkParameters p : Networks.get())
                if (version == p.getDumpedPrivateKeyHeader())
                    return new DumpedPrivateKey(p.network(), bytes);
            throw new AddressFormatException.InvalidPrefix("No network found for version " + version);
        } else {
            NetworkParameters params = NetworkParameters.of(network);
            if (version == params.getDumpedPrivateKeyHeader())
                return new DumpedPrivateKey(network, bytes);
            throw new AddressFormatException.WrongNetwork(version);
        }
    }
@Test(expected = AddressFormatException.InvalidDataLength.class)
    public void fromBase58_tooShort() {
        String base58 = Base58.encodeChecked(NetworkParameters.of(MAINNET).getDumpedPrivateKeyHeader(), new byte[31]);
        DumpedPrivateKey.fromBase58((Network) null, base58);
    }