czepluch / pysecp256k1 Goto Github PK
View Code? Open in Web Editor NEWcffi wrapper for secp256k1
License: MIT License
cffi wrapper for secp256k1
License: MIT License
I'm working on porting pyethapp to Windows. Can you help me with porting this package to Windows? Or help me finding a replacement?
# very good results!
# (default) ~/dev/ethereum/pysecp256k1 (git)-[perftest] % python tests/test_secp256k1.py
# cffi took: 0.79secs / 79μs per op / 12626 signs per sec
# cffi took: 1.28secs / 127μs per op / 7821 recovers per sec
def rand32bytes():
return ''.join(chr(random.randint(0, 255)) for i in range(32))
def perf(rounds=1000):
privkeys = [rand32bytes() for i in range(rounds)]
messages = [rand32bytes() for i in range(rounds)]
# test sign
signatures = []
st = time.time()
for priv, msg in zip(privkeys, messages):
s = secp256k1_ecdsa_sign(msg, priv)
signatures.append(s)
elapsed = time.time() - st
print 'cffi took: %.2fsecs / %dμs per op / %d signs per sec' % \
(elapsed, elapsed / rounds * 10**6, rounds / elapsed)
# test recover
pubs = []
st = time.time()
for sig, msg in zip(signatures, messages):
p = secp256k1_ecdsa_recover(msg, sig)
pubs.append(p)
elapsed = time.time() - st
print 'cffi took: %.2fsecs / %dμs per op / %d recovers per sec' % \
(elapsed, elapsed / rounds * 10**6, rounds / elapsed)
# check
for pub, privkey in zip(pubs, privkeys)[:100]:
assert privtopub(privkey) == pub
if __name__ == '__main__':
perf(10000)
// Dependencies for c_secp256k1
$ sudo apt-get install libssl-dev
$ sudo apt-get install libffi-dev
$ sudo apt-get install libtool
make clean
rm -fr build/
rm -fr dist/
rm -fr .egg-info
rm -fr c_secp256k1/.so
rm -fr c_secp256k1/_c_secp256k1.py
rm -rf bitcoin-secp256k1-*
rm secp256k1.tar.gz
rm: secp256k1.tar.gz: No such file or directory
make: *** [clean-build] Error 1
Git submodules are a pain in the ass to work with. Should just download a tarball instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.