I think you're mistaken.
If you want something that signs messages in general use GPG. It would be an extremely bad practice to come up with some novel cryptosystem just to sign messages when established audited and mature alternatives exists.
Bitcoin uses a novel cryptosystem for signing transactions called Bitcoin Script which allows all sorts of complex constraints on the signatures. It's why with Bitcoin you can do multisig-- but for GPG and whatnot, you can't really (technically it could be done, but would need complex MPC crypto which no one implements).
Sometimes you want to sign messages with bitcoin addresses, e.g. to have the operator of an address attest to something.
If you're going to do that and support all addresses, then you need to use Bitcoin script to do it. In doing so, you pick up some of the structure that goes around script-- some of which may not be as useful outside of the blockchain.
So I don't think anyone particularly wants to use the bitcoin core code base-- but rather they want a signmessage that works for all Bitcoin addresses.
Quote from: tiagocs on July 11, 2020, 07:45:44 PM
1 - Why was it chosen to prepend the scriptPubKey (when not P2PKH) to the preimage? To me, this adds unnecessary complexity which will slow down the adoption of BIP 322 by bitcoin libraries.
I'm not sure, but I could speculate:
Because that's how signing works in Bitcoin so it should make it simpler for existing code. Also signatures generally must commit to their public keys or weird vulnerabilities crop up where you think you're signing with one key, but you're really signing for a related key.
https://community.ziggo.nl/stel-je-vraag-211/kickboksen-glory-76-live-op-tv-naar-kijken-69600Bitcoin uses a novel cryptosystem for signing transactions called Bitcoin Script which allows all sorts of complex constraints on the signatures.
each implementation of bitcoin should have a way of producing and verifying ECDSA signatures and work with scripts to some extent (usually standard ones only) but they don't have to have the flags used in bitcoin core specially when it comes to message verification. for example none of these exist in SPV clients such as Electrum so their code has to significantly change if they wanted to implement this I.P.:
Verifying
Verify a proof, given a standard flags value, a script sig, an optional witness, and a derived sighash as described above.
1. Verify Script with flags=consensus flags (currently P2SH, DERSIG, NULLDUMMY, CLTV, CSV, WITNESS), scriptSig=script sig, scriptPubKey=scriptPubKey, witness=witness, and sighash=sighash
3. Verify Script with flags=standard flags (above plus STRICTENC, MINIMALDATA, etc.), scriptSig=script sig, scriptPubKey=scriptPubKey, witness=witness, and sighash=sighash
also these flags are used during block verification and most of them are there for backward compatibility (eg. whether BIP-66 is enabled to use DERSIG or BIP-112 for OP_CSV), i don't see why they should be used in a message signature verification.
not to mention that certain things from bitcoin scripts can not even be imported into message verification. some are addressing malleability issues, some OP codes such as those involving locktimes cause a lot of problems as there is no transaction or block to use for verification, the "signature" that is popped from the stack in transaction during script evaluation has a sighash flag which makes no sense in a message since there is no txout/ins to sign based on that,...
Quote from: gmaxwell on July 12, 2020, 05:57:52 AM
So I don't think anyone particularly wants to use the bitcoin core code base-- but rather they want a signmessage that works for all Bitcoin addresses.
then the proposal could have been a lot simpler or even expand on BIP-137 instead.
for instance as i said above there is no reason to use "witness" in a message signature from a bitcoin address since we are not producing a transaction and backward compatibility of SegWit is not needed here.
take P2PKH and P2WPKH, both of them are the exact same thing there is a pubkey that is hashed using HASH160 and there is a signature that matches that pubkey. in a transaction it makes a difference when creating the hash digest for verification and where the "stack items" are placed, but it is the same when verifying a message.
same with P2SH and P2WSH.
each implementation of bitcoin should have a way of producing and verifying ECDSA signatures and work with scripts to some extent (usually standard ones only) but they don't have to have the flags used in bitcoin core specially when it comes to message verification. for example none of these exist in SPV clients such as Electrum so their code has to significantly change if they wanted to implement this I.P.:
SPV clients don't verify transactions-- they can't because they don't have access to scriptpubkeys. This means that I wouldn't expect SPV clients to already contain the relevant code.
Quote
also these flags are used during block verification and most of them are there for backward compatibility (eg. whether BIP-66 is enabled to use DERSIG or BIP-112 for OP_CSV), i don't see why they should be used in a message signature verification.
Yucky for the spec to be described in terms of those flags which are presumably not adequately documented.
But the behaviour they signify has to be handled correctly to use generic Bitcoin addresses to process messages.
https://community.ziggo.nl/sport-144/kijk-glory-76-met-badr-hari-benny-adegbuyi-livestream-direct-69598Quote
not to mention that certain things from bitcoin scripts can not even be imported into message verification. some are addressing malleability issues, some OP codes such as those involving locktimes cause a lot of problems as there is no transaction or block to use for verification, the "signature" that is popped from the stack in transaction during script evaluation has a sighash flag which makes no sense in a message since there is no txout/ins to sign based on that,...
The strategy there should be to operate with a dummy, and the spec should be describing it that way.
Quote
take P2PKH and P2WPKH, both of them are the exact same thing there is a pubkey that is hashed using HASH160 and there is a signature that matches that pubkey. in a transaction it makes a difference when creating the hash digest for verification and where the "stack items" are placed, but it is the same when verifying a message.
same with P2SH and P2WSH.
That sounds like just falling into the same trap of only supporting an absurdly narrow subset of keys users use which then stands in the way of new use cases. I think that's just a total waste of time, and actually harmful for the industry.
For example, there have been users that refused to change to multisig-- when they could have otherwise used it, because they couldn't signmessage with it and they'd adopted some workflow that required them to signmessage with their addresses. The old signmessage format has turned out to be a boat anchor that has actually slow the adoption of new techniques and better security in Bitcoin. In hindsight, I think we made a mistake in ever implementing it in the first place.
There is certainly a place in the world for message signing systems that are simpler and less -- well-- weird than Bitcoin script but for those you should use something like PGP or signify.
And I don't intend to defend the BIP322 specifics -- only the general motivation of using script so that you can sign with arbitrary addresses.
It's not done that way because the authors wanted to use some bitcoin core internals, it's that way because its intended to be a generic mechanism that works for _every_ address, unconditionally, even ones that aren't widely in use right now-- and can be easily extended as bitcoin's consensus rules are. The easiest way to do that is to use a bunch of bitcoin internals, but it sounds like it's currently resulting in an unclear spec. -- apparently unclear enough that it didn't make its motivation and justifications clear enough.
Inherently though, anything generic is going to be more work to support for something that doesn't actually support verifying bitcoin signatures. There really isn't any way around that-- but fortunately no one is required to implement it!
tiagocs, pooya87, I think it's important that BIP322 work with arbitrary scripts, for the reasons that gmax has stated. But I also agree that BIP322 is written currently to require very heavy machinery (basically, linking to libbitcoinconsensus to do absolutely anything, and goes out of its way to expose sharp edges of Script. For example, allowing non-low-S signatures and then requiring verifiers to mark this as "inconclusive" appears to serve no purpose.
I wonder if you would support a version of BIP322 which:
1. Required all standardness rules be obeyed (and allowed as an "extension" to validate such signatures, somewhere cordoned off at the end of the BIP where nobody needs to see it)
https://et.water.ca.gov/wev/video-j-v-p-089A6xA7Alv10c.htmlhttps://et.water.ca.gov/wev/video-j-v-p-089.htmlhttps://et.water.ca.gov/wev/video-j-v-p-080.htmlhttps://et.water.ca.gov/wev/it-video-j-v-p-0180.htmlhttps://et.water.ca.gov/wev/it-video-j-v-p-080.htmlhttps://et.water.ca.gov/wev/it-video-j-v-p-010.htmlhttps://et.water.ca.gov/wev/it-video-j-v-p-0.htmlhttps://et.water.ca.gov/wev/it-video-j-v-p-00.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-de.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-nz.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-sa.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-ac.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-ad.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-re.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-ag.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-ai.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-am.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-ao.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-ar.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-as.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-at.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-ba.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-bd.htmlhttps://et.water.ca.gov/wev/PAR-JUV-in-diretta-be.htmlhttp://www.wellspring.edu.lb/ton/fr-Glory-76-01.htmlhttp://www.wellspring.edu.lb/ton/fr-Glory-76-3.htmlhttp://www.wellspring.edu.lb/ton/fr-Glory-76-5.htmlhttp://www.wellspring.edu.lb/ton/fr-Glory-76-6.htmlhttp://www.wellspring.edu.lb/ton/fr-Glory-76-7.htmlhttp://www.wellspring.edu.lb/ton/fr-Glory-76-8.htmlhttp://www.wellspring.edu.lb/ton/fr-Glory-76-9.htmlhttps://igps.ru/xin/vo-Glory-76-02.htmlhttps://igps.ru/xin/vo-Glory-76-03.htmlhttps://igps.ru/xin/vo-Glory-76-04.htmlhttps://igps.ru/xin/vo-Glory-76-07.htmlhttp://dev.truck-ads.com.au/j-p-vot-.htmlhttp://dev.truck-ads.com.au/j-p-vot-1.htmlhttp://dev.truck-ads.com.au/j-p-vot-2.htmlhttp://dev.truck-ads.com.au/j-p-vot-3.htmlhttp://dev.truck-ads.com.au/j-p-vot-4.htmlhttp://dev.truck-ads.com.au/j-p-vot-5.htmlhttp://dev.truck-ads.com.au/j-p-vot-6.htmlhttp://dev.truck-ads.com.au/j-p-vot-7.htmlhttp://dev.truck-ads.com.au/j-p-vot-8.htmlhttp://dev.truck-ads.com.au/j-p-vot-9.htmlhttps://et.water.ca.gov/wev/j-p-vot-.htmlhttps://et.water.ca.gov/wev/j-p-vot-1.htmlhttps://et.water.ca.gov/wev/j-p-vot-2.htmlhttps://et.water.ca.gov/wev/j-p-vot-3.htmlhttps://et.water.ca.gov/wev/j-p-vot-4.htmlhttps://et.water.ca.gov/wev/j-p-vot-5.htmlhttps://et.water.ca.gov/wev/j-p-vot-6.htmlhttps://et.water.ca.gov/wev/j-p-vot-7.htmlhttps://et.water.ca.gov/wev/j-p-vot-8.htmlhttps://et.water.ca.gov/wev/j-p-vot-9.htmlhttps://et.water.ca.gov/ssd1/video-p-v-utc.htmlhttps://et.water.ca.gov/ssd1/video-p-v-utc-01.htmlhttps://et.water.ca.gov/ssd1/video-p-v-sa1.htmlhttps://et.water.ca.gov/ssd1/video-p-v-0sa.htmlhttps://et.water.ca.gov/ssd1/video-p-v-0sa1.htmlhttps://et.water.ca.gov/ssd1/video-p-v-0sa2.htmlhttps://et.water.ca.gov/ssd1/Videos-Canelo-v-Smith-tv-8ha.htmlhttps://et.water.ca.gov/ssd1/Videos-c-v-s-tv-8ha.htmlhttps://et.water.ca.gov/ssd1/Videos-c-v-s-tv-2ma.htmlhttps://et.water.ca.gov/ssd1/Videos-c-v-s-tv-ma1.htmlhttps://et.water.ca.gov/ssd1/Videos-c-v-s-tv-mh.htmlhttps://et.water.ca.gov/ssd1/Videos-c-v-s-tv-mh-247.htmlhttps://community.ziggo.nl/sport-144/kijk-glory-76-met-badr-hari-benny-adegbuyi-livestream-direct-69598https://igps.ru/dkr/glory76-lk-nl-on-t-4.htmlhttps://igps.ru/dkr/glory76-lk-nl-on-tvc4.htmlhttps://igps.ru/dkr/glory76-lk-nl-on-tvc5.htmlhttps://igps.ru/dkr/glory76-lk-nl-on-tvc6.htmlhttps://igps.ru/dkr/glory76-lk-nl-on-tvc7.htmlhttps://igps.ru/dkr/glory-76-rot-e2.htmlhttps://igps.ru/dkr/glory-76-rot-e1.htmlhttps://igps.ru/dkr/eno7-76-rot-e3.htmlhttps://igps.ru/dkr/eno7-76-rot-e2.htmlhttps://igps.ru/vne/it-DAZN-tv-s.htmlhttps://igps.ru/vne/it-D-tv-s.htmlhttps://igps.ru/vne/DirettaD-tv-s.htmlhttps://www.cbre-ea.com/ecl/it-DAZN-tv-s.htmlhttps://www.cbre-ea.com/ecl/it-D-tv-s.htmlhttps://www.cbre-ea.com/ecl/DirettaD-tv-s.htmlhttps://et.water.ca.gov/wev/it-DAZN-tv-s.htmlhttps://et.water.ca.gov/wev/it-D-tv-s.htmlhttps://et.water.ca.gov/wev/DirettaD-tv-s.htmlhttps://et.water.ca.gov/wev/5f0fd-del-campeonato.htmlhttps://et.water.ca.gov/wev/new-del-campeonato.htmlhttps://et.water.ca.gov/wev/25-del-campeonato.html2. Specified what these standardness rules were/meant
3. Allowed implementations to return "inconclusive" for scripts they did not understand, while still permitting them to implement only templates if they really want.
4. Cleaned up the prose a bunch
The first two rules would let you use off-the-shelf Minscript software (such as this implementation in Python to support all widely used scripts except HTLCs, so even if you did not write a full BIP-322 verifier (which would require libbitcoinconsensus or Core) you would still be able to support a wide array of real-world usecases.