itod (OP)
Legendary
Offline
Activity: 1974
Merit: 1077
^ Will code for Bitcoins
|
|
January 26, 2014, 10:59:42 PM |
|
Is there a pure Python ECDSA Secp256k1 implementation? I don't care how slow it is, because calling libcrypto in a loop gives me Segmentation fault every 3-4 million loops. I'm using Joric/bitcoin-dev implementation and I've tried to find the cause with gdb, but give up on it, have no more nerves for it. Using some utility through RPC is not an attractive option because of overhead. If anyone has a link to a native Python solution I would be grateful.
|
|
|
|
Cytality
Newbie
Offline
Activity: 4
Merit: 0
|
|
January 26, 2014, 11:05:56 PM |
|
Is there a pure Python ECDSA Secp256k1 implementation? I don't care how slow it is, because calling libcrypto in a loop gives me Segmentation fault every 3-4 million loops. I'm using Joric/bitcoin-dev implementation and I've tried to find the cause with gdb, but give up on it, have no more nerves for it. Using some utility through RPC is not an attractive option because of overhead. If anyone has a link to a native Python solution I would be grateful. https://github.com/warner/python-ecdsaSorry, but just a slightly off-kilter question for you... Why not use C++? I assume you may develop Python on a Linux platform, so development and IDE usage would be similar. Hell, even the syntax is similar. With C++, however, you get more control from your code.
|
|
|
|
Sammey
Newbie
Offline
Activity: 38
Merit: 0
|
|
January 26, 2014, 11:08:03 PM |
|
Is there a pure Python ECDSA Secp256k1 implementation? I don't care how slow it is, because calling libcrypto in a loop gives me Segmentation fault every 3-4 million loops. I'm using Joric/bitcoin-dev implementation and I've tried to find the cause with gdb, but give up on it, have no more nerves for it. Using some utility through RPC is not an attractive option because of overhead. If anyone has a link to a native Python solution I would be grateful. https://github.com/warner/python-ecdsaSorry, but just a slightly off-kilter question for you... Why not use C++? I assume you may develop Python on a Linux platform, so development and IDE usage would be similar. Hell, even the syntax is similar. With C++, however, you get more control from your code. Was going to post that link. Looks like you beat me to it.
|
|
|
|
itod (OP)
Legendary
Offline
Activity: 1974
Merit: 1077
^ Will code for Bitcoins
|
|
January 26, 2014, 11:27:11 PM |
|
Is there a pure Python ECDSA Secp256k1 implementation? I don't care how slow it is, because calling libcrypto in a loop gives me Segmentation fault every 3-4 million loops. I'm using Joric/bitcoin-dev implementation and I've tried to find the cause with gdb, but give up on it, have no more nerves for it. Using some utility through RPC is not an attractive option because of overhead. If anyone has a link to a native Python solution I would be grateful. https://github.com/warner/python-ecdsaSorry, but just a slightly off-kilter question for you... Why not use C++? I assume you may develop Python on a Linux platform, so development and IDE usage would be similar. Hell, even the syntax is similar. With C++, however, you get more control from your code. I've found that, but README says: Curves included: prime192v1, secp224r1, prime256v1, secp384r1, and secp521r1. Problem is Bitcoin's Secp256k1 is not there, and I'm not sure if I would dare to do that myself. Regarding your C++ question, I've never done any serious C++ work, just very small things, but this thing made me ask that same question myself. If I don't find a solution by tomorrow I'll give up on Python for this job. Even tried to see how Armory is doing that, and it also depends on non-native library. I've Googled it everywhere before I've posted a question here.
|
|
|
|
Evil-Knievel
Legendary
Offline
Activity: 1260
Merit: 1168
|
|
January 26, 2014, 11:33:46 PM Last edit: April 17, 2016, 09:18:41 PM by Evil-Knievel |
|
This message was too old and has been purged
|
|
|
|
|
itod (OP)
Legendary
Offline
Activity: 1974
Merit: 1077
^ Will code for Bitcoins
|
|
January 26, 2014, 11:49:48 PM |
|
Take a look at my "MINING" thread currently to be found in the Service->Marketplace section. There you have a pure python secp256k1 implementation in my github project.
Thanks, Evil-Knievel! No wonder I haven't found it when it's so fresh. Off to take a good look how to use it. Bitcoin is Secp256k1, not Secp521r1, different curves.
|
|
|
|
maaku
Legendary
Offline
Activity: 905
Merit: 1012
|
|
January 27, 2014, 12:52:38 AM |
|
It has secp256k1 in git master, although not in the last release I tried. If you don't want to track head, it's simple enough to monkey-patch in support: # Import as a different name so as to clearly distinguish from our ecdsa* modules import ecdsa as pyecdsa
# Certicom secp256-k1, the ECDSA curve used by Bitcoin. This curve has recently # been added to the python-ecdsa repository, but is still missing from the latest # version on PyPI. try: SECP256k1 = pyecdsa.curves.find_curve((1, 3, 132, 0, 10)) except pyecdsa.curves.UnknownCurveError: _a = 0x0000000000000000000000000000000000000000000000000000000000000000L _b = 0x0000000000000000000000000000000000000000000000000000000000000007L _p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2FL _Gx = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798L _Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8L _r = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141L curve_secp256k1 = pyecdsa.ellipticcurve.CurveFp(_p, _a, _b) generator_secp256k1 = pyecdsa.ellipticcurve.Point(curve_secp256k1, _Gx, _Gy, _r) SECP256k1 = pyecdsa.curves.Curve('SECP256k1', curve_secp256k1, generator_secp256k1, (1, 3, 132, 0, 10)) pyecdsa.curves.curves.append(SECP256k1)
|
I'm an independent developer working on bitcoin-core, making my living off community donations. If you like my work, please consider donating yourself: 13snZ4ZyCzaL7358SmgvHGC9AxskqumNxP
|
|
|
Remember remember the 5th of November
Legendary
Offline
Activity: 1862
Merit: 1011
Reverse engineer from time to time
|
|
January 27, 2014, 12:54:26 AM |
|
Take a look at my "MINING" thread currently to be found in the Service->Marketplace section. There you have a pure python secp256k1 implementation in my github project.
Thanks, Evil-Knievel! No wonder I haven't found it when it's so fresh. Off to take a good look how to use it. Bitcoin is Secp256k1, not Secp521r1, different curves. https://github.com/warner/python-ecdsa/blob/master/ecdsa/curves.py
|
BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
|
|
|
itod (OP)
Legendary
Offline
Activity: 1974
Merit: 1077
^ Will code for Bitcoins
|
|
January 27, 2014, 01:05:01 AM |
|
It has secp256k1 in git master, although not in the last release I tried. If you don't want to track head, it's simple enough to monkey-patch in support:
Thanks to both of you, will try it tommorow.
|
|
|
|
|