Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize BIP-47 #8

Closed
wants to merge 1,268 commits into from

Conversation

justusranvier
Copy link

Version 3 payment codes avoid address reuse when the same payment code is
used to receive payments on different blockchains.


====Binary Serialization====

* Byte 0: version. required value: 0x03
Copy link
Member

@kristovatlas kristovatlas Sep 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consistent with previous versioning 👍

### The "next unused" public key is based on an index specific to the Alice-Bob context, not global to either Alice or Bob
## Alice selects the 4 byte registered coin type for the transaction based on SLIP-0044: <pre>t</pre>
## Alice calculates a secret point: <pre>S = aB</pre>
## Alice calculates a scalar shared secret using the x value of S: <pre>s = SHA256(HMAC-SHA512(Sx, t))</pre>
Copy link
Member

@kristovatlas kristovatlas Sep 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the goal of using HMAC-SHA512 here? Why was SHA512 chosen as a hash function? ❓

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Adding HMAC-SHA512 doesn't require the addition of any new functions to BIP47 implementations, as it is used for calculating the blinding factor of the notification transaction. 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HMAC-SHA512 is also part of BIP-32, so it's a hash function you can guarantee is available in any HD wallet.

## Alice selects the 0th private key derived from her payment code: <pre>a</pre>
## Alice selects the next unused public key derived from Bob's payment code, starting from zero: <pre>B, where B = bG</pre>
### The "next unused" public key is based on an index specific to the Alice-Bob context, not global to either Alice or Bob
## Alice selects the 4 byte registered coin type for the transaction based on SLIP-0044: <pre>t</pre>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N.B.: The coin types accepted by Bob for payment will be need to negotiated at another protocol layer since SLIP-0044 has many coins and is subject to updates.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed now with a comment at the beginning of the sending procedure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

### If the value of s is not in the secp256k1 group, Alice MUST increment the index used to derive Bob's public key and try again.
## Alice uses the scalar shared secret to calculate the ephemeral public key used to generate the P2PKH address for this transaction: <pre>B' = B + sG</pre>
# Bob is watching for incoming payments on B' ever since he received the notification transaction from Alice.
## Bob calculates n shared secrets with Alice, using the 0<sup>th</sup> public key derived Alice's payment code, and private keys 0 - n derived from Bob's payment code, where n is his desired lookahead window.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grammatical issue present also in v1 description?

0th public key derived +from+ Alice's payment code

## Bob calculates n shared secrets with Alice, using the 0<sup>th</sup> public key derived Alice's payment code, and private keys 0 - n derived from Bob's payment code, where n is his desired lookahead window.
## Bob calculates the ephemeral deposit addresses using the same procedure as Alice: <pre>B' = B + sG</pre>
## Bob calculate the private key for each ephemeral address as: <pre>b' = b + s</pre>

==Test Vectors==

* [[https://gist.github.com/SamouraiDev/6aad669604c5930864bd|BIP47 Reusable Payment Codes Test Vectors]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need v3 test vectors for the sake of completeness?

luke-jr and others added 27 commits February 3, 2021 22:27
bip-0141: clarify the sigop count calculation for CHECKMULTISIG
BIP 174: require creator to initialize empty output fields
…tsignal-check

bip 8: simplify MUST_SIGNAL check
bip-0350: fix links for reference implementations
cd1f225 BIP 155: Remove bitcoin.org link. (kiminuo)

Pull request description:

  Fix link.

ACKs for top commit:
  laanwj:
    Thanks you, ACK cd1f225

Tree-SHA512: f798246ddffc2564385a2e071da02e47457ced15e502a8b500a10c2a4f5134cea750042e916bbfac39966e85efd554ad333a908be602a4cfcf09fa058840a527
BIP-0039: Add Python-HDWallet package
Add another Rust implmentation of BIP-0039
The original implementation of BIP-47 in Samourai Wallet reversed
the parameters in the calculation of the HMAC-SHA512 step of
notification transaction blinding.

This change adjusts the text to match the as-implementend behavior
in deployed BIP-47 wallets and the test vectors.
@justusranvier justusranvier changed the title Bip47: define version 3 payment codes Finalize BIP-47 Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.