I have tried a bunch of stuff with numpy, but certainly I'm doing it wrong. I cannot get any better speed using it. Here's an example of my simple code that will generate 1 million keys and the associated compressed address:
from fastecdsa import keys, curve
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')
real 1m22,192s
user 1m21,461s
sys 0m0,640s
Then I rewrite the code to implement numpy ...
import numpy as np
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')
real 1m19,636s
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