Title: secp256k1 formula calculations Post by: krashfire on January 31, 2023, 05:44:57 AM Hi, i need help to check my code.
Code:
and after giving my inputs, i got this output, Private Key = 2.378864885847563e+77 I just wanna make sur. is my formula written correctly? and how do i actually read that answer? i tried googling but i cant get an answer on how do I read it as integer. Title: Re: secp256k1 formula calculations Post by: garlonicon on January 31, 2023, 06:22:46 AM It is invalid, because:
1. You have to calculate it modulo "n". 2. The correct formula is "s=(z+rd)/k", so your private key "d" is "(sk-z)/r". Also, if 256-bit numbers are too big for you to start with, then compute everything on smaller numbers first: https://www.coindesk.com/markets/2014/10/19/the-math-behind-the-bitcoin-protocol/ Title: Re: secp256k1 formula calculations Post by: witcher_sense on January 31, 2023, 06:31:23 AM I already have given you a link to a correct formula in your previous thread:
What is the formula to calculate private keys if you already have all the R,S,Z(H) K Value? Where d= private_key. d = (k * s - z) * r-1 mod n Source: https://learnmeabitcoin.com/technical/ecdsa (Why do you need to generate a random point each time? (Mathematical Explanation) Also, your resulting private key shouldn't be a floating point number, which is why it is better to use floor division (//) instead of real division ( / ) that always gives you floats (even when you divide intehers without remainder) Title: Re: secp256k1 formula calculations Post by: krashfire on January 31, 2023, 06:51:38 AM It is invalid, because: thank you garlonicon. I got this answer from ChatGPT... Damn.1. You have to calculate it modulo "n". 2. The correct formula is "s=(z+rd)/k", so your private key "d" is "(sk-z)/r". Also, if 256-bit numbers are too big for you to start with, then compute everything on smaller numbers first: https://www.coindesk.com/markets/2014/10/19/the-math-behind-the-bitcoin-protocol/ Title: Re: secp256k1 formula calculations Post by: krashfire on January 31, 2023, 06:52:21 AM I already have given you a link to a correct formula in your previous thread: What is the formula to calculate private keys if you already have all the R,S,Z(H) K Value? Where d= private_key. d = (k * s - z) * r-1 mod n Source: https://learnmeabitcoin.com/technical/ecdsa (Why do you need to generate a random point each time? (Mathematical Explanation) Also, your resulting private key shouldn't be a floating point number, which is why it is better to use floor division (//) instead of real division ( / ) that always gives you floats (even when you divide intehers without remainder) I already have given you a link to a correct formula in your previous thread: yeah yeah...I forgot about that ..thanks for reminding.What is the formula to calculate private keys if you already have all the R,S,Z(H) K Value? Where d= private_key. d = (k * s - z) * r-1 mod n Source: https://learnmeabitcoin.com/technical/ecdsa (Why do you need to generate a random point each time? (Mathematical Explanation) Also, your resulting private key shouldn't be a floating point number, which is why it is better to use floor division (//) instead of real division ( / ) that always gives you floats (even when you divide intehers without remainder) Title: Re: secp256k1 formula calculations Post by: krashfire on January 31, 2023, 07:15:42 AM ChatGPT also gave me this formula to find K nonce Value
Code: k= (z + r*s) % n Title: Re: secp256k1 formula calculations Post by: garlonicon on January 31, 2023, 03:48:56 PM Quote Code: k= (z + r*s) % n Quote ChatGPT also gave me this formula ChatGPT is already banned in Stack Overflow, because of bad answers it gave for technical questions. Who knows, if there will be more such cases here, then maybe we will get "automatically generated post" as one of the reasons to report such posts. Because now, the quality of that bot is far from perfect, and even worse, typical answers seems to be correct, but are often misleading.Title: Re: secp256k1 formula calculations Post by: witcher_sense on January 31, 2023, 04:01:45 PM Quote Code: k= (z + r*s) % n Just for reference, the correct formula is the following (we still need private key to obtain nonce value): k = (z + d * r) * s-1 mod n Title: Re: secp256k1 formula calculations Post by: krashfire on January 31, 2023, 07:31:58 PM Quote Code: k= (z + r*s) % n Just for reference, the correct formula is the following (we still need private key to obtain nonce value): k = (z + d * r) * s-1 mod n Just to be sure, I again ask ChatGPT Code:
Yeah This forum should ban CHATGPT as well. Title: Re: secp256k1 formula calculations Post by: Critical_Thoughts on February 01, 2023, 08:23:08 AM OP you need to understand chatGPT is not a computational operated model, it just generates answers based on a limited database, we don't know the source of it's outputs, they could be wrong in many cases. chatGPT is an experimental project, don't expect much from it.
Title: Re: secp256k1 formula calculations Post by: NotATether on February 02, 2023, 04:45:51 AM Quote Code: k= (z + r*s) % n The divisor is also missing here, instead the s is being multiplied instead of divided. Quote ChatGPT is already banned in Stack Overflow, because of bad answers it gave for technical questions. Who knows, if there will be more such cases here, then maybe we will get "automatically generated post" as one of the reasons to report such posts. Because now, the quality of that bot is far from perfect, and even worse, typical answers seems to be correct, but are often misleading. Alternatively you can feed the input of a post into ChatGPT and prompt it to explain why it's a bad bitcointalk post, and you will get an automated report message out of it. |