Author

Topic: Finding nonce in historical transactions / blocks (Read 284 times)

newbie
Activity: 30
Merit: 0
Hello friends. Inspired by the table on iceland's rsz, I created code in phyton for the cases where k,k+1...k+m. Since there is no such example whose private key I know, I ask you to check it. If it works, I will publish it on github. As far as I can see, there is no such resource, we can all benefit from it. Can anyone who sees it please check it out and give their opinions?

Code:
def h(n):
    return hex(n).replace("0x","")

def extended_gcd(aa, bb):
    lastremainder, remainder = abs(aa), abs(bb)
    x, lastx, y, lasty = 0, 1, 1, 0
    while remainder:
        lastremainder, (quotient, remainder) = remainder, divmod(lastremainder, remainder)
        x, lastx = lastx - quotient*x, x
        y, lasty = lasty - quotient*y, y
    return lastremainder, lastx * (-1 if aa < 0 else 1), lasty * (-1 if bb < 0 else 1)

def modinv(a, m):
    g, x, y = extended_gcd(a, m)
    if g != 1:
        raise ValueError
    return x % m
   
N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141



R1 = 0x49bf1b1c8364c4179bd82a3be28b1a326c2c1b2d120c3264865ecbc4dbaed4b3
S1 = 0x4ad0d60d72880bf0a51d88d0d5138ffa3593273bd0b3d48a5afe04023db9c2c9
Z1 = 0x1362d682d8872a0451e5f0d86f743a62bf0730b57ddddc901668d837cbfa2f48
R2 = 0x00ad7991e3b3d36f6f17a22fad1faddc53e7c124e5b6626db172c79299fce5cfb6
S2 = 0x10ecd8352675027f74edc18180ac083d75a1488497c6c3078a5966015514ac46
Z2 = 0xfec02a5d53eb20a6e470b7c321e0da83ea6d677f600f67033abf4b0e6b8745aa
m = 1

print (h(((S2*m*R1 + Z1*R2 - Z2*R1) * (S1*R2 - S2*R1)^(-1)) % N))
member
Activity: 184
Merit: 14
The transaction nonce is what is used to create the signature of the transaction or the r,s. It's private as it involves the private key to sign transactions
I'm kinda clueless here, but if it's private, it's not on the blockchain, right?

Ah, I seem to get it now. He's talking about in the ECDSA signature algorithm where a secret number k, the so-called transaction nonce (though this is the first time I heard it being called a nonce to be honest) is chosen that is used to create r and s.

Obviously that's not available in the raw transaction as he pointed out, but in another thread here I made a process for getting the nonce k from the private key, the message data - in this case the raw transaction with a few fields unfilled - , r and s: https://bitcointalksearch.org/topic/--5316741


Interesting thread thank you. Although I don't see the point  in finding K if you have P? Finding K leads you to P.

I find this interesting:

S1 = (h1+rx1*P)/k   =>  k = (h1+rx1*P)/S1

S2 = (h2+rx2*P)/(k+1)  =>  k+1 = (h2+rx2*P)/S2

((h1+rx1*P)/S1)  + 1 = (h2+rx2*P)/S2


.........

P = (h2*S1 - h1*S2 - S2)/(rx1*S2 - rx2*S1)
member
Activity: 184
Merit: 14
The transaction nonce is what is used to create the signature of the transaction or the r,s. It's private as it involves the private key to sign transactions
I'm kinda clueless here, but if it's private, it's not on the blockchain, right?

Ah, I seem to get it now. He's talking about in the ECDSA signature algorithm where a secret number k, the so-called transaction nonce (though this is the first time I heard it being called a nonce to be honest) is chosen that is used to create r and s.

Obviously that's not available in the raw transaction as he pointed out, but in another thread here I made a process for getting the nonce k from the private key, the message data - in this case the raw transaction with a few fields unfilled - , r and s: https://bitcointalksearch.org/topic/--5316741


Yes you got it my friend sorry. I can't find much data on it. Block nonce is usually 10 decimal characters 8 hex 32 bit. Was wandering what format the secret K value is if it is also a 32 bit string
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
The transaction nonce is what is used to create the signature of the transaction or the r,s. It's private as it involves the private key to sign transactions
I'm kinda clueless here, but if it's private, it's not on the blockchain, right?

Ah, I seem to get it now. He's talking about in the ECDSA signature algorithm where a secret number k, the so-called transaction nonce (though this is the first time I heard it being called a nonce to be honest) is chosen that is used to create r and s.

Obviously that's not available in the raw transaction as he pointed out, but in another thread here I made a process for getting the nonce k from the private key, the message data - in this case the raw transaction with a few fields unfilled - , r and s: https://bitcointalksearch.org/topic/--5316741
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
It turns out that the extraNonce is not included in the block or block header formats. This is a reply from theymos:
Correct. It's in the Coinbase transaction and since it's not a protocol standard, it can be a bit ambiguous, any changes in the transactions will alter the merkle root though I think using an extranonce makes it simpler.
I'm kinda clueless here, but if it's private, it's not on the blockchain, right?
The r and s values are 32 bytes each and located in the signature. If you want to parse it but I imagine that will take sometime, not sure what this can yield though. They're meant to be completely random under normal circumstances.
member
Activity: 184
Merit: 14
Is the data you're looking for included in any of those files?
http://blockdata.loyce.club/inputs/blockchair_bitcoin_inputs_20110615.tsv.gz
http://blockdata.loyce.club/outputs/blockchair_bitcoin_outputs_20110615.tsv.gz
http://blockdata.loyce.club/transactions/blockchair_bitcoin_transactions_20110615.tsv.gz
(Reference thread: Bitcoin block data: inputs, outputs and transactions)
If it's in here, I can get you the data.

The transaction nonce is what is used to create the signature of the transaction or the r,s. It's private as it involves the private key to sign transactions
I'm kinda clueless here, but if it's private, it's not on the blockchain, right?

Brute forced as in mining is only way I am familiar with
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
Is the data you're looking for included in any of those files?
http://blockdata.loyce.club/inputs/blockchair_bitcoin_inputs_20110615.tsv.gz
http://blockdata.loyce.club/outputs/blockchair_bitcoin_outputs_20110615.tsv.gz
http://blockdata.loyce.club/transactions/blockchair_bitcoin_transactions_20110615.tsv.gz
(Reference thread: Bitcoin block data: inputs, outputs and transactions)
If it's in here, I can get you the data.

The transaction nonce is what is used to create the signature of the transaction or the r,s. It's private as it involves the private key to sign transactions
I'm kinda clueless here, but if it's private, it's not on the blockchain, right?
member
Activity: 184
Merit: 14
I'm not sure where to find the extra nonce though, they're located in the Coinbase transaction.

It turns out that the extraNonce is not included in the block or block header formats. This is a reply from theymos:

Thanks for that. Their is always some ninja here with knowledge needed. This is obviously historical block data? Any idea how to find individual transaction nonce? Thanks

There is no nonce for individual transactions, because it only applies to block generation. Individual transactions have no use knowing the nonce, since that would just waste more bytes making the tx larger. It's a 32-bit counter located in the last 4 bytes of the block header.

The transaction nonce is what is used to create the signature of the transaction or the r,s. It's private as it involves the private key to sign transactions
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
I'm not sure where to find the extra nonce though, they're located in the Coinbase transaction.

It turns out that the extraNonce is not included in the block or block header formats. This is a reply from theymos:

Thanks for that. Their is always some ninja here with knowledge needed. This is obviously historical block data? Any idea how to find individual transaction nonce? Thanks

There is no nonce for individual transactions, because it only applies to block generation. Individual transactions have no use knowing the nonce, since that would just waste more bytes making the tx larger. It's a 32-bit counter located in the last 4 bytes of the block header.
member
Activity: 184
Merit: 14
Thanks for that. Their is always some ninja here with knowledge needed. This is obviously historical block data? Any idea how to find individual transaction nonce? Thanks
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
LoyceV very nicely compiled all of the nonces used in the blocks here: https://loyce.club/blockdata/nonce.txt.

I'm not sure where to find the extra nonce though, they're located in the Coinbase transaction.
member
Activity: 184
Merit: 14
Hi guys just wandering if their is a script/tool/method for finding nonce value of old transactions and/or blocks? Obviously the nonce has been found for every mined block but just wondering if their is a way to find this information out?

Thanks
Jump to: