import secp256k1 as ice
# how many addresses to generate
num_addresses = 1000000
# Open a file for writing
with open('addresses.out', 'w') as f:
# Generate and write each address to the file
for i in range(num_addresses):
prvkey_dec = keys.gen_private_key(curve.P256)
addr = ice.privatekey_to_address(0, True, prvkey_dec)
f.write(f'{addr}\n')
user 1m21,461s
sys 0m0,640s
Then I rewrite the code to implement numpy ...
import fastecdsa.keys as fkeys
import fastecdsa.curve as fcurve
import secp256k1 as ice
# how many addresses to generate
num_addresses = 1000000
# Generate a NumPy array of random private keys using fastecdsa
private_keys = np.array([fkeys.gen_private_key(fcurve.P256) for _ in range(num_addresses)])
# Use secp256k1 to convert the private keys to addresses
addresses = np.array([ice.privatekey_to_address(0, True, dec) for dec in private_keys])
# Write the addresses to a file
np.savetxt('addresses_numpy.out', addresses, fmt='%s')
user 1m18,826s
sys 0m1,027s
I don't see any performance hit here. What am I doing wrong?
EDIT: I am sorried for getting off-topic now. Let's continue HERE