Bitcoin Forum
May 24, 2024, 03:52:08 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Private keys of SegWit addresses  (Read 228 times)
MadGamer (OP)
Legendary
*
Offline Offline

Activity: 1568
Merit: 1031


View Profile
February 24, 2018, 02:13:03 PM
 #1

I generated a SegWit address, I got the private keys, I went to Bitaddress to type the PK and get the details. I got 1LnhJTGJJLdaUhP34SMHGwDqkfjFGfAzPQ while the real one is 3BVNuVsxgXSgg4WyD1r6rZxXa11VBFQUkW

I want to know, If I ever give the first address to someone and he send me some bitcoin, will I be able to spend it from the second (the SegWit one)? Let's just assume that the first one is from Blockchain.info and the second is from Trezor.
aleksej996
Sr. Member
****
Offline Offline

Activity: 490
Merit: 389


Do not trust the government


View Profile
February 24, 2018, 02:54:38 PM
 #2

No.

Addresses don't really exist on a protocol level, only transactions.
When someone sends you bitcoins to an address starting with 1, they use a P2PH transaction.
When they send you to the address starting with 3, they use a P2SH transaction.

Since you can't really send coins from an address, just spend UTXO, this question on it's own needs more information to determine what exactly is your concern.
ranochigo
Legendary
*
Offline Offline

Activity: 2982
Merit: 4193



View Profile
February 24, 2018, 03:07:42 PM
Merited by mprep (2), ABCbits (1), MadGamer (1), aleksej996 (1)
 #3

I want to know, If I ever give the first address to someone and he send me some bitcoin, will I be able to spend it from the second (the SegWit one)? Let's just assume that the first one is from Blockchain.info and the second is from Trezor.
I don't think Bitaddress recognise P2SH-P2PWKH yet. The private key for P2SH-P2PWKH is similar to the P2PKH and it's able to generate a legacy address from that private key too.

Since P2SH-P2PWKH, bc1, P2PKH can be generated from the same WIF key, you can retrieve your coins as long as you provide the correct addresses that corresponds to your WIF private key. I would definitely be against doing this though.

You CANNOT, however, be spending a coin in your 3xxx address in a wallet that you've defined to only recognise 1xxx address. (The wallet won't recognise your UTXO from 3xxx address).

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
February 24, 2018, 11:07:07 PM
Merited by ABCbits (3), achow101 (2)
 #4

I generated a SegWit address, I got the private keys, I went to Bitaddress to type the PK and get the details. I got 1LnhJTGJJLdaUhP34SMHGwDqkfjFGfAzPQ while the real one is 3BVNuVsxgXSgg4WyD1r6rZxXa11VBFQUkW
Essentially, private keys are just a very big number. The different address types are then derived from this number in slightly different ways. ie. compressed, uncompressed, SegWit.

So, with the same private key: KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn

Bitaddress.org gives us:
Address (Compressed): 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH
Public Key (compressed, 66 characters [0-9A-F]):
0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798

While segwitaddress.org gives us:
Address: 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN
Public Key: 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
Redeem Script: 0014751e76e8199196d454941c45d1b3a323f1433bd6

Note how the two public keys are the same?

The result of this is that, as always, if you have the correct private key, you will be able to access coins that were assigned to a specific address derived from that private key.


However, to answer your specific question of:
Quote
I want to know, If I ever give the first address to someone and he send me some bitcoin, will I be able to spend it from the second (the SegWit one)? Let's just assume that the first one is from Blockchain.info and the second is from Trezor.
The short answer is NO.

To demonstrate, let us use our private key from above: "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"

As we've seen, this private key generates the addresses:
"Legacy" - 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH
"SegWit" - 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN

You can see by looking at the address history... "1" has a bunch of transactions... "3" has nothing.

So, the coins sent to "1" are completely separated from any coins/transactions sent to "3" (and vice versa)... even though both have the same private key.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
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!