Fixed system test and ProofOfWorkService
This commit is contained in:
@ -28,7 +28,7 @@ import ch.dissem.bitmessage.utils.Encode;
|
||||
import java.io.*;
|
||||
|
||||
import static ch.dissem.bitmessage.utils.Decode.*;
|
||||
import static ch.dissem.bitmessage.utils.Singleton.security;
|
||||
import static ch.dissem.bitmessage.utils.Singleton.cryptography;
|
||||
|
||||
/**
|
||||
* A {@link CustomMessage} implementation that contains signed and encrypted data.
|
||||
@ -80,7 +80,7 @@ public class CryptoCustomMessage<T extends Streamable> extends CustomMessage {
|
||||
}
|
||||
|
||||
data.write(out);
|
||||
Encode.varBytes(security().getSignature(out.toByteArray(), identity.getPrivateKey()), out);
|
||||
Encode.varBytes(cryptography().getSignature(out.toByteArray(), identity.getPrivateKey()), out);
|
||||
container = new CryptoBox(out.toByteArray(), publicKey);
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ public class CryptoCustomMessage<T extends Streamable> extends CustomMessage {
|
||||
}
|
||||
|
||||
public void checkSignature(Pubkey pubkey) throws IOException, IllegalStateException {
|
||||
if (!security().isSignatureValid(out.toByteArray(), varBytes(wrapped), pubkey)) {
|
||||
if (!cryptography().isSignatureValid(out.toByteArray(), varBytes(wrapped), pubkey)) {
|
||||
throw new IllegalStateException("Signature check failed");
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static ch.dissem.bitmessage.utils.Singleton.security;
|
||||
import static ch.dissem.bitmessage.utils.Singleton.cryptography;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CryptoCustomMessageTest extends TestBase {
|
||||
@ -39,9 +39,9 @@ public class CryptoCustomMessageTest extends TestBase {
|
||||
PrivateKey privateKey = PrivateKey.read(TestUtils.getResource("BM-2cSqjfJ8xK6UUn5Rw3RpdGQ9RsDkBhWnS8.privkey"));
|
||||
BitmessageAddress sendingIdentity = new BitmessageAddress(privateKey);
|
||||
|
||||
GenericPayload payloadBefore = new GenericPayload(0, 1, security().randomBytes(100));
|
||||
GenericPayload payloadBefore = new GenericPayload(0, 1, cryptography().randomBytes(100));
|
||||
CryptoCustomMessage<GenericPayload> messageBefore = new CryptoCustomMessage<>(payloadBefore);
|
||||
messageBefore.signAndEncrypt(sendingIdentity, security().createPublicKey(sendingIdentity.getPublicDecryptionKey()));
|
||||
messageBefore.signAndEncrypt(sendingIdentity, cryptography().createPublicKey(sendingIdentity.getPublicDecryptionKey()));
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
messageBefore.write(out);
|
||||
@ -65,11 +65,11 @@ public class CryptoCustomMessageTest extends TestBase {
|
||||
PrivateKey privateKey = PrivateKey.read(TestUtils.getResource("BM-2cSqjfJ8xK6UUn5Rw3RpdGQ9RsDkBhWnS8.privkey"));
|
||||
final BitmessageAddress sendingIdentity = new BitmessageAddress(privateKey);
|
||||
|
||||
ProofOfWorkRequest requestBefore = new ProofOfWorkRequest(sendingIdentity, security().randomBytes(64),
|
||||
ProofOfWorkRequest requestBefore = new ProofOfWorkRequest(sendingIdentity, cryptography().randomBytes(64),
|
||||
ProofOfWorkRequest.Request.CALCULATE);
|
||||
|
||||
CryptoCustomMessage<ProofOfWorkRequest> messageBefore = new CryptoCustomMessage<>(requestBefore);
|
||||
messageBefore.signAndEncrypt(sendingIdentity, security().createPublicKey(sendingIdentity.getPublicDecryptionKey()));
|
||||
messageBefore.signAndEncrypt(sendingIdentity, cryptography().createPublicKey(sendingIdentity.getPublicDecryptionKey()));
|
||||
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
Reference in New Issue
Block a user