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

Add BIP352 silentpayments module #1519

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Commits on May 8, 2024

  1. Configuration menu
    Copy the full SHA
    957eb03 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    31187da View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ac97828 View commit details
    Browse the repository at this point in the history
  4. silentpayments: implement shared secret creation

    Add function for calculating either a*B or A*b. This function is used by both
    the sender and the recipient (i.e. a*B == A*b).
    
    Add functions for generating the tagged input hash, as this is used when
    creating the shared secret.
    
    In a later commit, `create_shared_secret` will be exposed in the API for
    the receiver to use when scanning as a light client.
    theStack authored and josibake committed May 8, 2024
    Configuration menu
    Copy the full SHA
    f35ab7d View commit details
    Browse the repository at this point in the history
  5. silentpayments: implement output pubkey creation

    Add methods for creating an xonly output from a shared secret. This
    involves adding a tagged hash for creating the output.
    
    This function will be exposed in the API in a later commit for the
    receiver to use when scanning as a light client.
    theStack authored and josibake committed May 8, 2024
    Configuration menu
    Copy the full SHA
    a4f3583 View commit details
    Browse the repository at this point in the history
  6. silentpayments: add sender routine

    Given a set of private keys, the smallest outpoint, and list of recipients this
    function handles the entire sender flow:
    
    1. Sum up the private keys
    2. Calculate the input_hash
    3. For each recipient:
        3a. Calculate a shared secret
        3b. Create the requested number of outputs
    
    This function assumes a single sender context in that it requires the
    sender to have access to all of the private keys. In the future, this
    API may be expanded to allow for a multiple senders or for a single
    sender who does not have access to all private keys at any given time,
    but for now these modes are considered out of scope / unsafe.
    josibake committed May 8, 2024
    Configuration menu
    Copy the full SHA
    2aec662 View commit details
    Browse the repository at this point in the history
  7. silentpayments: add recipient label support

    Add function for creating a label tweak. This requires a tagged hash
    function for labels. This function is used by the receiver for creating
    labels to be used for a) creating labelled addresses and b) to populate
    a labels cache when scanning.
    
    Add function for creating a labelled spend pubkey. This involves taking
    a label tweak, turning it into a public key and adding it to the spend
    public key. This function is used by the receiver to create a labelled
    silent payment address.
    theStack authored and josibake committed May 8, 2024
    Configuration menu
    Copy the full SHA
    8d5fe46 View commit details
    Browse the repository at this point in the history
  8. silentpayments: add opaque data type public_data

    Add data type for passing around the summed input public key (A_sum) and
    the input hash tweak (input_hash). This data is passed to the scanner
    before the ECDH step as two separate elements so that the scanner can
    multiply b_scan * input_hash before doing ECDH.
    
    Add functions for deserializing / serializing a public_data object to
    and from a public key. When serializing a public_data object, the
    input_hash is multplied into A_sum. This is so the object can be stored
    as public key for wallet rescanning later, or to vend to light clients.
    For the light client, a `_parse` function is added which parses the
    compressed public key serialization into a `public_data` object.
    josibake committed May 8, 2024
    Configuration menu
    Copy the full SHA
    d43636b View commit details
    Browse the repository at this point in the history
  9. silentpayments: add recipient scanning routine

    Add routine for scanning a transaction and returning the necessary
    spending data for any found outputs. This function works with labels via
    a lookup callback and requires access to the transaction outputs.
    Requiring access to the transaction outputs is not suitable for light
    clients, but light client support is enabled in followup commits.
    josibake committed May 8, 2024
    Configuration menu
    Copy the full SHA
    ab908c6 View commit details
    Browse the repository at this point in the history
  10. silentpayments: add recipient light client support

    Expose a shared secret routine in the public API and a output_pubkey
    creation routine. These are simple wrappers around the same functions
    the module is using under the hood. They are exposed for the light
    client as the minimal set of operations they need to do scanning without
    access to the transaction outputs.
    
    This means the light client will need to manage their own scanning
    state, so wherever possible it is preferrable to use the
    `_recipient_scan_ouputs` function.
    josibake committed May 8, 2024
    Configuration menu
    Copy the full SHA
    b58f891 View commit details
    Browse the repository at this point in the history
  11. silentpayments: add examples/silentpayments.c

    Demonstrate sending, scanning, and light client scanning.
    josibake committed May 8, 2024
    Configuration menu
    Copy the full SHA
    dfe9243 View commit details
    Browse the repository at this point in the history
  12. silentpayments: add benchmark for scan_outputs

    Add a benchmark for `scan_outputs` as this is the most performance
    critical part of silent payments.
    josibake committed May 8, 2024
    Configuration menu
    Copy the full SHA
    baafed0 View commit details
    Browse the repository at this point in the history
  13. tests: add BIP-352 test vectors

    The vectors are generated with a Python script that converts the .json
    file from the BIP to C code:
    
    $ ./tools/tests_silentpayments_generate.py test_vectors.json > ./src/modules/silentpayments/vectors.h
    theStack authored and josibake committed May 8, 2024
    Configuration menu
    Copy the full SHA
    932fe57 View commit details
    Browse the repository at this point in the history
  14. ci: enable silentpayments module

    theStack authored and josibake committed May 8, 2024
    Configuration menu
    Copy the full SHA
    56ed901 View commit details
    Browse the repository at this point in the history