Skip to content

Instantly share code, notes, and snippets.

@vivosmith vivosmith/bitcoin.py Secret
Last active Sep 25, 2017

Embed
What would you like to do?
import os
import ecdsa
import binascii
import hashlib
from ecdsa import SigningKey,VerifyingKey
private_key=os.urandom(32)
PK_EN=binascii.hexlify(private_key)
print("Your Key"+" "+str(PK_EN))
PK_CON=binascii.unhexlify(PK_EN)
sk=ecdsa.SigningKey.from_string(PK_CON, curve=ecdsa.SECP256k1)
vk=sk.verifying_key
msg=binascii.hexlify(b'Hello')
sign_msg=sk.sign(msg)
assert vk.verify(sign_msg,msg)
public_key=(+str((b'04')binascii.hexlify(vk.to_string())))
print(public_key)
ripemd160=hashlib.new('ripemd160')
ripemd160.update(hashlib.sha256(binascii.unhexlify(public_key)))
@vivosmith

This comment has been minimized.

Copy link
Owner Author

vivosmith commented Sep 25, 2017

raceback (most recent call last):
File "C:\Users\zac\Desktop\bitcoin.py", line 21, in
ripemd160.update(hashlib.sha256(binascii.unhexlify(public_key)))
binascii.Error: Odd-length string

@vivosmith

This comment has been minimized.

Copy link
Owner Author

vivosmith commented Sep 25, 2017

import os
import ecdsa
import binascii
import hashlib
import codecs
from ecdsa import SigningKey,VerifyingKey

private_key=os.urandom(32)
PK_EN=binascii.hexlify(private_key)
print("Your Key"+" "+str(PK_EN))
PK_CON=binascii.unhexlify(PK_EN)
sk=ecdsa.SigningKey.from_string(PK_CON, curve=ecdsa.SECP256k1)
vk=sk.verifying_key
msg=binascii.hexlify(b'Hello')
sign_msg=sk.sign(msg)
assert vk.verify(sign_msg,msg)

public_key=(str((b'04')+binascii.hexlify(vk.to_string())))
print(public_key)
print(binascii.unhexlify(public_key))
ripemd160=hashlib.new('ripemd160')

ripemd160.update(hashlib.sha256(binascii.unhexlify(public_key)))

@vivosmith

This comment has been minimized.

Copy link
Owner Author

vivosmith commented Sep 25, 2017

import os
import ecdsa
import binascii
import hashlib
import codecs
from ecdsa import SigningKey,VerifyingKey

private_key=os.urandom(32)
PK_EN=binascii.hexlify(private_key)
print("Your Key"+" "+str(PK_EN))
PK_CON=binascii.unhexlify(PK_EN)
sk=ecdsa.SigningKey.from_string(PK_CON, curve=ecdsa.SECP256k1)
vk=sk.verifying_key
msg=binascii.hexlify(b'Hello')
sign_msg=sk.sign(msg)
assert vk.verify(sign_msg,msg)

public_key=(str((b'04')+binascii.hexlify(vk.to_string())))
print(public_key)
ripemd160=hashlib.new('ripemd160')

ripemd160.update(hashlib.sha256(binascii.unhexlify(public_key)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.