mirror of
				https://github.com/Qortal/altcoinj.git
				synced 2025-11-03 05:57:21 +00:00 
			
		
		
		
	Always use utility method in KeyCrypterScrypt for determining the scrypt salt.
This commit is contained in:
		@@ -42,7 +42,6 @@ import org.spongycastle.crypto.params.KeyParameter;
 | 
			
		||||
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.math.BigInteger;
 | 
			
		||||
import java.security.SecureRandom;
 | 
			
		||||
import java.security.SignatureException;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
@@ -65,11 +64,7 @@ public class ECKeyTest {
 | 
			
		||||
 | 
			
		||||
    @Before
 | 
			
		||||
    public void setUp() throws Exception {
 | 
			
		||||
        SecureRandom secureRandom = new SecureRandom();
 | 
			
		||||
 | 
			
		||||
        byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
 | 
			
		||||
        secureRandom.nextBytes(salt);
 | 
			
		||||
        Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(salt));
 | 
			
		||||
        Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(KeyCrypterScrypt.randomSalt()));
 | 
			
		||||
        ScryptParameters scryptParameters = scryptParametersBuilder.build();
 | 
			
		||||
        keyCrypter = new KeyCrypterScrypt(scryptParameters);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,6 @@ import org.junit.Test;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
 | 
			
		||||
import java.security.SecureRandom;
 | 
			
		||||
import java.util.Random;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
@@ -50,9 +49,8 @@ public class KeyCrypterScryptTest {
 | 
			
		||||
 | 
			
		||||
    @Before
 | 
			
		||||
    public void setUp() throws Exception {
 | 
			
		||||
        byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
 | 
			
		||||
        new SecureRandom().nextBytes(salt);
 | 
			
		||||
        Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(salt));
 | 
			
		||||
        Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder()
 | 
			
		||||
                .setSalt(ByteString.copyFrom(KeyCrypterScrypt.randomSalt()));
 | 
			
		||||
        scryptParameters = scryptParametersBuilder.build();
 | 
			
		||||
 | 
			
		||||
        BriefLogFormatter.init();
 | 
			
		||||
 
 | 
			
		||||
@@ -93,8 +93,6 @@ public class WalletTest extends TestWithWallet {
 | 
			
		||||
    private static final CharSequence PASSWORD1 = "my helicopter contains eels";
 | 
			
		||||
    private static final CharSequence WRONG_PASSWORD = "nothing noone nobody nowhere";
 | 
			
		||||
 | 
			
		||||
    private SecureRandom secureRandom = new SecureRandom();
 | 
			
		||||
 | 
			
		||||
    private final Address OTHER_ADDRESS = new ECKey().toAddress(PARAMS);
 | 
			
		||||
 | 
			
		||||
    @Before
 | 
			
		||||
@@ -2093,9 +2091,8 @@ public class WalletTest extends TestWithWallet {
 | 
			
		||||
 | 
			
		||||
        // Try added an ECKey that was encrypted with a differenct ScryptParameters (i.e. a non-homogenous key).
 | 
			
		||||
        // This is not allowed as the ScryptParameters is stored at the Wallet level.
 | 
			
		||||
        byte[] salt = new byte[KeyCrypterScrypt.SALT_LENGTH];
 | 
			
		||||
        secureRandom.nextBytes(salt);
 | 
			
		||||
        Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder().setSalt(ByteString.copyFrom(salt));
 | 
			
		||||
        Protos.ScryptParameters.Builder scryptParametersBuilder = Protos.ScryptParameters.newBuilder()
 | 
			
		||||
                .setSalt(ByteString.copyFrom(KeyCrypterScrypt.randomSalt()));
 | 
			
		||||
        Protos.ScryptParameters scryptParameters = scryptParametersBuilder.build();
 | 
			
		||||
        KeyCrypter keyCrypterDifferent = new KeyCrypterScrypt(scryptParameters);
 | 
			
		||||
        ECKey ecKeyDifferent = new ECKey();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user