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
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
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
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