Allow signing private transaction with any key (#1561)

- Previously you had to sign the private transaction with the same key as the privacy marker transaction.
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Ivaylo Kirilov 6 years ago committed by Eric Kellstrand
parent 2b839193b9
commit 3e4953fd23
  1. 9
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/privacy/PrivateTransactionHandler.java
  2. 4
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/methods/privacy/EeaSendRawTransaction.java

@ -23,6 +23,7 @@ import tech.pegasys.pantheon.enclave.types.SendRequest;
import tech.pegasys.pantheon.enclave.types.SendResponse; import tech.pegasys.pantheon.enclave.types.SendResponse;
import tech.pegasys.pantheon.ethereum.core.Account; import tech.pegasys.pantheon.ethereum.core.Account;
import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.ethereum.core.Hash;
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters; import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
import tech.pegasys.pantheon.ethereum.core.Transaction; import tech.pegasys.pantheon.ethereum.core.Transaction;
import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator.TransactionInvalidReason; import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
@ -47,6 +48,7 @@ public class PrivateTransactionHandler {
private final Enclave enclave; private final Enclave enclave;
private final Address privacyPrecompileAddress; private final Address privacyPrecompileAddress;
private final SECP256K1.KeyPair nodeKeyPair; private final SECP256K1.KeyPair nodeKeyPair;
private final Address signerAddress;
private final PrivateStateStorage privateStateStorage; private final PrivateStateStorage privateStateStorage;
private final WorldStateArchive privateWorldStateArchive; private final WorldStateArchive privateWorldStateArchive;
@ -68,6 +70,7 @@ public class PrivateTransactionHandler {
this.enclave = enclave; this.enclave = enclave;
this.privacyPrecompileAddress = privacyPrecompileAddress; this.privacyPrecompileAddress = privacyPrecompileAddress;
this.nodeKeyPair = nodeKeyPair; this.nodeKeyPair = nodeKeyPair;
this.signerAddress = Address.extract(Hash.hash(nodeKeyPair.getPublicKey().getEncodedBytes()));
this.privateStateStorage = privateStateStorage; this.privateStateStorage = privateStateStorage;
this.privateWorldStateArchive = privateWorldStateArchive; this.privateWorldStateArchive = privateWorldStateArchive;
} }
@ -112,7 +115,7 @@ public class PrivateTransactionHandler {
.to(privacyPrecompileAddress) .to(privacyPrecompileAddress)
.value(privateTransaction.getValue()) .value(privateTransaction.getValue())
.payload(BytesValue.wrap(transactionEnclaveKey.getBytes(Charsets.UTF_8))) .payload(BytesValue.wrap(transactionEnclaveKey.getBytes(Charsets.UTF_8)))
.sender(privateTransaction.getSender()) .sender(signerAddress)
.signAndBuild(nodeKeyPair); .signAndBuild(nodeKeyPair);
} }
@ -185,4 +188,8 @@ public class PrivateTransactionHandler {
// private state does not exist // private state does not exist
Account.DEFAULT_NONCE); Account.DEFAULT_NONCE);
} }
public Address getSignerAddress() {
return signerAddress;
}
} }

@ -108,7 +108,9 @@ public class EeaSendRawTransaction implements JsonRpcMethod {
() -> { () -> {
final Transaction privacyMarkerTransaction = final Transaction privacyMarkerTransaction =
privateTransactionHandler.createPrivacyMarkerTransaction( privateTransactionHandler.createPrivacyMarkerTransaction(
enclaveKey, privateTransaction, getNonce(privateTransaction.getSender())); enclaveKey,
privateTransaction,
getNonce(privateTransactionHandler.getSignerAddress()));
return transactionPool return transactionPool
.addLocalTransaction(privacyMarkerTransaction) .addLocalTransaction(privacyMarkerTransaction)
.either( .either(

Loading…
Cancel
Save