Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Fix PrivateTransaction signature calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
iikirilov committed Jan 21, 2019
1 parent 87f169b commit 6b0c58a
Showing 1 changed file with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,16 @@ private Bytes32 getOrComputeSenderRecoveryHash() {
if (hashNoSignature == null) {
hashNoSignature =
computeSenderRecoveryHash(
nonce, gasPrice, gasLimit, to.orElse(null), value, payload, chainId);
nonce,
gasPrice,
gasLimit,
to.orElse(null),
value,
payload,
chainId,
privateFrom,
privateFor,
restriction);
}
return hashNoSignature;
}
Expand Down Expand Up @@ -405,7 +414,10 @@ private static Bytes32 computeSenderRecoveryHash(
final Address to,
final Wei value,
final BytesValue payload,
final OptionalInt chainId) {
final OptionalInt chainId,
final BytesValue privateFrom,
final List<BytesValue> privateFor,
final BytesValue restriction) {
return keccak256(
RLP.encode(
out -> {
Expand All @@ -421,6 +433,9 @@ private static Bytes32 computeSenderRecoveryHash(
out.writeUInt256Scalar(UInt256.ZERO);
out.writeUInt256Scalar(UInt256.ZERO);
}
out.writeBytesValue(privateFrom);
out.writeList(privateFor, (bv, rlpO) -> rlpO.writeBytesValue(bv));
out.writeBytesValue(restriction);
out.endList();
}));
}
Expand Down Expand Up @@ -599,7 +614,17 @@ protected SECP256K1.Signature computeSignature(final SECP256K1.KeyPair keys) {
final OptionalInt optionalChainId =
chainId > 0 ? OptionalInt.of(chainId) : OptionalInt.empty();
final Bytes32 hash =
computeSenderRecoveryHash(nonce, gasPrice, gasLimit, to, value, payload, optionalChainId);
computeSenderRecoveryHash(
nonce,
gasPrice,
gasLimit,
to,
value,
payload,
optionalChainId,
privateFrom,
privateFor,
restriction);
return SECP256K1.sign(hash, keys);
}
}
Expand Down

0 comments on commit 6b0c58a

Please sign in to comment.