Bitcoin Forum
April 16, 2024, 08:03:00 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Do you have an idea for checking P2SH signatures with a website ?  (Read 227 times)
lulucrypto (OP)
Sr. Member
****
Offline Offline

Activity: 709
Merit: 335


You need someone to develop your Web project ?


View Profile WWW
November 10, 2019, 10:54:11 PM
Merited by ABCbits (1)
 #1

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 !

Web developer.0x0AB75f882ef60731e02212fFcfBA7C5ce6e0B4F3
Bitcoin addresses contain a checksum, so it is very unlikely that mistyping an address will cause you to lose money.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713297780
Hero Member
*
Offline Offline

Posts: 1713297780

View Profile Personal Message (Offline)

Ignore
1713297780
Reply with quote  #2

1713297780
Report to moderator
pooya87
Legendary
*
Offline Offline

Activity: 3416
Merit: 10487



View Profile
November 11, 2019, 04:43:55 AM
Merited by nc50lc (2), ABCbits (1), Heisenberg_Hunter (1), lulucrypto (1)
 #2

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 <Hash160 of pubkey>) then the address is build similar to any P2SH address (OP_HASH160 <Hash160 of script> 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://bitcointalk.org/index.php?topic=996318.msg52763726#msg52763726
Code:
HxdlrefJp37AWwOSrcrziBWRjakOb8o4LCD4xMQzQ4XGCMbISyrECrBisdZW2zZf3HsKkbl+BZwBL1Gkr64MUkk=
decoded:
Code:
1f1765ade7c9a77ec05b0392adcaf38815918da90e6fca382c20f8c4c4334385c608c6c84b2ac40ab062b1d656db365fdc7b0a91b97e059c012f51a4afae0c5249
0x1f + 0x04 = 0x23
Code:
IxdlrefJp37AWwOSrcrziBWRjakOb8o4LCD4xMQzQ4XGCMbISyrECrBisdZW2zZf3HsKkbl+BZwBL1Gkr64MUkk=

now verify using that site

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
lulucrypto (OP)
Sr. Member
****
Offline Offline

Activity: 709
Merit: 335


You need someone to develop your Web project ?


View Profile WWW
November 11, 2019, 09:32:30 PM
 #3

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

Web developer.0x0AB75f882ef60731e02212fFcfBA7C5ce6e0B4F3
bitmover
Legendary
*
Offline Offline

Activity: 2268
Merit: 5869


bitcoindata.science


View Profile WWW
November 11, 2019, 11:42:16 PM
 #4

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.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
lulucrypto (OP)
Sr. Member
****
Offline Offline

Activity: 709
Merit: 335


You need someone to develop your Web project ?


View Profile WWW
November 12, 2019, 09:38:10 PM
 #5

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.

Web developer.0x0AB75f882ef60731e02212fFcfBA7C5ce6e0B4F3
BitMaxz
Legendary
*
Online Online

Activity: 3220
Merit: 2935


Block halving is coming.


View Profile WWW
November 12, 2019, 10:43:48 PM
Last edit: November 12, 2019, 10:55:19 PM by BitMaxz
 #6

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://bitcointalk.org/index.php?topic=990345.0

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
lulucrypto (OP)
Sr. Member
****
Offline Offline

Activity: 709
Merit: 335


You need someone to develop your Web project ?


View Profile WWW
November 16, 2019, 02:42:22 PM
Last edit: November 16, 2019, 08:57:44 PM by lulucrypto
 #7

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://bitcointalk.org/index.php?topic=990345.0

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.

Web developer.0x0AB75f882ef60731e02212fFcfBA7C5ce6e0B4F3
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!