-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0479a74
commit 73efcf6
Showing
6 changed files
with
125 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#printf "2N8bXfrWTzqZoV89dosge2JxvE38VnHurqD" | base58 -dc | xxd -p | cut -c 2- | ||
printf "2N8bXfrWTzqZoV89dosge2JxvE38VnHurqD" | bx base58check-decode | ||
|
||
#pay to [a9 14 20byte-hash 87] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
priv='3b8407ec451a008c92c20068a6ca6e80e95c05b1a24655c646bcdadf33e8be2d' | ||
bx ec-to-public ${priv} | ||
bx ec-to-public -u ${priv} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
wif='cPaPiXu54qDEMg5UMyXmKZY8ikb12aZ6JJyzdRZF2CEQY252A9LP' | ||
#bx wif-to-ec L21LJEeJwK35wby1BeTjwWssrhrgQE2MZrpTm2zbMC677czAHHu3 | ||
bx wif-to-ec $wif | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import hashlib | ||
import binascii | ||
import ecdsa | ||
|
||
from ecdsa.util import sigencode_der, sigencode_der_canonize, sigencode_strings | ||
from ecdsa.util import sigdecode_der, sigdecode_strings | ||
from ecdsa import SigningKey, NIST256p, SECP256k1 | ||
from hash_util import hash256,dhash256,get_len_hex,formatamount,hash160,reverse_byte_order | ||
|
||
from secp256k1 import GetUncompressedkey,ParseSignature | ||
|
||
#the message for sign | ||
signed_msg='0a00903a1a547ea6c0cb20b1ef2e3926202f27c4dee9a656a57d8a6800ce67e3' | ||
print 'h_msg:', signed_msg | ||
#priv key | ||
priv_key='3b8407ec451a008c92c20068a6ca6e80e95c05b1a24655c646bcdadf33e8be2d' | ||
|
||
sk = SigningKey.from_string(binascii.unhexlify(priv_key), curve=SECP256k1) | ||
sign_data_hash_single=hash256(signed_msg.decode('hex')) | ||
sign_data_hash_double=hash256(sign_data_hash_single) | ||
print 'hash1:', sign_data_hash_single.encode('hex') | ||
print 'hash2:', sign_data_hash_double.encode('hex') | ||
#create signature | ||
der = sk.sign_digest_deterministic(sign_data_hash_double, hashfunc=hashlib.sha256, sigencode=sigencode_der_canonize) | ||
print 'der_s:',der.encode('hex') | ||
|
||
#verify signature | ||
pub_key='026225155bd431cbdd7e6d8ab07e61cd30482158b66fa11fe3c2492cd0a9dd2310' | ||
(x, y) = GetUncompressedkey(pub_key) | ||
x= hex(x)[2:].rstrip('L').zfill(64) | ||
y= hex(y)[2:].rstrip('L').zfill(64) | ||
pubkey_b=(x+y).decode('hex') | ||
(sig_r,sig_s)=ParseSignature(der.encode('hex')) | ||
print 'sig_r:', sig_r | ||
print 'sig_s:', sig_s | ||
signature=(sig_r+sig_s).lstrip('00').decode('hex') | ||
vk = ecdsa.VerifyingKey.from_string(pubkey_b, curve=ecdsa.SECP256k1) | ||
check=vk.verify(signature, sign_data_hash_single, hashlib.sha256) | ||
print 'check:', check | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters