Bitcoin Forum
May 04, 2024, 11:22:05 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: How does one derive a SegWit address from a legacy address? [0.001 BTC Reward!]  (Read 405 times)
StackGambler (OP)
Full Member
***
Offline Offline

Activity: 434
Merit: 101

YouTuber, gambler, and scam-buster.


View Profile
March 29, 2019, 09:57:07 AM
Last edit: March 29, 2019, 01:19:45 PM by StackGambler
 #1

Hello,

I signed a message from my Ledger, and selected the address 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB to sign from. When I signed the message, it got signed from the address 1CmXjL8V2UJ8jQnMmVNCJtyTzSHPY4gyoR, which I presume is the legacy address from which the first one was derived.

My question is, is there some online tool that can help me see the link between the two addresses, or how one or derived from the other? Thank you.

I like gambling. Probably currently trying to figure out how to pay next month's rent.
1714864925
Hero Member
*
Offline Offline

Posts: 1714864925

View Profile Personal Message (Offline)

Ignore
1714864925
Reply with quote  #2

1714864925
Report to moderator
1714864925
Hero Member
*
Offline Offline

Posts: 1714864925

View Profile Personal Message (Offline)

Ignore
1714864925
Reply with quote  #2

1714864925
Report to moderator
1714864925
Hero Member
*
Offline Offline

Posts: 1714864925

View Profile Personal Message (Offline)

Ignore
1714864925
Reply with quote  #2

1714864925
Report to moderator
Make sure you back up your wallet regularly! Unlike a bank account, nobody can help you if you lose access to your BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714864925
Hero Member
*
Offline Offline

Posts: 1714864925

View Profile Personal Message (Offline)

Ignore
1714864925
Reply with quote  #2

1714864925
Report to moderator
1714864925
Hero Member
*
Offline Offline

Posts: 1714864925

View Profile Personal Message (Offline)

Ignore
1714864925
Reply with quote  #2

1714864925
Report to moderator
BitcoinGirl.Club
Legendary
*
Offline Offline

Activity: 2772
Merit: 2712


Farewell LEO: o_e_l_e_o


View Profile WWW
March 29, 2019, 10:29:20 AM
 #2

Hello,

I signed a message from my Ledger, and selected the address 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB to sign from. When I signed the message, it got signed from the address 1CmXjL8V2UJ8jQnMmVNCJtyTzSHPY4gyoR, which I presume is the legacy address from which the first one was derived.

My question is, is there some online tool that can help me see the link between the two addresses, or how one or derived from the other? Thank you.

Legacy starts with 1

Segwit starts with 3 or bc1


In Ledger, you can not sing a message from a segwit address so by default it signs you a legacy address.

▄▄███████▄▄
▄██████████████▄
▄██████████████████▄
▄████▀▀▀▀███▀▀▀▀█████▄
▄█████████████▄█▀████▄
███████████▄███████████
██████████▄█▀███████████
██████████▀████████████
▀█████▄█▀█████████████▀
▀████▄▄▄▄███▄▄▄▄████▀
▀██████████████████▀
▀███████████████▀
▀▀███████▀▀
.
 MΞTAWIN  THE FIRST WEB3 CASINO   
.
.. PLAY NOW ..
StackGambler (OP)
Full Member
***
Offline Offline

Activity: 434
Merit: 101

YouTuber, gambler, and scam-buster.


View Profile
March 29, 2019, 10:33:54 AM
 #3

Hello,

I signed a message from my Ledger, and selected the address 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB to sign from. When I signed the message, it got signed from the address 1CmXjL8V2UJ8jQnMmVNCJtyTzSHPY4gyoR, which I presume is the legacy address from which the first one was derived.

My question is, is there some online tool that can help me see the link between the two addresses, or how one or derived from the other? Thank you.

Legacy starts with 1

Segwit starts with 3 or bc1


In Ledger, you can not sing a message from a segwit address so by default it signs you a legacy address.


Yep, I surmised as much. What I'd like to know is, how do I see the list of SegWit addresses linked to that legacy address? I'd like to give proof of funds from a 3XXX address rather than a 1XXX address, so I want to figure out how the two are linked.

I like gambling. Probably currently trying to figure out how to pay next month's rent.
Heisenberg_Hunter
Legendary
*
Offline Offline

Activity: 1583
Merit: 1276


Heisenberg Design Services


View Profile WWW
March 29, 2019, 11:14:37 AM
Merited by poordeveloper (1)
 #4

, or how one or derived from the other? Thank you.

In order to understand how the addresses are generated, you need to have an insight on how the public keys and private keys are derived based on the elliptic curve algorithm which is being followed in the bitcoin. Every address is generated from the private keys. With a private key you can generate either a legacy address (that starts with 1) or a segregated witness address commonly known as segwit (that starts with 3 or bc1). Some wallets like electrum can generate only addresses which are of legacy type or native segwit or bech32 type.

A public key is generally derived from the private key with a help of one way multiplication function. This means that, you can generate a public key from the private key but you cannot do the other way (i.e a private key cannot be derived from a public key). A private key is a ordinary number which lies in between 1 and 2^256. I am not going deep inside about private keys and their functions, as it would become slightly off-topic and the post would become so lengthy and cumbersome.

A private key is a hexadecimal representation of 256 bit random number. From that hexadecimal number, you generate the public key by doing a multiplication. This multiplication can be represented by

K = k * G

where

G = Constant from the elliptic curve
k = Private Key
K = Public

The constant G is derived from Elliptic Curve and when you multiply your generated Private Key with the Constant, it will yield a new string of characters known as the public key.

Note that, it is a one way function where only multiplication is possible and dividing Public Key with constant won't yield you the Private Key.

Legacy Addresses

Once you have the Public Key, you can either generate a legacy address or a segwit address. A legacy address is the common address used in the early days and will generate a higher transaction size. With higher transaction sizes, you need to pay higher fees. Here with the generated public key, you will double hash them to get a resulting legacy address.

The public key is first hashed with Sha256 algorithm and the resulting number is hashed with RiPEMD160 algorithm. We can simply write this as,

Address = RIPEMD160[SHA256[PubKey]]]

The resulting version of the hash is longer enough, hence they are encoded using Base58 encoding method which brings down the total character to 58.

P2SH Addresses

A P2SH is similar to the hashing function, but here we don't hash the public key rather we double hash the script. Addresses that start with 3 are generally called as p2sh rather than calling them as segwit. Segwit removes unwanted witnesses which increases the size of a transaction significantly. By reducing the space, more transactions can be included in a block which certainly helps in scalability of the bitcoin network.

Yep, I surmised as much. What I'd like to know is, how do I see the list of SegWit addresses linked to that legacy address? I'd like to give proof of funds from a 3XXX address rather than a 1XXX address, so I want to figure out how the two are linked.
They are linked together only by private keys. With a single private key, you can either generate a legacy or a segwit address.
StackGambler (OP)
Full Member
***
Offline Offline

Activity: 434
Merit: 101

YouTuber, gambler, and scam-buster.


View Profile
March 29, 2019, 11:31:52 AM
 #5

Thanks for the detailed response, Heisenberg_Hunter.

What I'm getting at is, how can I prove that I own the funds present at 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB if I can only sign a message from 1CmXjL8V2UJ8jQnMmVNCJtyTzSHPY4gyoR? Is it impossible for me to prove I own those funds simply because they are stored in a SegWit address, or is there some online app or block explorer that can prove that a signed message from 1CmXjL8V2UJ8jQnMmVNCJtyTzSHPY4gyoR also corresponds to the address 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB?

I like gambling. Probably currently trying to figure out how to pay next month's rent.
AdolfinWolf
Legendary
*
Offline Offline

Activity: 1946
Merit: 1427


View Profile
March 29, 2019, 11:38:13 AM
 #6

Thanks for the detailed response, Heisenberg_Hunter.

What I'm getting at is, how can I prove that I own the funds present at 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB if I can only sign a message from 1CmXjL8V2UJ8jQnMmVNCJtyTzSHPY4gyoR? Is it impossible for me to prove I own those funds simply because they are stored in a SegWit address, or is there some online app or block explorer that can prove that a signed message from 1CmXjL8V2UJ8jQnMmVNCJtyTzSHPY4gyoR also corresponds to the address 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB?
In theory, (atleast i think), you should be able to prove correlation if you've spend funds from both of the adresses.

Once you spend funds, the public key becomes known, which, should be the same for both of the adresses? (Not entirely sure if this is actually the case though.)

Otherwise, no, i don't think there's any way to prove to someone without the private key that you own both of the adresses. (Unless you use some sort of chain analysis as proof.)

TryNinja
Legendary
*
Offline Offline

Activity: 2828
Merit: 6977



View Profile WWW
March 29, 2019, 11:41:54 AM
 #7

AFAIK, there is no way to prove one is connected to the other without providing your private key.

But you should be able to use a different wallet that supports signing messages with Segwit addresses to do it.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
StackGambler (OP)
Full Member
***
Offline Offline

Activity: 434
Merit: 101

YouTuber, gambler, and scam-buster.


View Profile
March 29, 2019, 11:46:30 AM
 #8

AFAIK, there is no way to prove one is connected to the other without providing your private key.

But you should be able to use a different wallet that supports signing messages with Segwit addresses to do it.

Well, that sucks. I just got back after locking my Ledger in a safe deposit box in Malaysia  Undecided

I like gambling. Probably currently trying to figure out how to pay next month's rent.
TryNinja
Legendary
*
Offline Offline

Activity: 2828
Merit: 6977



View Profile WWW
March 29, 2019, 11:57:25 AM
 #9

AFAIK, there is no way to prove one is connected to the other without providing your private key.

But you should be able to use a different wallet that supports signing messages with Segwit addresses to do it.

Well, that sucks. I just got back after locking my Ledger in a safe deposit box in Malaysia  Undecided
Oh sorry, I actually thought you were talking about Electrum instead of Ledger for some reason. Exporting the private key to sign it in a different wallet would break your hardware wallet security. So that’s not recommended.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
March 29, 2019, 11:58:33 AM
Merited by Heisenberg_Hunter (5), poordeveloper (2), LoyceV (1), Pmalek (1), StackGambler (1)
 #10

G = Constant from the elliptic curve
The constant G is derived from Elliptic Curve and when you multiply your generated Private Key with the Constant, it will yield a new string of characters known as the public key.
This part is false.
G is not exactly a "constant" and is not derived from the curve. G is one of the point on the curve that we have chosen as the "generator" of the curve. And that means multiplying any value from 1 to order of G yields another point (not a string of characters!!) on the curve which would be your public key. And that is the basic of asymmetric cryptography.

A legacy address is the common address used in the early days and will generate a higher transaction size.
This is false. Legacy transactions don't have higher size, they have higher weight.

Address = Base58check_encode(version_byte || RIPEMD160[SHA256[PubKey]]])
FTFY

The resulting version of the hash is longer enough, hence they are encoded using Base58 encoding method which brings down the total character to 58.
This if false. The number of characters can be different and it is between 25-34.
58 is the total number of characters in the base we are encoding this to. eg. Base-16 has 16 characters.


In any case to answer OP's question the problem is that when you are proving ownership of an address, what you really are doing is that you are creating a signature similar to when you sign a transaction. And when others verify that, what they really do is that they recover your public key from that signature then verify whether it is valid or not.
Where does address come in? Basically nowhere. We also include the address because when they recover your public key from your signature they might end up with multiple possible public keys, including the address helps narrow the possibilities down to only 1.
What about SegWit addresses come in? The problem is that there still is no standard for them. I saw one of these hardware wallets (Trezor?) had a personal defined standard where they added 1 byte to the first byte of the signatures. But apart from that, you won't find anything globally accepted.

Since this IS possible your only option is to ask the wallet developers to add such functionality for you or come to some sort of agreement with the other party you are trying to do a "proof of funds" with to come up with some sort of standard like sending a transaction out of the address with a message attached would work but it will cost you fees.

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
StackGambler (OP)
Full Member
***
Offline Offline

Activity: 434
Merit: 101

YouTuber, gambler, and scam-buster.


View Profile
March 29, 2019, 12:06:00 PM
 #11



In any case to answer OP's question the problem is that when you are proving ownership of an address, what you really are doing is that you are creating a signature similar to when you sign a transaction. And when others verify that, what they really do is that they recover your public key from that signature then verify whether it is valid or not.
Where does address come in? Basically nowhere. We also include the address because when they recover your public key from your signature they might end up with multiple possible public keys, including the address helps narrow the possibilities down to only 1.
What about SegWit addresses come in? The problem is that there still is no standard for them. I saw one of these hardware wallets (Trezor?) had a personal defined standard where they added 1 byte to the first byte of the signatures. But apart from that, you won't find anything globally accepted.

Since this IS possible your only option is to ask the wallet developers to add such functionality for you or come to some sort of agreement with the other party you are trying to do a "proof of funds" with to come up with some sort of standard like sending a transaction out of the address with a message attached would work but it will cost you fees.

Thank you, this is the closest thing to the answer I'm looking for in the thread.

Another question: I've locked up my Ledger for the time being. Is it possible to prove the link between the 1XXX address and the 3XXX address without having to re-sign another transaction?

By the way, here is the signature in question: https://bitcointalk.org/index.php?topic=996318.msg50361478#msg50361478

I like gambling. Probably currently trying to figure out how to pay next month's rent.
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
March 29, 2019, 12:31:36 PM
 #12

Thank you, this is the closest thing to the answer I'm looking for in the thread.

Another question: I've locked up my Ledger for the time being. Is it possible to prove the link between the 1XXX address and the 3XXX address without having to re-sign another transaction?

By the way, here is the signature in question: https://bitcointalk.org/index.php?topic=996318.msg50361478#msg50361478

I have actually never had the chance to learn how nested-SegWit addresses work. But since they are derived from one public key and by publishing your signature + your address (1xxx) you are revealing your public key, it should not be hard to get the 3xxx address from it.
The public key of the address you linked is:
Code:
02ec5d3485b27e3721a34f71065892f1d3be2d7b2f57970d768239810e0074e978

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
AdolfinWolf
Legendary
*
Offline Offline

Activity: 1946
Merit: 1427


View Profile
March 29, 2019, 12:39:11 PM
 #13

Thank you, this is the closest thing to the answer I'm looking for in the thread.

Another question: I've locked up my Ledger for the time being. Is it possible to prove the link between the 1XXX address and the 3XXX address without having to re-sign another transaction?

By the way, here is the signature in question: https://bitcointalk.org/index.php?topic=996318.msg50361478#msg50361478

I have actually never had the chance to learn how nested-SegWit addresses work. But since they are derived from one public key and by publishing your signature + your address (1xxx) you are revealing your public key, it should not be hard to get the 3xxx address from it.
The public key of the address you linked is:
Code:
02ec5d3485b27e3721a34f71065892f1d3be2d7b2f57970d768239810e0074e978
Just curious, is there any documentation as to how you just did that?

StackGambler (OP)
Full Member
***
Offline Offline

Activity: 434
Merit: 101

YouTuber, gambler, and scam-buster.


View Profile
March 29, 2019, 12:40:51 PM
 #14

Thank you, this is the closest thing to the answer I'm looking for in the thread.

Another question: I've locked up my Ledger for the time being. Is it possible to prove the link between the 1XXX address and the 3XXX address without having to re-sign another transaction?

By the way, here is the signature in question: https://bitcointalk.org/index.php?topic=996318.msg50361478#msg50361478

I have actually never had the chance to learn how nested-SegWit addresses work. But since they are derived from one public key and by publishing your signature + your address (1xxx) you are revealing your public key, it should not be hard to get the 3xxx address from it.
The public key of the address you linked is:
Code:
02ec5d3485b27e3721a34f71065892f1d3be2d7b2f57970d768239810e0074e978

That's pretty cool, thanks.

So I've been Googling around. Using validateaddress in Bitcoin Core gives me "scriptPubKey": "a914a84658b58e2bd0e62bfb1905dfcc19415bf99ff387" when I submit the address 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB. I wonder if this has any relation to the public key or the 1XXX address.

I like gambling. Probably currently trying to figure out how to pay next month's rent.
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
March 29, 2019, 01:00:07 PM
Merited by AdolfinWolf (1)
 #15

Just curious, is there any documentation as to how you just did that?
Standards for Efficient Cryptography SEC 1: Elliptic Curve Cryptography
Section 4.1.6 Public Key Recovery Operation (Page 47)

That's pretty cool, thanks.

So I've been Googling around. Using validateaddress in Bitcoin Core gives me "scriptPubKey": "a914a84658b58e2bd0e62bfb1905dfcc19415bf99ff387" when I submit the address 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB. I wonder if this has any relation to the public key or the 1XXX address.
I honestly don't know. I still have not been able to figure out how this particular type of address is derived from keys.

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
StackGambler (OP)
Full Member
***
Offline Offline

Activity: 434
Merit: 101

YouTuber, gambler, and scam-buster.


View Profile
March 29, 2019, 01:17:09 PM
 #16

Just curious, is there any documentation as to how you just did that?
Standards for Efficient Cryptography SEC 1: Elliptic Curve Cryptography
Section 4.1.6 Public Key Recovery Operation (Page 47)

That's pretty cool, thanks.

So I've been Googling around. Using validateaddress in Bitcoin Core gives me "scriptPubKey": "a914a84658b58e2bd0e62bfb1905dfcc19415bf99ff387" when I submit the address 3H2miXstFo3jRFfz5ekcdZJNMfGSYHeNvB. I wonder if this has any relation to the public key or the 1XXX address.
I honestly don't know. I still have not been able to figure out how this particular type of address is derived from keys.

Damn, that sucks.

Welp, for the next 24 hours, I'll give a 0.001 BTC reward to anyone who can figure out how to link the 1XXX address to the 3XXX address without me having to retrieve the Ledger from its stored location. I sure as hell can't figure it out; maybe someone else can. The reward will expire after a day, because I may want to spend my money after that  Grin

I like gambling. Probably currently trying to figure out how to pay next month's rent.
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
March 29, 2019, 01:35:25 PM
Merited by HCP (5)
 #17

how to link the 1XXX address to the 3XXX address without me having to retrieve the Ledger from its stored location.

Things you can not do:
- Get the 1xxx address from 3xxx address
Things you can do:
- Get the 3xxx address from the 1xxx address1
- Get either 1xxx or 3xxx or basically anything else if you have published a signature with a message that you signed (this includes transactions that were spent from that key)!2

Here are the steps for (1)
1. Having the address starting with 1, perform a Base58check_decode on it to get the byte array remove the first byte as it is the version byte. The next 20 bytes are the hash160 (you can also open the address in blockchain.com explorer and it shows you the hash160 result!)
2. Write the "witness script" for the current version of SegWit which is
Code:
0x00 0x14 <hash160>
3. Perform HASH160 hash on the result of step 2
Code:
RIPEMD160(SHA256(<witness script>))
4. Append the P2SH version byte (=0x05) to the beginning of the result of step 3 and perform a Base58Check_encode on the result
Code:
Base58.EncodeWithCheckSum(0x05 || <hash160>)
=> now you have your P2SH-P2WPKH address that starts with 3.

Here are the steps for (2):
1. Decode your signature (base-64) and throw away the first byte. Then your first 32 bytes are your r value in little-endian order and the second one is s.
2. Append the default message to  your message (Bitcoin Signed Message:\n) with its length. Compute double SHA256 of it. This is the "message".
3. Recover your public key by knowing (r,s) and message. (I haven't released my library yet to add that as a reference but you should be able to find  this option in any library such as OpenSSL that has ECDSA capabilities)
4. Perform HASH160 on the compressed public key as bytes.
5. Feed it to step 2 of above.

This is the reference but in my opinion it is very vague: https://bitcoincore.org/en/segwit_wallet_dev/

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
StackGambler (OP)
Full Member
***
Offline Offline

Activity: 434
Merit: 101

YouTuber, gambler, and scam-buster.


View Profile
March 29, 2019, 01:46:18 PM
 #18

how to link the 1XXX address to the 3XXX address without me having to retrieve the Ledger from its stored location.

Things you can not do:
- Get the 1xxx address from 3xxx address
Things you can do:
- Get the 3xxx address from the 1xxx address1
- Get either 1xxx or 3xxx or basically anything else if you have published a signature with a message that you signed (this includes transactions that were spent from that key)!2

Here are the steps for (1)
1. Having the address starting with 1, perform a Base58check_decode on it to get the byte array remove the first byte as it is the version byte. The next 20 bytes are the hash160 (you can also open the address in blockchain.com explorer and it shows you the hash160 result!)
2. Write the "witness script" for the current version of SegWit which is
Code:
0x00 0x14 <hash160>
3. Perform HASH160 hash on the result of step 2
Code:
RIPEMD160(SHA256(<witness script>))
4. Append the P2SH version byte (=0x05) to the beginning of the result of step 3 and perform a Base58Check_encode on the result
Code:
Base58.EncodeWithCheckSum(0x05 || <hash160>)
=> now you have your P2SH-P2WPKH address that starts with 3.

Here are the steps for (2):
1. Decode your signature (base-64) and throw away the first byte. Then your first 32 bytes are your r value in little-endian order and the second one is s.
2. Append the default message to  your message (Bitcoin Signed Message:\n) with its length. Compute double SHA256 of it. This is the "message".
3. Recover your public key by knowing (r,s) and message. (I haven't released my library yet to add that as a reference but you should be able to find  this option in any library such as OpenSSL that has ECDSA capabilities)
4. Perform HASH160 on the compressed public key as bytes.
5. Feed it to step 2 of above.

This is the reference but in my opinion it is very vague: https://bitcoincore.org/en/segwit_wallet_dev/

Thanks. So I'm trying to figure out how to do the first method, but I'm not sure which app or website to input the steps in. I tried it in Bitcoin Core and coinb.in; didn't seem to work. Please do excuse my ineptitude.

I like gambling. Probably currently trying to figure out how to pay next month's rent.
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
March 29, 2019, 01:57:45 PM
 #19

Thanks. So I'm trying to figure out how to do the first method, but I'm not sure which app or website to input the steps in. I tried it in Bitcoin Core and coinb.in; didn't seem to work. Please do excuse my ineptitude.

Well those applications all have the code to do all these stuff but they don't usually expose the functions through any kind of CLI because it is not used. You'll have to write something yourself. I can put together something for you in c# for the first part only (not the public key recovery) if you like.

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
StackGambler (OP)
Full Member
***
Offline Offline

Activity: 434
Merit: 101

YouTuber, gambler, and scam-buster.


View Profile
March 29, 2019, 01:59:27 PM
 #20

Thanks. So I'm trying to figure out how to do the first method, but I'm not sure which app or website to input the steps in. I tried it in Bitcoin Core and coinb.in; didn't seem to work. Please do excuse my ineptitude.

Well those applications all have the code to do all these stuff but they don't usually expose the functions through any kind of CLI because it is not used. You'll have to write something yourself. I can put together something for you in c# for the first part only (not the public key recovery) if you like.

That would be a massive help! If you can code up something that links the two addresses, or point me towards an online resource that does the job, it would be amazing. You'll get the reward as well, if you care for that sort of thing  Tongue Bless you!

I like gambling. Probably currently trying to figure out how to pay next month's rent.
Pages: [1] 2 »  All
  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!