Main > Technical Support

How to encode a PTS address?

<< < (2/3) > >>

toast:
This link may be helpful.
https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses

toast:
Hmm, I noticed he may be applying sha256 an extra time in there, since it's not possible for the script ouput to contain the actual pubkey if the input is sha256(pubkey).

Again, it might be easier if we just try this process from the very start. Are you just manually trying to generate PTS public keys? What's your goal?

toast:
I'm not sure what you mean by ASM hash. Let me step through the code for you, hopefully you can match up your string to some part of this process.


--- Code: ---OP_DUP OP_HASH160 496650cdb4b6275ca4478c0ce98cb6f7224bb1e7 OP_EQUALVERIFY OP_CHECKSIG
--- End code ---

The string in there is sha256(public_key). This script creates ripemd160(sha256(public_key)), then does some verification on it. The script outputs this string, which is <sig> <pubkey>.


--- Code: --- 304402205e81e8ed0b1f7cf6d1d415961859d3b95f5e5c353af303b6cef1e3efa6c3349702202fa9fdd6914abd0e9606c78899e7f3010cafdad211645cf459ae18b3b827b2c101 0365e0beb9a0c1497f3667067aeb8f3ea9dc4c9d5696cee7f19eae49f9457a5cfb
--- End code ---

This is where the python code starts, assigning the string to the variable "script". I cut some unimportant stuff.


--- Code: ---script = "304402205e81e8ed0b1f7cf6d1d415961859d3b95f5e5c353af303b6cef1e3efa6c3349702202fa9fdd6914abd0e9606c78899e7f3010cafdad211645cf459ae18b3b827b2c101 0365e0beb9a0c1497f3667067aeb8f3ea9dc4c9d5696cee7f19eae49f9457a5cfb".split()
h = hashlib.sha256(script[1].decode("hex")).digest()
ripe160 =  hashlib.new('ripemd160')
ripe160.update(h)
d = ripe160.digest()
--- End code ---

This just takes the pubkey and assigns ripemd160(sha256(pubkey)) to the variable "d". The rest of the code is pretty easy to match up with the diagram I linked above.


--- Code: ---#Prepend the Mainnet prefix
address = ('\x00' + d)

--- End code ---
Replace 0x00 with 0x38.

--- Code: ---#Calculate checksum
checksum = hashlib.sha256(hashlib.sha256(address).digest()).digest()[:4]
# Build the raw address
address += checksum
# Encode the address in base58
encoded_address = b58encode(address)
print encoded_address
--- End code ---

Le me know if this helps. I may be able to be more helpful if you go back a few steps and explain where you got your original "ASM hash".

5chdn:

--- Quote from: toast on January 03, 2014, 05:48:30 pm ---0x38 == 56
Will check it out when I get to a computer

--- End quote ---

Yep sorry, of course!

toast:
0x38 == 56
Will check it out when I get to a computer

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version