tintinweb / ecdsa-private-key-recovery

A simple library to recover the private key of ECDSA and DSA signatures sharing the same nonce k and therefore having identical signature parameter r

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use your tool to solve my problem

kyisoethin opened this issue · comments

commented

I want to ask for advice in my case of CTF lab.
So, if this is out of question type, you can leave it.
I have signatures that use ruby securerandom and it uses same k nonce.
I know the domain. But I don't know how to get public key.
So, I can have two signatures and their r and s.
Then, how can I substitute these values in your script?
I think I have to replace the following code .

sampleA = EcDsaSignature((3791300999159503489677918361931161866594575396347524089635269728181147153565,   #r
                          49278124892733989732191499899232294894006923837369646645433456321810805698952), #s
                         bignum_to_hex(
                             765305792208265383632692154455217324493836948492122104105982244897804317926).decode(
                             "hex"),
                         pub)

I know r and s. But I do not know what to replace third argument.
So, please help me to solve my problem.

Hi @kyisoethin,

the public key is required. It is probably part of your CTF challenge to recover the pubkey from (r,s). this thread could be of help. I am pretty sure there's a tool that will help you where you provide curve, r,s to recover pubkey canditates and then you feed (pubkey, r,s1)(pubkey,r,s2) into ecdsa-private-key-recovery to get the privkey.

//edit: https://github.com/AntonKueltz/fastecdsa/blob/master/fastecdsa/keys.py#L81 is probably a good bet to recover pubkey candidates.

cheers,
tin

Hey tin.. is there a utility you recommend to pull R S from a specific candidate .... (already have the pubkey)
Thanks.

Kind Regards
Mikej