Python steemitimages.com Image Uploader (with secp256k1 problems)
Why I'm doing it?
I'm still new on steemit, and for my introduction post I had some hassles. Like I prepared my post offline because I don't like doing stuff in the browser only to find myself at the end loosing my work of hours. I wrote all in xhtml with css formated only to figure out that in the end I had to format everything once more. So I thought I would make me some script to make this process how I want it.
What I did.
I installed python-steem(Documentation), but I couldn't find how to upload the images. After some searching I figured out that there is now way with this library. But anyway I like python the last years and have still some plans with python.
But I found imagehoster which looks like the base of steemitimages. So I played around and got it managed to upload an image with the help sign.js and curl.
By the way shot by my wife :) Thank you for that!
What's wrong with it?
But the differences of the secp256k1 implementations between node.js and python driving me nuts. Has anyone an idea how to get the signature in DER format converted to lower S (whatever that means. Only thing what I understood is that it is bitcoin specific and little endian instead of big endian, and shorter. I guess it's the same for the steem blockchain!?)
More details.
And it took me now the whole day to read the following:
- secp256k1 node.js implementation
- dsteem node.js implementation
- dsteem node.js docs
- secp256k1 python implementation
- steem python implementation
- steem python docs
- and some others I discarded like two python bitcoin libraries
Help very welcome
Maybe I have overlooked something in the python steem implementation :/
So if someone have an idea, I would be very happy!
Some code
#!/usr/bin/python3
from hashlib import sha256
import sys
import secp256k1
#first import of steembase.account fails. (at least on my machine)
try:
import steembase.account
except:
import steembase.account
from steem.utils import compat_bytes
class SteemitImages:
def __init__(self):
pass
def imageSign(_data, _key):
h = sha256()
h.update(b"ImageSigningChallenge")
h.update(_data)
# hash.digest() is the same as in sign.js
key = steembase.account.PrivateKey(_key)
# key is also the same as in sign.js
sk = secp256k1.PrivateKey(compat_bytes(key), raw=True)
sig = sk.ecdsa_sign(h.digest(), raw=True)
out = sk.ecdsa_signature_normalize(sig)
return out.hex()
def getDataFromFile(_file):
with open(_file, mode='rb') as file:
return file.read()
if __name__ == "__main__":
print(SteemitImages.imageSign(SteemitImages.getDataFromFile(sys.argv[2]),sys.argv[1]))
Leave Python steemitimages.com Image Uploader (with secp256k1 problems) to:
Read more #steem posts
Best Posts From Voluntaryist Thor
We have not curated any of vthor's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Voluntaryist Thor
- Drug money in the Darknet - Or how to fill up my pockets - Cancun (Day 39, $14)
- Never ever calculate with money you have not already in the pocket - Cancun (Day 34, $14)
- I am dizzy from writing German - Cancun (Day 33, $27)
- Thinking about money makes you dizzy? - Cancun (Day 31, $14)
- 4 ways to fail. But how to succeed? - Cancun (Day 29, $14)
- What makes really real money? (continuation)- Cancun (Day 28, $14)
- What makes really real money? - Cancun (Day 26, $14)
- Where is my audience? - Cancun (Day 24, still $0)
- Still a lot of distraction in my head - Cancun (Day 23, still $0)
- Pushing it further - Cancun (Day 22, still $0)
- Missed routine and life since 14.750 days on this planet - Cancun (Day 21, still $0)
- Secure & anonymous communication with an encrypted phone
- I need return to some routine - 90 day challenge - Cancun (Day 20, still $0)
- 90 day challenge - Cancun (Day 19, still $0)
- Sometimes everything seems to go wrong, and you think it can't go any worse...
- Want to read fast the introduction post of some steemian?
- Python steemitimages.com Image Uploader (with secp256k1 problems)
- Reboot... My imperfect introduction in an imperfect world.