Exemplo n.º 1
0
def createMK(denomination, cdd, not_before, mint_not_after, coin_not_after):
    import crypto

    key = crypto.createRSAKeyPair(1024)

    if denomination not in cdd.denominations:
        raise MessageError('denomination not in denominations')

    if mint_not_after <= not_before or mint_not_after > coin_not_after:
        raise MessageError('those variables do not make sense')

    hashing = cdd.issuer_cipher_suite.hashing()
    hashing.update(key.__str__())

    minting_key = containers.MintKey(hashing.digest(), cdd.currency_identifier, denomination, not_before,
                                        mint_not_after, coin_not_after, key)

    signing = cdd.issuer_cipher_suite.signing
    hashing = cdd.issuer_cipher_suite.hashing

    minting_key.setSignature(cdd.issuer_public_master_key, signing, hashing)
    
    if not minting_key.verify_with_CDD(cdd):
        raise MessageError('Just made a bad minting key')

    return minting_key
Exemplo n.º 2
0
def createMK(denomination, cdd, not_before, mint_not_after, coin_not_after):
    import crypto

    key = crypto.createRSAKeyPair(1024)

    if denomination not in cdd.denominations:
        raise MessageError('denomination not in denominations')

    if mint_not_after <= not_before or mint_not_after > coin_not_after:
        raise MessageError('those variables do not make sense')

    hashing = cdd.issuer_cipher_suite.hashing()
    hashing.update(key.__str__())

    minting_key = containers.MintKey(hashing.digest(), cdd.currency_identifier,
                                     denomination, not_before, mint_not_after,
                                     coin_not_after, key)

    signing = cdd.issuer_cipher_suite.signing
    hashing = cdd.issuer_cipher_suite.hashing

    minting_key.setSignature(cdd.issuer_public_master_key, signing, hashing)

    if not minting_key.verify_with_CDD(cdd):
        raise MessageError('Just made a bad minting key')

    return minting_key
Exemplo n.º 3
0
def createCDD():
    import crypto

    key = crypto.createRSAKeyPair(1024)

    denominations = ['1', '5', '25', '100', '500', '2500', '10000']

    hashing = crypto.SHA256HashingAlgorithm
    signing = crypto.RSASigningAlgorithm
    blinding = crypto.RSABlindingAlgorithm

    cipher_suite = crypto.CryptoContainer(signing=signing, blinding=blinding, hashing=hashing)

    cdd = containers.CurrencyDescriptionDocument(
            'OpenCoin standard', 'OpenCent', 'OC', 'IssuerLocation', denominations, cipher_suite, key)

    cdd.sign_self(signing, hashing)

    return cdd
Exemplo n.º 4
0
def createDSDBCertificate(cdd, not_before, not_after):
    import crypto

    key = crypto.createRSAKeyPair(1024)

    if not_before > not_after:
        raise MessageError('that does not make sense')

    hashing = cdd.issuer_cipher_suite.hashing(str(key))

    encrypting = crypto.RSAEncryptionAlgorithm

    cert = containers.DSDBKey(hashing.digest(), not_before, not_after, encrypting, key)

    signing = cdd.issuer_cipher_suite.signing
    hashing = cdd.issuer_cipher_suite.hashing
    
    cert.addAdSignature(cdd.issuer_public_master_key, signing, hashing)
    
    if not cert.verify_with_CDD(cdd):
        raise MessageErrror('Just made a bad DSDB cert')

    return cert
Exemplo n.º 5
0
def createDSDBCertificate(cdd, not_before, not_after):
    import crypto

    key = crypto.createRSAKeyPair(1024)

    if not_before > not_after:
        raise MessageError('that does not make sense')

    hashing = cdd.issuer_cipher_suite.hashing(str(key))

    encrypting = crypto.RSAEncryptionAlgorithm

    cert = containers.DSDBKey(hashing.digest(), not_before, not_after,
                              encrypting, key)

    signing = cdd.issuer_cipher_suite.signing
    hashing = cdd.issuer_cipher_suite.hashing

    cert.addAdSignature(cdd.issuer_public_master_key, signing, hashing)

    if not cert.verify_with_CDD(cdd):
        raise MessageErrror('Just made a bad DSDB cert')

    return cert
Exemplo n.º 6
0
def createCDD():
    import crypto

    key = crypto.createRSAKeyPair(1024)

    denominations = ['1', '5', '25', '100', '500', '2500', '10000']

    hashing = crypto.SHA256HashingAlgorithm
    signing = crypto.RSASigningAlgorithm
    blinding = crypto.RSABlindingAlgorithm

    cipher_suite = crypto.CryptoContainer(signing=signing,
                                          blinding=blinding,
                                          hashing=hashing)

    cdd = containers.CurrencyDescriptionDocument('OpenCoin standard',
                                                 'OpenCent', 'OC',
                                                 'IssuerLocation',
                                                 denominations, cipher_suite,
                                                 key)

    cdd.sign_self(signing, hashing)

    return cdd