Bitcoin Forum
May 09, 2024, 03:10:37 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How Does Key Sweeping Work?  (Read 769 times)
ranlo (OP)
Legendary
*
Offline Offline

Activity: 1974
Merit: 1007



View Profile
May 18, 2014, 11:26:05 PM
 #1

Hopefully this is the right area to ask this. I'm wondering how key sweeping works. I know there are clients and sites that can do it, but I don't quite follow. It's based on the private key, of course, but when there can be billions of different public keys generated with any given private key, how is it that the client can sweep every possibility (and can usually do it within a second or two)?

Or am I completely misunderstanding how the blockchain is read and how the keys work?

https://nanogames.io/i-bctalk-n/
Message for info on how to get kickbacks on sites like Nano (above) and CryptoPlay!
1715267437
Hero Member
*
Offline Offline

Posts: 1715267437

View Profile Personal Message (Offline)

Ignore
1715267437
Reply with quote  #2

1715267437
Report to moderator
1715267437
Hero Member
*
Offline Offline

Posts: 1715267437

View Profile Personal Message (Offline)

Ignore
1715267437
Reply with quote  #2

1715267437
Report to moderator
Even in the event that an attacker gains more than 50% of the network's computational power, only transactions sent by the attacker could be reversed or double-spent. The network would not be destroyed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715267437
Hero Member
*
Offline Offline

Posts: 1715267437

View Profile Personal Message (Offline)

Ignore
1715267437
Reply with quote  #2

1715267437
Report to moderator
1715267437
Hero Member
*
Offline Offline

Posts: 1715267437

View Profile Personal Message (Offline)

Ignore
1715267437
Reply with quote  #2

1715267437
Report to moderator
Foxpup
Legendary
*
Offline Offline

Activity: 4354
Merit: 3044


Vile Vixen and Miss Bitcointalk 2021-2023


View Profile
May 19, 2014, 12:27:55 AM
 #2

there can be billions of different public keys generated with any given private key
Where'd you get this crazy idea? There is only one public key for a given private key, and only two ways that public key can be represented (compressed and uncompressed), giving two addresses. Not billions. Note also that private keys in wallet import format specify which of the two addresses should be used.

Will pretend to do unspeakable things (while actually eating a taco) for bitcoins: 1K6d1EviQKX3SVKjPYmJGyWBb1avbmCFM4
I am not on the scammers' paradise known as Telegram! Do not believe anyone claiming to be me off-forum without a signed message from the above address! Accept no excuses and make no exceptions!
ranlo (OP)
Legendary
*
Offline Offline

Activity: 1974
Merit: 1007



View Profile
May 19, 2014, 12:39:34 AM
 #3

there can be billions of different public keys generated with any given private key
Where'd you get this crazy idea? There is only one public key for a given private key, and only two ways that public key can be represented (compressed and uncompressed), giving two addresses. Not billions. Note also that private keys in wallet import format specify which of the two addresses should be used.

I think I misrepresented the question.

I guess the proper question is how you can sweep all the addresses when there are billions of those.

https://nanogames.io/i-bctalk-n/
Message for info on how to get kickbacks on sites like Nano (above) and CryptoPlay!
cp1
Hero Member
*****
Offline Offline

Activity: 616
Merit: 500


Stop using branwallets


View Profile
May 19, 2014, 12:39:55 AM
 #4

There are many private keys for each bitcoin address, not the other way around.  But don't worry about that.

Perhaps you're thinking of a deterministic seed?  Those generate a private key / public key pair by incrementing a counter, so you just need to keep incrementing the counter until you stop finding addresses with activity on them.

Guide to armory offline install on USB key:  https://bitcointalk.org/index.php?topic=241730.0
ranlo (OP)
Legendary
*
Offline Offline

Activity: 1974
Merit: 1007



View Profile
May 19, 2014, 12:41:30 AM
 #5

There are many private keys for each bitcoin address, not the other way around.  But don't worry about that.

Perhaps you're thinking of a deterministic seed?  Those generate a private key / public key pair by incrementing a counter, so you just need to keep incrementing the counter until you stop finding addresses with activity on them.

I added a corrected question. It was addresses I was thinking of, not public keys. That's my fault (I'm still new to HOW Bitcoin and others work, which is also why I'm asking the question, :p).

So address-wise... how are you able to sweep all possible addresses when they are generated randomly to begin with?

https://nanogames.io/i-bctalk-n/
Message for info on how to get kickbacks on sites like Nano (above) and CryptoPlay!
cp1
Hero Member
*****
Offline Offline

Activity: 616
Merit: 500


Stop using branwallets


View Profile
May 19, 2014, 12:52:57 AM
 #6

I added a corrected question. It was addresses I was thinking of, not public keys. That's my fault (I'm still new to HOW Bitcoin and others work, which is also why I'm asking the question, :p).

So address-wise... how are you able to sweep all possible addresses when they are generated randomly to begin with?

As Foxpup said, the private key really only corresponds to one address.  All sweeping means is that you spend whatever is in that address and send it to a new one.

Imagine having an online wallet with address A
And a cold offline wallet with address B, where I've written the private key on a piece of paper.

If I open my online wallet and sweep that offline private key that corresponds to address B then it'll send whatever is in B to address A.  My online wallet still only has address A, but it has all the coins from B in that address A as well.

That's different than importing a private key.  If I imported the private B key into my online wallet then it would have both addresses A and B.

You can read how to get the bitcoin address from the corresponding private key here:  https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses
The key to bitcoin is that you can go from step 0 to step 9 easily, but going backwards from 9 to 0 is impossible.

Guide to armory offline install on USB key:  https://bitcointalk.org/index.php?topic=241730.0
ranlo (OP)
Legendary
*
Offline Offline

Activity: 1974
Merit: 1007



View Profile
May 19, 2014, 12:56:46 AM
 #7

I added a corrected question. It was addresses I was thinking of, not public keys. That's my fault (I'm still new to HOW Bitcoin and others work, which is also why I'm asking the question, :p).

So address-wise... how are you able to sweep all possible addresses when they are generated randomly to begin with?

As Foxpup said, the private key really only corresponds to one address.  All sweeping means is that you spend whatever is in that address and send it to a new one.

Imagine having an online wallet with address A
And a cold offline wallet with address B, where I've written the private key on a piece of paper.

If I open my online wallet and sweep that offline private key that corresponds to address B then it'll send whatever is in B to address A.  My online wallet still only has address A, but it has all the coins from B in that address A as well.

That's different than importing a private key.  If I imported the private B key into my online wallet then it would have both addresses A and B.


I was under the impression, though, that I could have (I'm shortening addresses for brevity):

One wallet with its private key. 5 Addresses with the following balances:

1jAdjflsjkfsdf32423lk - 0.01 BTC
1jAdjflsjkfsdf23j44lkl - 0.03 BTC
1jAdjflsjkfsdf234234 - 0.03 BTC
1jAdjflsjkfsdf23j423l - 0.03 BTC
1jAdjflsjkfsdf2342l3l - 0.05 BTC

Now, my understanding is that you could use a "sweeper" (or import, maybe?) to take just the private key and automatically know that there are 0.15 BTC associated with it (by taking all of the possible addresses and pulling in their balances). Is this where my understanding was wrong?

https://nanogames.io/i-bctalk-n/
Message for info on how to get kickbacks on sites like Nano (above) and CryptoPlay!
cp1
Hero Member
*****
Offline Offline

Activity: 616
Merit: 500


Stop using branwallets


View Profile
May 19, 2014, 01:01:33 AM
 #8


I was under the impression, though, that I could have (I'm shortening addresses for brevity):

One wallet with its private key. 5 Addresses with the following balances:

1jAdjflsjkfsdf32423lk - 0.01 BTC
1jAdjflsjkfsdf23j44lkl - 0.03 BTC
1jAdjflsjkfsdf234234 - 0.03 BTC
1jAdjflsjkfsdf23j423l - 0.03 BTC
1jAdjflsjkfsdf2342l3l - 0.05 BTC

Now, my understanding is that you could use a "sweeper" (or import, maybe?) to take just the private key and automatically know that there are 0.15 BTC associated with it (by taking all of the possible addresses and pulling in their balances). Is this where my understanding was wrong?

Those 5 addresses each have their own private keys associated with them.  If you want to sweep those funds you'll need to use each of the 5 keys.  Just think of sweep as spend, take, or steal.

Guide to armory offline install on USB key:  https://bitcointalk.org/index.php?topic=241730.0
ranlo (OP)
Legendary
*
Offline Offline

Activity: 1974
Merit: 1007



View Profile
May 19, 2014, 01:05:51 AM
 #9


I was under the impression, though, that I could have (I'm shortening addresses for brevity):

One wallet with its private key. 5 Addresses with the following balances:

1jAdjflsjkfsdf32423lk - 0.01 BTC
1jAdjflsjkfsdf23j44lkl - 0.03 BTC
1jAdjflsjkfsdf234234 - 0.03 BTC
1jAdjflsjkfsdf23j423l - 0.03 BTC
1jAdjflsjkfsdf2342l3l - 0.05 BTC

Now, my understanding is that you could use a "sweeper" (or import, maybe?) to take just the private key and automatically know that there are 0.15 BTC associated with it (by taking all of the possible addresses and pulling in their balances). Is this where my understanding was wrong?

Those 5 addresses each have their own private keys associated with them.  If you want to sweep those funds you'll need to use each of the 5 keys.  Just think of sweep as take or steal.

Ah, I think I'm catching on now. So to clarify:

I just did a key export from a client (out of curiosity) and it gave multiple private keys. Sweeping these takes in each private key and determines what address it goes to, and then can access those funds, correct?

So really we don't even need to know any addresses, as long as you have the private key that came from each one?

https://nanogames.io/i-bctalk-n/
Message for info on how to get kickbacks on sites like Nano (above) and CryptoPlay!
cp1
Hero Member
*****
Offline Offline

Activity: 616
Merit: 500


Stop using branwallets


View Profile
May 19, 2014, 01:08:21 AM
 #10

Yes, each private key contains within it the ability to know the address associated with it.  So for example if you gave me one of your private keys then I could immediately steal the coins on that address, even if you didn't give me the address.  Because it's easy to find the address from a private key.  However if you gave me the address I can't do anything with it but look at how many coins it has because it's impossible to get the private key from the address.


Guide to armory offline install on USB key:  https://bitcointalk.org/index.php?topic=241730.0
ranlo (OP)
Legendary
*
Offline Offline

Activity: 1974
Merit: 1007



View Profile
May 19, 2014, 01:10:28 AM
 #11

Yes, each private key contains within it the ability to know the address associated with it.  So for example if you gave me one of your private keys then I could immediately steal the coins on that address, even if you didn't give me the address.  Because it's easy to find the address from a private key.  However if you gave me the address I can't do anything with it but look at how many coins it has because it's impossible to get the private key from the address.



Thanks for clarifying all of this for me. The way the system works is completely different than how I envisioned it.

You definitely made it more clear though!

https://nanogames.io/i-bctalk-n/
Message for info on how to get kickbacks on sites like Nano (above) and CryptoPlay!
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
May 19, 2014, 04:37:02 AM
 #12

Yes, each private key contains within it the ability to know the address associated with it.  So for example if you gave me one of your private keys then I could immediately steal the coins on that address, even if you didn't give me the address.  Because it's easy to find the address from a private key.  However if you gave me the address I can't do anything with it but look at how many coins it has because it's impossible to get the private key from the address.
Thanks for clarifying all of this for me. The way the system works is completely different than how I envisioned it.

You definitely made it more clear though!

You'll find that much of bitcoin works completely differently than how most people envision it. We use many words and phrases to represent the protection and transfer of control of value that form a particular image in the minds of the typical listener.  These images make it easier to talk at a high level about "spending" or "receiving" bitcoins.  As you learn more about bitcoin, you'll discover that the technical details involved are very different than the common descriptions.
ranlo (OP)
Legendary
*
Offline Offline

Activity: 1974
Merit: 1007



View Profile
May 19, 2014, 04:41:46 AM
 #13

Yes, each private key contains within it the ability to know the address associated with it.  So for example if you gave me one of your private keys then I could immediately steal the coins on that address, even if you didn't give me the address.  Because it's easy to find the address from a private key.  However if you gave me the address I can't do anything with it but look at how many coins it has because it's impossible to get the private key from the address.
Thanks for clarifying all of this for me. The way the system works is completely different than how I envisioned it.

You definitely made it more clear though!

You'll find that much of bitcoin works completely differently than how most people envision it. We use many words and phrases to represent the protection and transfer of control of value that form a particular image in the minds of the typical listener.  These images make it easier to talk at a high level about "spending" or "receiving" bitcoins.  As you learn more about bitcoin, you'll discover that the technical details involved are very different than the common descriptions.

True. I've ran into many things I misinterpreted based on how they were stated. I tried delving into the code as well but that left me completely baffled (I'm a newbie when it comes to C++). Slowly but surely I'm learning though! Mostly just cutting it into more consumable chunks for digesting (so to speak).

https://nanogames.io/i-bctalk-n/
Message for info on how to get kickbacks on sites like Nano (above) and CryptoPlay!
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!