# How to find Values N and K given R,S and Z in ECDSA?

How to find Value `N` and `K` ? I have the values for `R`, `S` and `Z`.

for example these:

``````BigInteger R =("00d47ce4c025c35ec440bc81d99834a624875161a26bf56ef7fdc0f5d52f843ad1"));
BigInteger S =("0044e1ff2dfd8102cf7a47c21d5c9fd5701610d04953c6836596b4fe9dd2f53e3e"));
BigInteger Z =("00c0e2d0a89a348de88fda08211c70d1d7e52ccef2eb9459911bf977d587784c6e"));
BigInteger X  =("00c477f9f65c22cce20657faa5b2d1d8122336f851a508a1ed04e479c34985bf96"));
``````

Now, how to get these:

``````BigInteger K =("007a1a7e52797fc8caaa435d2a4dace39158504bf204fbe19f14dbb427faee50ae"));
BigInteger N =("00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"));
``````

How to get the values `K` and `N` ?
I am confused about how to calculate it, can somebody tell me how it is done?

`k` and `n` are not values that you calculate. `k` is randomly generated while `n` is predefined by the curve parameters.
`n` is the order of the curve `G.` It is defined by the curve parameters for the secp256k1 curve which are defined here: http://www.secg.org/sec2-v2.pdf. In those parameters, `n = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141`.
`k` is a randomly generated integer that is used only once for a signature. It is known as the nonce and acts as a source of randomness. If the same `k` is used to sign two different messages with the same private key, the private key will be leaked.
• I already told you what `n` is and it is not that. As I said in my answer, you do not calculate `n` or `k`. `n` is given to you by the parameters for secp256k1, and `k` is randomly generated. You cannot calculate them. – Andrew Chow Sep 14 '18 at 13:41