-
Notifications
You must be signed in to change notification settings - Fork 136
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
Blinding of asset issuance transaction #254
Comments
You should never be copying blinding factors like you're describing. They should be generated uniformly randomly, except that one has to be chosen to cancel all the others out -- which looks like what your code is doing, except for the final cancellation step. |
Hi, thanks for answering me so fast, and sorry if my code is a bit confused it's just a draft. If I didn't get you wrong, you're talking about this part (l.90-93):
Then I generate random abf and vbf for the outputs of the transaction I'm creating:
And at last the final vbf:
This part I tried to copy and adapt the workflow described here, l. 54-113. My understanding is that we first get the abfs and vbfs from the previous outputs we're spending and then generate randomly new ones for the outputs we'll create, which is what we pass as arguments to There are a lot of questions about how to handle asset issuance, since they're not "real" inputs and don't point to existing UTXOs. That's what confusing me a bit now I think. |
Oh! I misunderstood what you meant by copying blinding factors. Indeed, the blinding factors on the inputs have to match the commitments, which are defined by the outputs that they reference, so you have to look this up and copy the value into place. For the purposes of balancing commitments, you can think of issued assets as "real" inputs, in that they appear on the negative side of the verification equation. But unlike real inputs, you should generate the blinding factors for issuance inputs randomly, just like you do with outputs. |
Hi, I've resumed work on this topic and I think I understand better what's going on, but I might still be misunderstanding something about asset issuance. I managed to create blinded (but not signed yet) transaction with libwally, but it seems they are incorrect though, as Elements' I think I might be uncorrectly generating the issuance rangeproof, as this part is still a bit obscure to me, and I'm trying to lay here what I understood so far so that I can be corrected if I misunderstood something. Iiuc, when blinding a "normal" output, the sender:
It seems this can't work the same in the case of an initial issuance. I've read Elements' code to try to figure out what to do (for example here and there) and here's what I'm doing in Libwally wrt the issuance of a new asset:
I've seen in Elements that we generate a private blinding key for issuance with an OP_RETURN script with prevout of the input the issuance is hooked to and our master blinding key, and then we use this key as a nonce for the rangeproof. The nonce of a first issuance is empty, since we'll use the private blinding key directly as a nonce for unblinding. Here's the step in Libwally:
|
There's something I don't understand about the workflow to blind an asset issuance.
tx_elements_input_init
takesissuance_amount
andissuance_amount_rangeproof
as arguments, but how do we compute those data?If I understand correctly,
issuance_amount
should be the value commitment to the amount of issued assets, andissuance_amount_rangeproof
is the corresponding rangeproof.At first I just took the value commitment and rangeproof for the newly issued asset output and put it also in the input, it didn't work and now I think I understand why, but now how should I create the right value commitment and rangeproof for the input ?
To compute a value commitment, I need the amount issued (so far so good), a value blinding factor (vbf) and a generator (I need an asset blinding factor for this one).
In a normal input, I'll take the vbf and abf from the previous transaction, but since an issuance doesn't spend a previous output, does it mean I can just take random 32 bytes for those ?
Then to compute the rangeproof, I'll need a blinding pubkey that again I'm supposed to take from the prevout, so can I just compute an ephemeral key pair and take the pubkey ?
Here's the relevant part of my code so far (I edited some parts since it's a bit long, maybe there are some inconsistencies because of that), I can produce a transaction that I can sign but I'll get a
16: bad-txns-in-ne-out
error in elements withtestmempoolaccept
, and I guess that's because my value commitments is broken but I can't see how to correct it.The text was updated successfully, but these errors were encountered: