Git Product home page Git Product logo

addresses-from-keys-jsong-pb-denver-070918's Introduction

Creating Addresses

# Address Example

from helper import encode_base58, hash160, double_sha256
sec = bytes.fromhex('025CBDF0646E5DB4EAA398F365F2EA7A0E3D419B7E0330E39CE92BDDEDCAC4F9BC')
h160 = hash160(sec)
raw = b"\x00" + h160
raw = raw + double_sha256(raw)[:4]
addr = encode_base58(raw)
print(addr)

Try it

Find the mainnet and testnet addresses corresponding to the private keys:

compressed, 888**3
uncompressed, 321
uncompressed, 4242424242
from ecc import G

from helper import double_sha256, encode_base58, hash160

components = (
    # (compressed, secret)
    (True, 888**3),
    (False, 321),
    (False, 4242424242),
)

# iterate through components
    # get the public point
    # get the sec format
    # hash160 the result
    # prepend b'\x00' for mainnet b'\x6f' for testnet
        # raw is the prefix + h160
        # get the double_sha256 of raw, first 4 bytes are the checksum
        # append checksum
        # encode_base58 the whole thing

Test Driven Exercise

from ecc import S256Point, G

from helper import double_sha256, encode_base58, hash160

class S256Point(S256Point):

    def address(self, compressed=True, testnet=False):
        '''Returns the address string'''
        # get the sec
        # hash160 the sec
        # raw is hash 160 prepended w/ b'\x00' for mainnet, b'\x6f' for testnet
        # checksum is first 4 bytes of double_sha256 of raw
        # encode_base58 the raw + checksum
        # return as a string, you can use .decode('ascii') to do this.
        pass

addresses-from-keys-jsong-pb-denver-070918's People

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.