Skip to content

Commit

Permalink
Rework RequestSendFundsOp - part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
pzmarzly committed Jun 10, 2019
1 parent 2abf07f commit 1114a56
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion components/proto/src/funder/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub enum FriendMessage<B = NetAddress> {
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
pub struct Receipt {
pub response_hash: HashResult,
// = sha512/256(requestId || sha512/256(route) || randNonce)
// = sha512/256(requestId || randNonce)
pub invoice_id: InvoiceId,
pub src_plain_lock: PlainLock,
pub dest_plain_lock: PlainLock,
Expand Down
8 changes: 2 additions & 6 deletions components/proto/src/funder/signature_buff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub fn create_response_signature_buffer<S>(

let mut inner_blob = Vec::new();
inner_blob.extend_from_slice(&pending_transaction.request_id);
inner_blob.extend_from_slice(&pending_transaction.route.hash());
inner_blob.extend_from_slice(&response_send_funds.rand_nonce);

sbuffer.extend_from_slice(&hash::sha_512_256(&inner_blob));
Expand All @@ -53,14 +52,12 @@ pub fn prepare_receipt(
) -> Receipt {
let mut hash_buff = Vec::new();
hash_buff.extend_from_slice(&pending_transaction.request_id);
hash_buff.extend_from_slice(&pending_transaction.route.hash());
hash_buff.extend_from_slice(&response_send_funds.rand_nonce);
let response_hash = hash::sha_512_256(&hash_buff);
// = sha512/256(requestId || sha512/256(route) || randNonce)
// = sha512/256(requestId || randNonce)

Receipt {
response_hash,
// = sha512/256(requestId || sha512/256(route) || randNonce)
invoice_id: pending_transaction.invoice_id.clone(),
src_plain_lock: collect_send_funds.src_plain_lock.clone(),
dest_plain_lock: collect_send_funds.dest_plain_lock.clone(),
Expand Down Expand Up @@ -93,10 +90,9 @@ pub fn prepare_commit(
) -> Commit {
let mut hash_buff = Vec::new();
hash_buff.extend_from_slice(&pending_transaction.request_id);
hash_buff.extend_from_slice(&pending_transaction.route.hash());
hash_buff.extend_from_slice(&response_send_funds.rand_nonce);
let response_hash = hash::sha_512_256(&hash_buff);
// = sha512/256(requestId || sha512/256(route) || randNonce)
// = sha512/256(requestId || randNonce)

Commit {
response_hash,
Expand Down
3 changes: 1 addition & 2 deletions components/proto/src/schema/common.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ struct MultiCommit {
# A receipt for payment to the Funder
struct Receipt {
responseHash @0: Hash;
# = sha512/256(requestId || sha512/256(route) || randNonce)
# = sha512/256(requestId || randNonce)
invoiceId @1: InvoiceId;
srcPlainLock @2: PlainLock;
destPlainLock @3: PlainLock;
Expand All @@ -159,4 +159,3 @@ struct Receipt {
# invoiceId
# )
}

11 changes: 5 additions & 6 deletions components/proto/src/schema/funder.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,17 @@ struct ResponseSendFundsOp {
signature @3: Signature;
# Signature{key=destinationKey}(
# sha512/256("FUNDS_RESPONSE") ||
# sha512/256(requestId || sha512/256(route) || randNonce) ||
# srcHashedLock ||
# destHashedLock ||
# sha512/256(requestId || randNonce) ||
# srcHashedLock ||
# destHashedLock ||
# destPayment ||
# totalDestPayment ||
# invoiceId
# )
#
# Note that the signature contains an inner blob (requestId || ...).
# This is done to make the size of the receipt shorter.
# See also the Receipt structure.
# This was done to make the size of the receipt shorter, as previously
# this contained a full route.
}

struct CancelSendFundsOp {
Expand All @@ -168,4 +168,3 @@ struct FriendOperation {
collectSendFunds @6: CollectSendFundsOp;
}
}

14 changes: 7 additions & 7 deletions doc/docs/atomic_proposal.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,17 @@ struct ResponseSendFundsOp {
signature @3: Signature;
# Signature{key=destinationKey}(
# sha512/256("FUNDS_RESPONSE") ||
# sha512/256(requestId || sha512/256(route) || randNonce) ||
# srcHashedLock ||
# destHashedLock ||
# sha512/256(requestId || randNonce) ||
# srcHashedLock ||
# destHashedLock ||
# destPayment ||
# totalDestPayment ||
# invoiceId
# )
#
# Note that the signature contains an inner blob (requestId || ...).
# This is done to make the size of the receipt shorter.
# See also the Receipt structure.
# This was done to make the size of the receipt shorter, as previously
# this contained a full route.
}
```

Expand Down Expand Up @@ -406,7 +406,7 @@ credits.
```capnp
struct Commit {
responseHash @0: Hash;
# = sha512/256(requestId || sha512/256(route) || randNonce)
# = sha512/256(requestId || randNonce)
destPayment @1: CustomUInt128;
# Amount of credits paid in this Transaction.
srcPlainLock @2: PlainLock;
Expand Down Expand Up @@ -494,7 +494,7 @@ Receipt.
```capnp
struct Receipt {
responseHash @0: Hash;
# = sha512/256(requestId || sha512/256(route) || randNonce)
# = sha512/256(requestId || randNonce)
invoiceId @1: InvoiceId;
srcPlainLock @2: PlainLock;
destPlainLock @3: PlainLock;
Expand Down

0 comments on commit 1114a56

Please sign in to comment.