vulpemventures / go-elements

Go support for Liquid/Elements transactions
MIT License
27 stars 13 forks source link

Psetv2 signer, finaliser and extractor #184

Closed sekulicd closed 2 years ago

sekulicd commented 2 years ago

This adds signer, finaliser and extractor role. SIGHASH_RANGEPROOF is considered in functions that calculates hash for signature. Currently rangeproofs are added to the hash if appropriate sighash_type is passed to the HashForWitnessV0/HashForSignature func, IMO i think rangeproofs hash should always be added to the sig hash for security reasons.

@tiero, @altafan please review.

tiero commented 2 years ago

Also, psetv2/blinder.go could follow this convention in light of the required changes above.

Sorry to stress on this point, let's strive to have a separated package blinder to be detached from the psetv2 so we can compile it to WASM & gomobile

altafan commented 2 years ago

Sorry to stress on this point, let's strive to have a separated package blinder to be detached from the psetv2 so we can compile it to WASM & gomobile

For this, it could be enough for the methods that we will define in psetv2/blinder.go to expect not only the blinding data to add but also the sanity checks that validate those data.

Every check related to the PSET that does not involve secp-zkp could be done by the "base" blinder, like checking that the current output can be blinded, or that the PSET is not locked for modifications etc.

This way, psetv2 would not directly depend on secp-zkp and could be compiled to WASM & gomobile.

tiero commented 2 years ago

psetv2/blinder.go

I mean we must move in a different folder & different package CGO stuff, otherwise go build will ignore the whole package if just one file has one dependency with CGO

You can just try it and see if ignores the whole package or no GOOS=js GOARCH=wasm go build ./psetv2

sekulicd commented 2 years ago

@tiero @altafan please check if u are ok with the way how i decoupled psetv2 from confidential pkg. Here is just POC with the separate pkg for testing so that psetv2 stays decoupled.

tiero commented 2 years ago

@tiero @altafan please check if u are ok with the way how i decoupled psetv2 from confidential pkg. Here is just POC with the separate pkg for testing so that psetv2 stays decoupled.

If I understand, the decoupling is done using the Blinder interface.

We still missing the blindProofsValid to be moved out, but looks good solution for now. It should be possible now to compile to WASM and create a wrapper on top to provider necessary bytes data from the JS runtime.

altafan commented 2 years ago

@sekulicd solve conflicts