forked from Qortal/qortal
Removed broken MD160 support in Crypto
This commit is contained in:
parent
cd066cf357
commit
ac15dfe789
@ -5,7 +5,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.qortal.account.Account;
|
import org.qortal.account.Account;
|
||||||
import org.qortal.block.BlockChain;
|
|
||||||
import org.qortal.utils.Base58;
|
import org.qortal.utils.Base58;
|
||||||
|
|
||||||
import com.google.common.primitives.Bytes;
|
import com.google.common.primitives.Bytes;
|
||||||
@ -59,24 +58,17 @@ public class Crypto {
|
|||||||
return Bytes.concat(digest, digest);
|
return Bytes.concat(digest, digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private static String toAddress(byte addressVersion, byte[] input) {
|
private static String toAddress(byte addressVersion, byte[] input) {
|
||||||
// SHA2-256 input to create new data and of known size
|
// SHA2-256 input to create new data and of known size
|
||||||
byte[] inputHash = digest(input);
|
byte[] inputHash = digest(input);
|
||||||
|
|
||||||
// Use RIPEMD160 to create shorter address
|
// Use RIPEMD160 to create shorter address
|
||||||
if (BlockChain.getInstance().getUseBrokenMD160ForAddresses()) {
|
// Use legit MD160
|
||||||
// Legacy BROKEN MD160
|
try {
|
||||||
BrokenMD160 brokenMD160 = new BrokenMD160();
|
MessageDigest md160 = MessageDigest.getInstance("RIPEMD160");
|
||||||
inputHash = brokenMD160.digest(inputHash);
|
inputHash = md160.digest(inputHash);
|
||||||
} else {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
// Use legit MD160
|
throw new RuntimeException("RIPEMD160 message digest not available");
|
||||||
try {
|
|
||||||
MessageDigest md160 = MessageDigest.getInstance("RIPEMD160");
|
|
||||||
inputHash = md160.digest(inputHash);
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
throw new RuntimeException("RIPEMD160 message digest not available");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create address data using above hash and addressVersion (prepended)
|
// Create address data using above hash and addressVersion (prepended)
|
||||||
|
Loading…
Reference in New Issue
Block a user