Author

Topic: Do you have an idea for checking P2SH signatures with a website ? (Read 247 times)

sr. member
Activity: 709
Merit: 336
You need someone to develop your Web project ?
Better provide more details on what exactly do you need and there is no Electrum standard maybe you are talking about Legacy and Segwit wallet? You can sign and verify both p2sh segwit and legacy addresses in Electrum.

Hmm, yes it's true that I was not very clear, I wanted to talk about checking the SegtWit Signatures ( As mentioned @bitmover ).


I don't have much knowledge in javascript but if you are looking for some opensource scripts from github take a look at this links below it might help you to make your own JavaScript program that could sign and verify addresses.

- https://github.com/bitcoinjs/bitcoinjs-message


Just added this how to do sign and verifying works.
- https://bitcointalksearch.org/topic/how-to-sign-a-message-990345

Okay, thanks for sharing, I'll see what I can do with these resources Wink



...
Code:
HxdlrefJp37AWwOSrcrziBWRjakOb8o4LCD4xMQzQ4XGCMbISyrECrBisdZW2zZf3HsKkbl+BZwBL1Gkr64MUkk=
decoded:
Code:
1f1765ade7c9a77ec05b0392adcaf38815918da90e6fca382c20f8c4c4334385c608c6c84b2ac40ab062b1d656db365fdc7b0a91b97e059c012f51a4afae0c5249
...

Hm, when I try to decode signature with ( JS ) :
Code:
atob('HxdlrefJp37AWwOSrcrziBWRjakOb8o4LCD4xMQzQ4XGCMbISyrECrBisdZW2zZf3HsKkbl+BZwBL1Gkr64MUkk=')

I have in response :
Code:
e­çɧ~À[’­Êóˆ‘�©oÊ8, øÄÄ3C…ÆÆÈK*Ä
°b±ÖVÛ6_Ü{
‘¹~œ/Q¤¯® RI

Is this normal ?

What exactly do I replace next ?

Otherwise, in addition to checking Brainwallet, I will try to integrate "bitcoinjs-message" ( Thank @BitMaxz ) Wink

If the checks work with this script, then it will be a bonus in addition to Brainwallet.
legendary
Activity: 3472
Merit: 3217
Playbet.io - Crypto Casino and Sportsbook
I understand what you mean.

Until now, the idea was always to provide a link and a screen for verification. I may be able to learn to check addresses with Electrum ( But it seems pretty complicated ).

Can you tell me more about the Electrum standard ?

In which case does it work ?

How to reproduce that in JavaScript ?

Thank you in advance.

Better provide more details on what exactly do you need and there is no Electrum standard maybe you are talking about Legacy and Segwit wallet? You can sign and verify both p2sh segwit and legacy addresses in Electrum.

If your plan is to check the sign message of the p2sh legacy address you can easily make a signed message or generate a signature in Electrum by going to addresses then right-click the address you would like to sign a message.

You can also use that to verify the signature by pasting the message, address, and signature under that screen.

I don't have much knowledge in javascript but if you are looking for some opensource scripts from github take a look at this links below it might help you to make your own JavaScript program that could sign and verify addresses.

- https://github.com/bitcoinjs/bitcoinjs-message


Just added this how to do sign and verifying works.
- https://bitcointalksearch.org/topic/how-to-sign-a-message-990345
sr. member
Activity: 709
Merit: 336
You need someone to develop your Web project ?
I understand what you mean.

Until now, the idea was always to provide a link and a screen for verification. I may be able to learn to check addresses with Electrum ( But it seems pretty complicated ).

Can you tell me more about the Electrum standard ?

In which case does it work ?

How to reproduce that in JavaScript ?

Thank you in advance.
legendary
Activity: 2352
Merit: 6089
bitcoindata.science
The problem I see with this method, which is a workaround, is that it will not be widely accepted.

Usually people sign messages to prove that they own the funds of a certain address.
I know that this method prove that you have the private key, because both addresses are generated from the same private keys. However, will people accept this signature as proof? You are not signing from a segwit address after all.

 there is no standard that is widely accepted over different wallets, and most people won't understand that this legacy address is derived from the same private key.

Isn't it better just to use Electrum standard for verification? Then your website   could verify segwit addresses messages directly and it could also be confirmed in Electrum wallet.

Electrum made it own verification method, which is not standard and not accepted by the core, but it is better than this workaround imo.
sr. member
Activity: 709
Merit: 336
You need someone to develop your Web project ?
Hello,

Thank you very much for taking the time, once again, to help me with this !

I will not have time to try all that, I see to test / integrate this tomorrow or after tomorrow.

Thank you very much  ! Wink
legendary
Activity: 3472
Merit: 10611
similar to Bech32 addresses you will have to use a workaround and "fool" the silly tool to work for you. and again i would suggest using a cryptography library written specifically for bitcoin to verify signatures instead.

but here is the workaround you could use in https://jhoenicke.github.io/brainwallet.github.io/#verify
explanation first (if you wanted to use a library some day):
the thing about nested SegWit (note that it is not P2SH, it is P2WPKH nested in a P2SH script which is why signing a message works thanks to only having 1 key) is that they are hash of the hash of script that contains the public key so the steps to recover the public key is similar but you'll have to build the script first (OP_0 ) then the address is build similar to any P2SH address (OP_HASH160 OP_Equal) then base58 encode with checksum using 0x05 as version byte.

the workaround:
there is not much of a standard for message signing in general and there is none for nested SegWit ones. the "standard" that exists is encoding r and s and another byte referred to as "v" or recovery ID so the total size is 32+32+1=65 bytes tops. this byte is the first byte in bitcoin message signatures.
Trezor has come up with their own "standard" which they basically do the signing as before, get the recovery ID and then add another 4 bytes to it. that site supports this format!
a workaround to use would be to first decode the signature using Base64 (you can perform some additional checks here such as checking length is not bigger than 65, the first byte is between 27 and 37 [the range may not be accurate]) then adding 4 to the first byte of the decoded result and then encoding it with Base64 again.
example: https://bitcointalksearch.org/topic/m.52763726
Code:
HxdlrefJp37AWwOSrcrziBWRjakOb8o4LCD4xMQzQ4XGCMbISyrECrBisdZW2zZf3HsKkbl+BZwBL1Gkr64MUkk=
decoded:
Code:
1f1765ade7c9a77ec05b0392adcaf38815918da90e6fca382c20f8c4c4334385c608c6c84b2ac40ab062b1d656db365fdc7b0a91b97e059c012f51a4afae0c5249
0x1f + 0x04 = 0x23
Code:
IxdlrefJp37AWwOSrcrziBWRjakOb8o4LCD4xMQzQ4XGCMbISyrECrBisdZW2zZf3HsKkbl+BZwBL1Gkr64MUkk=

now verify using that site
sr. member
Activity: 709
Merit: 336
You need someone to develop your Web project ?
Hello,

I want to tell you, everything is said in the title !

I am looking for a method to check the type P2SH signatures with a website?

A bit like this kind of method :

https://bitcointalk.org/index.php?topic=5198585.0-

If you have an idea, do not hesitate, it interests me to integrate in the bot.

Thank you in advance !
Jump to: