From 3b76fc6112dcc1944b98172ad3f30ef82de84b70 Mon Sep 17 00:00:00 2001 From: "Minh T. Nguyen" Date: Sun, 25 May 2014 17:23:47 -0700 Subject: [PATCH] To create private key, we retry when the random number is less than n - 1; even if it is n - 1; Issue #28 --- ch04.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch04.asciidoc b/ch04.asciidoc index f45fc94c..0681c163 100644 --- a/ch04.asciidoc +++ b/ch04.asciidoc @@ -40,7 +40,7 @@ A +private key+ is simply a number, picked at random. Ownership and control over ===== Generating a private key from a random number -A private key is a number between +1+ and +n - 1+, where n is a constant defined in the elliptic curve standard (latexmath:[\(n = 1.158 * 10^\(77\) \)], n is the order of the elliptic curve used in bitcoin. See <>). To create such a key, we randomly pick a 256-bit number and check that it is less than +n - 1+. In programming terms, this is usually achieved by feeding a larger string of random bits, collected from a cryptographically-secure source of randomness, into the SHA-256 hash algorithm which will conveniently produce a 256-bit number. If the result is less than +n - 1+, we have a suitable private key. If it is greater than +n - 1+, we simply try again with another random number. +A private key is a number between +1+ and +n - 1+, where n is a constant defined in the elliptic curve standard (latexmath:[\(n = 1.158 * 10^\(77\) \)], n is the order of the elliptic curve used in bitcoin. See <>). To create such a key, we randomly pick a 256-bit number and check that it is less than +n - 1+. In programming terms, this is usually achieved by feeding a larger string of random bits, collected from a cryptographically-secure source of randomness, into the SHA-256 hash algorithm which will conveniently produce a 256-bit number. If the result is less than +n - 1+, we have a suitable private key. Otherwise, we simply try again with another random number. [TIP] ====