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

pset: add optional asset blinding factor to input and output #1329

Conversation

LeoComandini
Copy link
Contributor

In some protocols where blinding is done by different parties,
the asset surjection proof for some output might be created by:

  • someone who does not own an input with the same asset, or
  • someone who does not know the asset blinding factor
    corresponding to the output asset commitment

This, in general, is the case of LiquiDEX v1 [1], e.g.

  • Alice wants to swap x of asset A for y of asset B
  • Alice owns a utxo with x of asset A
  • Alice creates a spending that utxo and receiving an output
    with y of asset B.
  • Alice draws at random the asset and value blinding factors
    for the output, sets the corresponding asset and value
    commitment. Sets the nonce commitment. Computes and sets
    the rangeproof.
  • Alice computes the scalar offset contribution of the input
    and output (combined)
  • Alice computes the value blind proofs for the input and output
  • Alice creates the LiquiDEX proposal using the data obtained
    above:
{
  "version": 1,
  "tx": "...",
  "inputs": [{
    "asset": "aa...",
    "satoshi": x,
    "assetblinder": "...",
    "value_blind_proof": "...",
  }],
  "outputs": [{
    "asset": "bb...",
    "satoshi": y,
    "assetblinder": "...",
    "value_blind_proof": "...",
  }],
  "scalars": ["..."],
}
  • Alice shares the proposal with Bob
  • Bob adds more inputs for the asset B and fees
  • Bob adds more outputs for the asset A, B and fees
  • Bob blinds the transaction, i.e.:
    • draws at random abf and vbf for each new output, apart
      from the last one for which he uses the new inputs
      contribution and the scalar offset from the proposal to
      balance the tx.
    • creates rangeproofs for each new output
    • creates surjection proofs for each (blinded) fee output
    • creates surjection proofs for each A output, note that
      in general the input asset blinding factor is needed.
    • creates surjection proofs for each B output, including
      the one from Alice, which requires the output blinding
      factor. Note that Alice could not have created the
      surjection proof since she did not know any B input
      when she created the tx.

Input and output asset blinding factors are the last fields
needed to convert LiquiDEX v1 proposals in PSETs (and viceversa).


[1] https://leocomandini.github.io/2022/10/27/liquidexv1.html

apoelstra added a commit to ElementsProject/rust-elements that referenced this pull request Apr 23, 2024
17d354e pset: test input and output asset blinding factors (Leonardo Comandini)
db805b3 pset: output: add asset blinding factor (Leonardo Comandini)
d1dfed4 pset: input: add asset blinding factor (Leonardo Comandini)
04ab514 pset: implement (de)serialize for AssetBlindingFactor (Leonardo Comandini)

Pull request description:

  Change corresponding to ElementsProject/elements#1329

ACKs for top commit:
  apoelstra:
    ACK 17d354e

Tree-SHA512: 14c8d9d096c6412bd15fac1f597a3fbc02a43bee64e3edc8209d487b805671b6cec1fa752337e817324170178a3cf3151bbcbe98dd2646f1e92e3018cd5dceec
Copy link
Member

@delta1 delta1 left a comment

Choose a reason for hiding this comment

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

utACK bc3870a with minor comments

doc/pset.mediawiki Outdated Show resolved Hide resolved
doc/pset.mediawiki Outdated Show resolved Hide resolved
src/psbt.h Outdated Show resolved Hide resolved
@LeoComandini LeoComandini force-pushed the 2024-04-20-pset-asset-blinding-factors branch from bc3870a to 3908da0 Compare April 24, 2024 08:38
@LeoComandini LeoComandini force-pushed the 2024-04-20-pset-asset-blinding-factors branch from 3908da0 to ee08228 Compare July 15, 2024 14:36
@LeoComandini
Copy link
Contributor Author

Hi @delta1 ,
I've addressed your comments and rebased.
Should I do something more to have this merged?

@delta1
Copy link
Member

delta1 commented Jul 15, 2024

hey @LeoComandini, I was hoping to get another set of eyes on this.

@apoelstra could you please review?

@apoelstra
Copy link
Member

Does anyone remember where the (very long past discussion was where I was opposed to putting raw secret data into PSETs?

I think this should have an ELIP number.

@LeoComandini
Copy link
Contributor Author

Does anyone remember where the (very long past discussion was where I was opposed to putting raw secret data into PSETs)?

Pinged you in that chat

You also reviewed and merged the same change in rust-elements, see ElementsProject/rust-elements#201

@apoelstra
Copy link
Member

You also reviewed and merged the same change in rust-elements, see ElementsProject/rust-elements#201

I had assumed that PRs to rust-elements from Blockstream employees which add PSET fields with no description or justification were implementing missing functionality. Not that they were controversial out-of-spec extensions. I'll review more carefully in the future.

@jsarenik
Copy link

Does anyone remember where the (very long past discussion was where I was opposed to putting raw secret data into PSETs?

I think this should have an ELIP number.

@apoelstra please share as I could not find it yet.

Some quick candidates may be:

@apoelstra
Copy link
Member

@jsarenik I found an internal discussion about it. I'm not sure when I will have time to review it.

Meanwhile probably the best way to move forward @LeoComandini is to open a ELIPs PR to add these fields so that we can move discussion into a public arena.

@LeoComandini
Copy link
Contributor Author

LeoComandini commented Jul 17, 2024

@apoelstra , opened ELIP PR ElementsProject/ELIPs#18

@apoelstra
Copy link
Member

Merged the ELIP.

Since this is LiquiDEX-specific and a proprietary extension, I think we should close this PR and instead only implement it in rust-elements/elements-miniscript.

@delta1
Copy link
Member

delta1 commented Aug 8, 2024

Closing since this is now in rust-elements ElementsProject/rust-elements#207

@LeoComandini if you do need this in Elements then let's revisit this discussion

@delta1 delta1 closed this Aug 8, 2024
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.

4 participants