def main():




    print "Server Private Key Generator"
    print "Server should have run for several minutes prior to this script."
    print "also, before this script runs, mash on the keyboard for a minute or so through the terminal to get more entropy.\n"

    private_key = os.urandom(32)
    pubkey = ed25519.publickey(private_key)
    doublecheck_key_works(private_key, pubkey)

    print "\n Public key for common/constants.go SERVER_PUB_KEY:"
    print pubkey.encode('hex')
    print "\n Private key for ~/.factom/factom.conf :"
    print private_key.encode('hex') + pubkey.encode('hex')
    
    print "\n\n\n"
    
    private_key = os.urandom(32)
    pubkey = ed25519.publickey(private_key)
    doublecheck_key_works(private_key, pubkey)

    print "\n Private EC key for ~/.factom/factom.conf :"
    print private_key.encode('hex') + pubkey.encode('hex')
    print "\n Public Human readable EC address to fund :"
    print public_EC_key_to_human(private_key, False)
Пример #2
0
def privkey_to_pubkey(privkey, advanced):
    """
    this function takes a 32 byte ed25519 private key and returns a 32 byte public key
    both values are binary encoded
    In this diagram: http://i.stack.imgur.com/5afWK.png
    from: http://crypto.stackexchange.com/questions/3596/is-it-possible-to-pick-your-ed25519-public-key
    takes in the k value and returns the A value
    The advanced parameter set to true displays technical internal data
    """
    pubkey = ed25519.publickey(privkey)
    if advanced == True:
        print "ed25519 Factoid public key: " + pubkey.encode('hex')
    return pubkey
def privkey_to_pubkey(privkey, advanced):
    """
    this function takes a 32 byte ed25519 private key and returns a 32 byte public key
    both values are binary encoded
    In this diagram: http://i.stack.imgur.com/5afWK.png
    from: http://crypto.stackexchange.com/questions/3596/is-it-possible-to-pick-your-ed25519-public-key
    takes in the k value and returns the A value
    The advanced parameter set to true displays technical internal data
    """
    pubkey = ed25519.publickey(privkey)
    if advanced == True:
        print "ed25519 Factoid public key: " + pubkey.encode('hex')
    return pubkey
def main():

    names = list()
    notes = list()
    privateKeys = list()
    privateKeysHuman = list()
    publicKeys = list()
    publicKeysHuman = list()

    print "Key List Generator"

    with open("names.txt") as f:
        content = f.readlines()

    for i in range(0, len(content)):
        newKey = os.urandom(32)
        privateKeys.append(newKey)
        c = content[i].strip().rsplit(':', 1)
        names.append(c[0])
        if len(c) > 1:
            notes.append(c[1])
        else:
            notes.append("")
        privateKeysHuman.append(private_key_to_human(privateKeys[i], False))

    #### Write private keys

    f = open("privateKeys.txt", "w")

    for i in range(0, len(content)):
        f.write(
            "--------------------------------------------------------------------------------\n"
        )
        #write index
        index = str(i + 1)
        for x in range(pageWidth / 2 - kerf - len(index)):
            f.write(" ")
        f.write(index)
        for x in range(kerf):
            f.write(" ")
        f.write("|")
        for x in range(kerf):
            f.write(" ")
        f.write(index)
        for x in range(pageWidth / 2 - kerf - len(index)):
            f.write(" ")
        f.write("\n")

        #write key
        left = privateKeysHuman[i][:26]
        right = privateKeysHuman[i][26:]
        for x in range(pageWidth / 2 - kerf - len(left)):
            f.write(" ")
        f.write(left)
        for x in range(kerf):
            f.write(" ")
        f.write("|")
        for x in range(kerf):
            f.write(" ")
        f.write(right)
        for x in range(pageWidth / 2 - kerf - len(right)):
            f.write(" ")
        f.write("\n")

        # write name
        for x in range(pageWidth / 2 - kerf - len(names[i])):
            f.write(" ")
        f.write(names[i])
        for x in range(kerf):
            f.write(" ")
        f.write("|")
        for x in range(kerf):
            f.write(" ")
        f.write(names[i])
        for x in range(pageWidth / 2 - kerf - len(names[i])):
            f.write(" ")
        f.write("\n")

        # write notes
        chunksize = pageWidth / 2 - kerf
        lines = len(notes[i]) / (chunksize)

        for y in range(lines + 1):
            line = notes[i][y * chunksize:y * chunksize + chunksize]
            for x in range(pageWidth / 2 - kerf - len(line)):
                f.write(" ")
            f.write(line)
            for x in range(kerf):
                f.write(" ")
            f.write("|")
            for x in range(kerf):
                f.write(" ")
            f.write(line)
            for x in range(pageWidth / 2 - kerf - len(line)):
                f.write(" ")
            f.write("\n")
    f.close()

    #### Write public keys

    f = open("publicKeys.txt", "w")

    for i in range(0, len(content)):
        publicKeys.append(ed25519.publickey(privateKeys[i]))
        publicKeysHuman.append(
            public_key_to_human_address(publicKeys[i], False))
        doublecheck_key_works(privateKeys[i], publicKeys[i], False)

        f.write(
            "--------------------------------------------------------------------------------\n"
        )
        #write index
        index = str(i + 1)
        f.write(index + "\n")
        #write pubkey human
        f.write(publicKeysHuman[i] + "\n")
        #write pubkey
        f.write(publicKeys[i].encode("Hex") + "\n")
        #write name
        f.write(names[i] + "\n")
        # write notes
        chunksize = pageWidth
        lines = len(notes[i]) / (chunksize)

        for y in range(lines + 1):
            line = notes[i][y * chunksize:y * chunksize + chunksize]
            f.write(line)
            f.write("\n")
        print names[i]
def private_key_to_human_address(private_key, advanced):
    pubkey = ed25519.publickey(private_key)
    return public_key_to_human_address(pubkey, advanced)
Пример #6
0
import sys
sys.path.append('libs')
import hashlib
import base58
import ed25519djb as ed25519
import os

# get a 32 byte random number.  This is the raw ed25519 private key
ECprivatekey = os.urandom(32)

# if using an existing private key, uncomment and add your key here
#ECprivatekey = "0000000000000000000000000000000000000000000000000000000000000000".decode("hex")

# get the matching public key for the random private key
Ed25519PrivateKey = ECprivatekey
Ed25519PublicKey = ed25519.publickey(Ed25519PrivateKey)

print "raw private key:" + ECprivatekey.encode("hex")
print "raw public key: " + Ed25519PublicKey.encode("hex")

# convert the private key to human readable form

# this is a magic number to make the first two letters be Es
privatePrefix = "5db6"

interimAddress = privatePrefix + ECprivatekey.encode("hex")
checksum = hashlib.sha256(
    hashlib.sha256(interimAddress.decode("hex")).digest()).digest()
b58encoding = base58.b58encode(interimAddress.decode("hex") + checksum[:4])

print "human readable Private Key: " + b58encoding
def main():

    names = list()
    notes = list()
    privateKeys = list()
    privateKeysHuman = list()
    publicKeys = list()
    publicKeysHuman = list()

    print "Key List Generator"

    with open("names.txt") as f:
        content = f.readlines()

    for i in range(0, len(content)):
        newKey = os.urandom(32)
        privateKeys.append(newKey)
        c = content[i].strip().rsplit(':', 1)
        names.append(c[0])
        if len(c) > 1:
            notes.append(c[1])
        else:
            notes.append("")
        privateKeysHuman.append(private_key_to_human(privateKeys[i], False))

    #### Write private keys

    f = open("privateKeys.txt", "w")

    for i in range(0, len(content)):
        f.write("--------------------------------------------------------------------------------\n")
        #write index
        index = str(i+1)
        for x in range(pageWidth/2-kerf-len(index)):
            f.write(" ")
        f.write(index)
        for x in range(kerf):
            f.write(" ")
        f.write("|")
        for x in range(kerf):
            f.write(" ")
        f.write(index)
        for x in range(pageWidth/2-kerf-len(index)):
            f.write(" ")
        f.write("\n")

        #write key
        left = privateKeysHuman[i][:26]
        right = privateKeysHuman[i][26:]
        for x in range(pageWidth/2-kerf-len(left)):
            f.write(" ")
        f.write(left)
        for x in range(kerf):
            f.write(" ")
        f.write("|")
        for x in range(kerf):
            f.write(" ")
        f.write(right)
        for x in range(pageWidth/2-kerf-len(right)):
            f.write(" ")
        f.write("\n")

        # write name
        for x in range(pageWidth/2-kerf-len(names[i])):
            f.write(" ")
        f.write(names[i])
        for x in range(kerf):
            f.write(" ")
        f.write("|")
        for x in range(kerf):
            f.write(" ")
        f.write(names[i])
        for x in range(pageWidth/2-kerf-len(names[i])):
            f.write(" ")
        f.write("\n")

        # write notes
        chunksize = pageWidth/2 - kerf
        lines = len(notes[i])/(chunksize)

        for y in range(lines+1):
            line = notes[i][y*chunksize:y*chunksize+chunksize]
            for x in range(pageWidth/2-kerf-len(line)):
                f.write(" ")
            f.write(line)
            for x in range(kerf):
                f.write(" ")
            f.write("|")
            for x in range(kerf):
                f.write(" ")
            f.write(line)
            for x in range(pageWidth/2-kerf-len(line)):
                f.write(" ")
            f.write("\n")
    f.close()


    #### Write public keys

    f = open("publicKeys.txt", "w")

    for i in range(0, len(content)):
        publicKeys.append(ed25519.publickey(privateKeys[i]))
        publicKeysHuman.append(public_key_to_human_address(publicKeys[i],False))
        doublecheck_key_works(privateKeys[i], publicKeys[i], False)

        f.write("--------------------------------------------------------------------------------\n")
        #write index
        index = str(i+1)
        f.write(index + "\n")
        #write pubkey human
        f.write(publicKeysHuman[i]+ "\n")
        #write pubkey
        f.write(publicKeys[i].encode("Hex")+ "\n")
        #write name
        f.write(names[i]+ "\n")
        # write notes
        chunksize = pageWidth
        lines = len(notes[i])/(chunksize)

        for y in range(lines+1):
            line = notes[i][y*chunksize:y*chunksize+chunksize]
            f.write(line)
            f.write("\n")
        print names[i]
def private_key_to_human_address(private_key, advanced):
    pubkey = ed25519.publickey(private_key)
    return public_key_to_human_address(pubkey, advanced)