Multi-Tenancy: Do not specify a public key anymore when requesting a … (#185)

* Multi-Tenancy: Do not specify a public key anymore when requesting a payload from Orion, so all private keys are tried to decrypt the encrypted payload.

Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net>
pull/182/head
pinges 5 years ago committed by Usman Saleem
parent a6b2ec7460
commit 3c1768eef7
  1. 2
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/EnclaveErrorAcceptanceTest.java
  2. 4
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/EthSignerAcceptanceTest.java
  3. 8
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/PrivacyGroupAcceptanceTest.java
  4. 4
      enclave/src/main/java/org/hyperledger/besu/enclave/types/ReceiveRequest.java
  5. 4
      enclave/src/main/java/org/hyperledger/besu/enclave/types/ReceiveResponse.java
  6. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCreatePrivacyGroup.java
  7. 6
      ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java
  8. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java
  9. 5
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionHandler.java
  10. 3
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractTest.java
  11. 2
      ethereum/referencetests/src/test/resources
  12. 2
      gradle/versions.gradle
  13. 4
      testutil/src/main/java/org/hyperledger/orion/testutil/OrionTestHarnessFactory.java

@ -152,7 +152,7 @@ public class EnclaveErrorAcceptanceTest extends PrivacyAcceptanceTestBase {
alice.getEnclaveKey(),
bob.getEnclaveKey())));
assertThat(throwable).hasMessageContaining("NodePushingToPeer");
assertThat(throwable).hasMessageContaining("NodePropagatingToAllPeers");
}
@Test

@ -107,8 +107,8 @@ public class EthSignerAcceptanceTest extends PrivacyAcceptanceTestBase {
new PrivacyGroup(
privacyGroupId,
PrivacyGroup.Type.PANTHEON,
"Default Name",
"Default Description",
"",
"",
Base64String.wrapList(minerNode.getEnclaveKey()))));
final String transactionHash =

@ -76,7 +76,7 @@ public class PrivacyGroupAcceptanceTest extends PrivacyAcceptanceTestBase {
new PrivacyGroup(
privacyGroupId,
PrivacyGroup.Type.PANTHEON,
"Default Name",
"",
"my group description",
Base64String.wrapList(alice.getEnclaveKey(), bob.getEnclaveKey()));
@ -97,7 +97,7 @@ public class PrivacyGroupAcceptanceTest extends PrivacyAcceptanceTestBase {
privacyGroupId,
PrivacyGroup.Type.PANTHEON,
"myGroupName",
"Default Description",
"",
Base64String.wrapList(alice.getEnclaveKey(), bob.getEnclaveKey()));
alice.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));
@ -116,8 +116,8 @@ public class PrivacyGroupAcceptanceTest extends PrivacyAcceptanceTestBase {
new PrivacyGroup(
privacyGroupId,
PrivacyGroup.Type.PANTHEON,
"Default Name",
"Default Description",
"",
"",
Base64String.wrapList(alice.getEnclaveKey(), bob.getEnclaveKey()));
alice.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected));

@ -28,6 +28,10 @@ public class ReceiveRequest {
this.to = to;
}
public ReceiveRequest(final String key) {
this(key, null);
}
public String getKey() {
return key;
}

@ -21,8 +21,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonPropertyOrder({"payload", "privacyGroupId"})
public class ReceiveResponse {
private byte[] payload;
private String privacyGroupId;
private final byte[] payload;
private final String privacyGroupId;
@JsonCreator
public ReceiveResponse(

@ -36,7 +36,7 @@ public class PrivCreatePrivacyGroup implements JsonRpcMethod {
private static final Logger LOG = getLogger();
private final Enclave enclave;
private PrivacyParameters privacyParameters;
private final PrivacyParameters privacyParameters;
private final JsonRpcParameter parameters;
public PrivCreatePrivacyGroup(

@ -160,11 +160,7 @@ public class PrivacyPrecompiledContractIntegrationTest {
final PrivacyPrecompiledContract privacyPrecompiledContract =
new PrivacyPrecompiledContract(
new SpuriousDragonGasCalculator(),
publicKeys.get(0),
enclave,
worldStateArchive,
privateStateStorage);
new SpuriousDragonGasCalculator(), enclave, worldStateArchive, privateStateStorage);
privacyPrecompiledContract.setPrivateTransactionProcessor(mockPrivateTxProcessor());

@ -46,7 +46,6 @@ import org.apache.logging.log4j.Logger;
public class PrivacyPrecompiledContract extends AbstractPrecompiledContract {
private final Enclave enclave;
private final String enclavePublicKey;
private final WorldStateArchive privateWorldStateArchive;
private final PrivateStateStorage privateStateStorage;
private PrivateTransactionProcessor privateTransactionProcessor;
@ -58,7 +57,6 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract {
final GasCalculator gasCalculator, final PrivacyParameters privacyParameters) {
this(
gasCalculator,
privacyParameters.getEnclavePublicKey(),
new Enclave(privacyParameters.getEnclaveUri()),
privacyParameters.getPrivateWorldStateArchive(),
privacyParameters.getPrivateStateStorage());
@ -66,13 +64,11 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract {
PrivacyPrecompiledContract(
final GasCalculator gasCalculator,
final String publicKey,
final Enclave enclave,
final WorldStateArchive worldStateArchive,
final PrivateStateStorage privateStateStorage) {
super("Privacy", gasCalculator);
this.enclave = enclave;
this.enclavePublicKey = publicKey;
this.privateWorldStateArchive = worldStateArchive;
this.privateStateStorage = privateStateStorage;
}
@ -90,12 +86,12 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract {
@Override
public BytesValue compute(final BytesValue input, final MessageFrame messageFrame) {
final String key = BytesValues.asBase64String(input);
final ReceiveRequest receiveRequest = new ReceiveRequest(key, enclavePublicKey);
final ReceiveRequest receiveRequest = new ReceiveRequest(key);
final ReceiveResponse receiveResponse;
try {
receiveResponse = enclave.receive(receiveRequest);
} catch (Exception e) {
} catch (final Exception e) {
LOG.error("Enclave probably does not have private transaction with key {}.", key, e);
return BytesValue.EMPTY;
}

@ -94,8 +94,7 @@ public class PrivateTransactionHandler {
}
}
public String getPrivacyGroup(final String key, final PrivateTransaction privateTransaction)
throws Exception {
public String getPrivacyGroup(final String key, final PrivateTransaction privateTransaction) {
if (privateTransaction.getPrivacyGroupId().isPresent()) {
return BytesValues.asBase64String(privateTransaction.getPrivacyGroupId().get());
}
@ -108,7 +107,7 @@ public class PrivateTransactionHandler {
try {
receiveResponse = enclave.receive(receiveRequest);
return receiveResponse.getPrivacyGroupId();
} catch (Exception e) {
} catch (final RuntimeException e) {
LOG.error("Failed to retrieve private transaction in enclave", e);
throw e;
}

@ -54,7 +54,6 @@ public class PrivacyPrecompiledContractTest {
@Rule public final TemporaryFolder temp = new TemporaryFolder();
private final String actual = "Test String";
private final String publicKey = "public key";
private final BytesValue key = BytesValue.wrap(actual.getBytes(UTF_8));
private PrivacyPrecompiledContract privacyPrecompiledContract;
private PrivacyPrecompiledContract brokenPrivateTransactionHandler;
@ -134,7 +133,6 @@ public class PrivacyPrecompiledContractTest {
privacyPrecompiledContract =
new PrivacyPrecompiledContract(
new SpuriousDragonGasCalculator(),
publicKey,
mockEnclave(),
worldStateArchive,
privateStateStorage);
@ -142,7 +140,6 @@ public class PrivacyPrecompiledContractTest {
brokenPrivateTransactionHandler =
new PrivacyPrecompiledContract(
new SpuriousDragonGasCalculator(),
publicKey,
brokenMockEnclave(),
worldStateArchive,
privateStateStorage);

@ -1 +1 @@
Subproject commit cfbcd15f91d4d6e1785d9cae5c5c37f47e8bad46
Subproject commit 0327d9f76ce2a292a99e7a9dfc93627368ce589e

@ -61,7 +61,7 @@ dependencyManagement {
dependency 'org.apache.tuweni:tuweni-crypto:0.9.0'
dependency 'org.apache.tuweni:tuweni-toml:0.9.0'
dependency 'net.consensys:orion:1.3.2'
dependency 'net.consensys:orion:1.5.0-SNAPSHOT'
dependency 'org.apache.commons:commons-text:1.8'

@ -38,8 +38,8 @@ public class OrionTestHarnessFactory {
final String privKeyPath,
final List<String> othernodes)
throws IOException {
Path key1pub = copyResource(pubKeyPath, tempDir.resolve(pubKeyPath));
Path key1key = copyResource(privKeyPath, tempDir.resolve(privKeyPath));
final Path key1pub = copyResource(pubKeyPath, tempDir.resolve(pubKeyPath));
final Path key1key = copyResource(privKeyPath, tempDir.resolve(privKeyPath));
return create(tempDir, key1pub, key1key, othernodes);
}

Loading…
Cancel
Save