diff --git a/contracts/IdentityPromises.sol b/contracts/IdentityPromises.sol index 404be71..7774482 100644 --- a/contracts/IdentityPromises.sol +++ b/contracts/IdentityPromises.sol @@ -16,11 +16,11 @@ contract IdentityPromises is IdentityRegistry , IdentityBalances { } - function clearPromise(bytes32 receiverAndSigns, uint256 seq, uint256 amount, + function clearPromise(bytes32 receiverAndSigns, bytes32 extraDataHash, uint256 seq, uint256 amount, bytes32 sender_R, bytes32 sender_S, bytes32 receiver_R, bytes32 receiver_S) public returns (bool) { (address receiver, uint8 sender_V, uint8 receiver_V) = Utils.unpackSignatureAndSigns(receiverAndSigns); - bytes32 promiseHash = keccak256(abi.encodePacked(ISSUER_PREFIX, receiver , seq , amount)); + bytes32 promiseHash = keccak256(abi.encodePacked(ISSUER_PREFIX, extraDataHash, receiver, seq , amount)); address sender = ecrecover(promiseHash, sender_V , sender_R, sender_S); address recoveredReceiver = ecrecover(keccak256(abi.encodePacked(RECEIVER_PREFIX, promiseHash , sender)), receiver_V , receiver_R, receiver_S); diff --git a/promises/clearing.go b/promises/clearing.go index 412a448..670c601 100644 --- a/promises/clearing.go +++ b/promises/clearing.go @@ -68,8 +68,13 @@ func (pc *PromiseClearing) ClearReceivedPromise(promise * ReceivedPromise) error var packedAddressAndSigns [32]byte addressAndSigns := append([]byte{issuerSig.V, receiverSig.V} , promise.Receiver.Bytes()...) copy(packedAddressAndSigns[10:32] , addressAndSigns) + + var extraDataHash[32]byte + copy(extraDataHash[:], promise.ConsumerHash()) + _ , err = pc.ClearPromise( packedAddressAndSigns, + extraDataHash, big.NewInt(promise.SeqNo), big.NewInt(promise.Amount), issuerSig.R, diff --git a/promises/promise.go b/promises/promise.go index e9c707e..32f5759 100644 --- a/promises/promise.go +++ b/promises/promise.go @@ -9,6 +9,7 @@ import ( ) type Promise struct { + ServiceConsumer common.Address Receiver common.Address SeqNo int64 Amount int64 @@ -16,8 +17,12 @@ type Promise struct { const issuerPrefix = "Issuer prefix:" +func (p * Promise) ConsumerHash() []byte { + return crypto.Keccak256(p.ServiceConsumer.Bytes()) +} + func (p * Promise) HashBytes() []byte { - return crypto.Keccak256([]byte(issuerPrefix) , p.Receiver.Bytes(), abi.U256(big.NewInt(p.SeqNo)), abi.U256(big.NewInt(p.Amount))) + return crypto.Keccak256([]byte(issuerPrefix) , p.ConsumerHash(), p.Receiver.Bytes(), abi.U256(big.NewInt(p.SeqNo)), abi.U256(big.NewInt(p.Amount))) }