user-1: I find lots of tools/scripts written in python which can generate random number then using this random number it generates Bitcoin Private key(WIF) -> Bitcoin Address pair.
I have tried verifying few pairs using www.bitaddress.org >> Wallet Details by entering WIF key and verifying with output address.
But How can one make sure, the tools/scripts will always generate valid address and key pair ?
or is this like this way
if it generates one valid address and key pair it means all the future address and key pairs will be valid ?
i was looking at this https://github.com/shirriff/bitcoin-code
from makeAddr.py
import random, keyUtils
private_key = ''.join(['%x' % random.randrange(16) for x in range(0, 64)])
print keyUtils.privateKeyToWif(private_key)
print keyUtils.keyToAddr(private_key)

i know random number/string generated using this method is not very much secure, but i am talking in terms of valid WIF and address pair.

user38271: you need to make sure that the private is lower than 1.158 * 10^77 (115792089237316195423570985008687907852837564279074904382605163141518161494337) and 
In your case you could do 
 import random, keyUtils 
 private_key = ''.join(['%x' %random.randrange(16) for x in range(0, 64)]) 
 print keyUtils.privateKeyToWif(private_key)
 print keyUtils.keyToAddr(private_key)

 from ecdsa.curves import SECP256k1
 decoded_private_key = int(private_key,16)
 if decoded_private_key > 0 and  decoded_private_key < SECP256k1.generator.order():
     print 'valid'
 else:
     print 'invalid'


-1: <p>I find lots of <code>tools/scripts</code> written in <code>python</code> which can generate <code>random number</code> then using this <code>random number</code> it generates <code>Bitcoin Private key(WIF) -&gt; Bitcoin Address pair</code>.</p>

<p>I have tried verifying few pairs using <code>www.bitaddress.org</code> >> <code>Wallet Details</code> by entering <code>WIF key</code> and verifying with output <code>address</code>.</p>

<p>But How can one make sure, the tools/scripts will always <code>generate valid address and key pair</code> ?</p>

<p>or is this like this way</p>

<p>if it generates one <code>valid</code> <code>address and key pair</code> it means all the future <code>address and key pairs</code> will be <code>valid</code> ?</p>

<p>i was looking at this <strong><a href="https://github.com/shirriff/bitcoin-code" rel="nofollow noreferrer">https://github.com/shirriff/bitcoin-code</a></strong></p>

<p>from <code>makeAddr.py</code></p>

<pre><code>import random, keyUtils
private_key = ''.join(['%x' % random.randrange(16) for x in range(0, 64)])
print keyUtils.privateKeyToWif(private_key)
print keyUtils.keyToAddr(private_key)
</code></pre>

<p>i know random number/string generated using this method is not very much secure, but i am talking in terms of <code>valid WIF and address pair</code>.</p>
 38271: <p>you need to make sure that the private is lower than 1.158 * 10^77 (<code>115792089237316195423570985008687907852837564279074904382605163141518161494337</code>) and </p>

<p>In your case you could do </p>

<pre><code> import random, keyUtils 
 private_key = ''.join(['%x' %random.randrange(16) for x in range(0, 64)]) 
 print keyUtils.privateKeyToWif(private_key)
 print keyUtils.keyToAddr(private_key)

 from ecdsa.curves import SECP256k1
 decoded_private_key = int(private_key,16)
 if decoded_private_key &gt; 0 and  decoded_private_key &lt; SECP256k1.generator.order():
     print 'valid'
 else:
     print 'invalid'
</code></pre>
