Changeset 168

Show
Ignore:
Timestamp:
03/04/08 20:13:12 (4 years ago)
Author:
ocmathew
Message:

Modify containers. All hard-coded values for signatures/hashes had to be changed.
Changes to CDDs: Changed standard_version to standard_identifier, added options
Changes to MintKeys?: Changed coin_not_after to token_not_after
Changes to CDDs, MintKeys?, Coins: Changed denomination to a string
Updated protocol.txt to remove some DSDB_key stuff
Updated protocol-containers.txt to reflect changed containers

Location:
trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/pyopencoin/oc/containers.py

    r163 r168  
    1 import base64,json 
     1import base64 
     2import json 
     3import types 
    24 
    35class Container(object): 
     
    258260    ...                              hashing=crypto.SHA256HashingAlgorithm) 
    259261     
    260     >>> cdd = CDD(standard_version = 'http://opencoin.org/OpenCoinProtocol/1.0', 
     262    >>> cdd = CDD(standard_identifier = 'http://opencoin.org/OpenCoinProtocol/1.0', 
    261263    ...           currency_identifier = 'http://opencent.net/OpenCent',  
    262264    ...           short_currency_identifier = 'OC',  
    263265    ...           issuer_service_location = 'opencoin://issuer.opencent.net:8002',  
    264     ...           denominations = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000],  
     266    ...           denominations = ['1', '2', '5', '10', '20', '50', '100', '200', '500', '1000'],  
    265267    ...           issuer_cipher_suite = ics,  
     268    ...           options = [], 
    266269    ...           issuer_public_master_key = crypto.RSAKeyPair(e=17L,n=3233L)) 
    267270 
    268271    >>> j = cdd.content_part() 
    269272    >>> j 
    270     '[["standard_version","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["short_currency_identifier","OC"],["issuer_service_location","opencoin://issuer.opencent.net:8002"],["denominations",[1,2,5,10,20,50,100,200,500,1000]],["issuer_cipher_suite",["RSASigningAlgorithm","RSABlindingAlgorithm","SHA256HashingAlgorithm"]],["issuer_public_master_key","DKE=,EQ=="]]' 
     273    '[["standard_identifier","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["short_currency_identifier","OC"],["issuer_service_location","opencoin://issuer.opencent.net:8002"],["denominations",["1","2","5","10","20","50","100","200","500","1000"]],["issuer_cipher_suite",["RSASigningAlgorithm","RSABlindingAlgorithm","SHA256HashingAlgorithm"]],["options",[]],["issuer_public_master_key","DKE=,EQ=="]]' 
    271274  
    272275    >>> cdd2 = CDD().fromJson(j) 
     
    278281 
    279282    >>> cdd2.toJson() 
    280     '[["standard_version","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["short_currency_identifier","OC"],["issuer_service_location","opencoin://issuer.opencent.net:8002"],["denominations",[1,2,5,10,20,50,100,200,500,1000]],["issuer_cipher_suite",["RSASigningAlgorithm","RSABlindingAlgorithm","SHA256HashingAlgorithm"]],["issuer_public_master_key","DKE=,EQ=="],["signature",[["keyprint","XQ=="],["signature","Vg=="]]]]' 
     283    '[["standard_identifier","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["short_currency_identifier","OC"],["issuer_service_location","opencoin://issuer.opencent.net:8002"],["denominations",["1","2","5","10","20","50","100","200","500","1000"]],["issuer_cipher_suite",["RSASigningAlgorithm","RSABlindingAlgorithm","SHA256HashingAlgorithm"]],["options",[]],["issuer_public_master_key","DKE=,EQ=="],["signature",[["keyprint","XQ=="],["signature","Vg=="]]]]' 
    281284     
    282285     
     
    304307    from crypto import encodeCryptoContainer, decodeCryptoContainer, decodeRSAKeyPair 
    305308     
    306     fields = ['standard_version',  
     309    fields = ['standard_identifier',  
    307310              'currency_identifier',  
    308311              'short_currency_identifier',  
     
    310313              'denominations',  
    311314              'issuer_cipher_suite',  
     315              'options', 
    312316              'issuer_public_master_key'] 
    313317 
     
    348352    >>> mintKey = MintKey(key_identifier=key_id, 
    349353    ...                   currency_identifier='http://opencent.net/OpenCent', 
    350     ...                   denomination=1, 
     354    ...                   denomination="1", 
    351355    ...                   not_before=timegm((2008,1,1,0,0,0)), 
    352356    ...                   key_not_after=timegm((2008,2,1,0,0,0)), 
    353     ...                   coin_not_after=timegm((2008,4,1,0,0,0)), 
     357    ...                   token_not_after=timegm((2008,4,1,0,0,0)), 
    354358    ...                   public_key=public) 
    355359                           
     
    369373 
    370374    >>> mintKey.toJson() 
    371     '[["key_identifier","..."],["currency_identifier","http://opencent.net/OpenCent"],["denomination",1],["not_before","2008-01-01T00:00:00Z"],["key_not_after","2008-02-01T00:00:00Z"],["coin_not_after","2008-04-01T00:00:00Z"],["public_key","..."],["signature",[["keyprint","hxz5pRwS+RFp88qQliXYm3R5uNighktwxqEh4RMOuuk="],["signature","..."]]]]' 
     375    '[["key_identifier","..."],["currency_identifier","http://opencent.net/OpenCent"],["denomination","1"],["not_before","2008-01-01T00:00:00Z"],["key_not_after","2008-02-01T00:00:00Z"],["token_not_after","2008-04-01T00:00:00Z"],["public_key","..."],["signature",[["keyprint","hxz5pRwS+RFp88qQliXYm3R5uNighktwxqEh4RMOuuk="],["signature","..."]]]]' 
    372376 
    373377    Well, we are going to test that verify_with_CDD works now. We've already 
     
    444448              'not_before',  
    445449              'key_not_after',  
    446               'coin_not_after', 
     450              'token_not_after', 
    447451              'public_key'] 
    448452 
     
    453457              'not_before':{'encode':encodeTime,'decode':decodeTime}, 
    454458              'key_not_after':{'encode':encodeTime,'decode':decodeTime}, 
    455               'coin_not_after':{'encode':encodeTime,'decode':decodeTime}} 
     459              'token_not_after':{'encode':encodeTime,'decode':decodeTime}} 
    456460 
    457461    def __init__(self, **kwargs): 
    458462        ContainerWithSignature.__init__(self, **kwargs) 
    459463        self.keytype = kwargs.get('keytype', None) 
     464        if self.denomination and not isinstance(self.denomination, types.StringType): 
     465            raise Exception('Tried to set a denomination that was not a string') 
    460466 
    461467    def verify_with_CDD(self, currency_description_document): 
     
    491497 
    492498        can_mint = time >= self.not_before and time <= self.key_not_after 
    493         can_redeem = time >= self.not_before and time <= self.coin_not_after 
     499        can_redeem = time >= self.not_before and time <= self.token_not_after 
    494500 
    495501        return (can_mint, can_redeem) 
     
    500506     
    501507    Test the adding of currencies 
    502     >>> b = CurrencyBase(standard_version = 'http://opencoin.org/OpenCoinProtocol/1.0', 
     508    >>> b = CurrencyBase(standard_identifier = 'http://opencoin.org/OpenCoinProtocol/1.0', 
    503509    ...                 currency_identifier = 'http://opencent.net/OpenCent', 
    504510    ...                 denomination = '1', 
     
    521527 
    522528    Test proper encoding/decoding of key_identifier and serial 
    523     >>> b = CurrencyBase(standard_version = 'http://opencoin.org/OpenCoinProtocol/1.0', 
     529    >>> b = CurrencyBase(standard_identifier = 'http://opencoin.org/OpenCoinProtocol/1.0', 
    524530    ...                 currency_identifier = 'http://opencent.net/OpenCent', 
    525531    ...                 denomination = '1', 
     
    529535    >>> j = b.toJson() 
    530536    >>> j 
    531     '[["standard_identifier",null],["currency_identifier","http://opencent.net/OpenCent"],["denomination","1"],["key_identifier","YQ=="],["serial","Yg=="]]' 
     537    '[["standard_identifier","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["denomination","1"],["key_identifier","YQ=="],["serial","Yg=="]]' 
    532538 
    533539    >>> b == CurrencyBase().fromJson(j) 
     
    587593            return False 
    588594 
    589         if self.standard_identifier != cdd.standard_version: 
     595        if self.standard_identifier != cdd.standard_identifier: 
    590596            return False 
    591597 
     
    621627    >>> blank = CurrencyBlank(standard_identifier='http://OpenCoin/1.0/', 
    622628    ...                       currency_identifier='http://OpenCent', 
    623     ...                       denomination=1, 
     629    ...                       denomination='1', 
    624630    ...                       key_identifier='cent') 
    625631 
     
    632638 
    633639    >>> blank.toJson() 
    634     '[["standard_identifier","http://OpenCoin/1.0/"],["currency_identifier","http://OpenCent"],["denomination",1],["key_identifier","Y2VudA=="],["serial","MTIz"]]' 
     640    '[["standard_identifier","http://OpenCoin/1.0/"],["currency_identifier","http://OpenCent"],["denomination","1"],["key_identifier","Y2VudA=="],["serial","MTIz"]]' 
    635641 
    636642    >>> blank.serial = None 
     
    665671    >>> mintKey1 = MintKey(key_identifier=public1.key_id(hash_alg), 
    666672    ...                   currency_identifier='http://opencent.net/OpenCent', 
    667     ...                   denomination=1, 
     673    ...                   denomination='1', 
    668674    ...                   not_before=timegm((2008,1,1,0,0,0)), 
    669675    ...                   key_not_after=timegm((2008,2,1,0,0,0)), 
    670     ...                   coin_not_after=timegm((2008,4,1,0,0,0)), 
     676    ...                   token_not_after=timegm((2008,4,1,0,0,0)), 
    671677    ...                   public_key=public1) 
    672678    >>> mintKey1 = addSignature(mintKey1, hash_alg, sign_alg, CDD_private, CDD.signature.keyprint)  
     
    679685    >>> mintKey5 = MintKey(key_identifier=public5.key_id(hash_alg), 
    680686    ...                   currency_identifier='http://opencent.net/OpenCent', 
    681     ...                   denomination=5, 
     687    ...                   denomination='5', 
    682688    ...                   not_before=timegm((2008,1,1,0,0,0)), 
    683689    ...                   key_not_after=timegm((2008,2,1,0,0,0)), 
    684     ...                   coin_not_after=timegm((2008,4,1,0,0,0)), 
     690    ...                   token_not_after=timegm((2008,4,1,0,0,0)), 
    685691    ...                   public_key=public5) 
    686692    >>> mintKey5 = addSignature(mintKey5, hash_alg, sign_alg, CDD_private, CDD.signature.keyprint)  
     
    690696     
    691697    FIXME XXX A blank references a standard identifier, and a CDD uses a standard version! 
    692     >>> blank = CurrencyBlank(standard_identifier=CDD.standard_version, 
     698    >>> blank = CurrencyBlank(standard_identifier=CDD.standard_identifier, 
    693699    ...                       currency_identifier=CDD.currency_identifier, 
    694     ...                       denomination=1, 
     700    ...                       denomination='1', 
    695701    ...                       key_identifier=mintKey1.key_identifier, 
    696702    ...                       serial='abcdefghijklmnopqrstuvwxyz') 
    697703 
    698704    >>> blank.toJson() 
    699     '[["standard_identifier","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["denomination",1],["key_identifier","sj17RxE1hfO06+oTgBs9Z7xLut/3NN+nHJbXSJYTks0="],["serial","YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo="]]' 
     705    '[["standard_identifier","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["denomination","1"],["key_identifier","sj17RxE1hfO06+oTgBs9Z7xLut/3NN+nHJbXSJYTks0="],["serial","YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo="]]' 
    700706 
    701707    >>> blank.content_part() == blank.toJson() 
     
    704710    >>> blind_value = blank.blind_blank(CDD, mintKey1, blind_factor='blind factor') 
    705711    >>> base64.b64encode(blind_value) 
    706     'Ni+1wlpQxCL+zDhK4K2KKfq1MgeX5+t2VXIuP2qhqe4nw3OZGphOW30/jZfmlBuLUFomdIc7g4iRwRF34D7gCQ==' 
     712    'FtDSI1eT2FsXK+R/zJVk9mGTRan4KQsogVmSMFts3kVrdV4y3mkIuYEaZ3B0ZP491rqR0QtIlVEAYf8sQNgbhQ==' 
    707713     
    708714    Do some magic as the mint 
    709715    >>> blind_sig = sign_alg(private1).sign(blind_value) 
    710716    >>> base64.b64encode(blind_sig) 
    711     'BaH8tyK3D6qg3UaxIZ7zVRWee7vMsBMbkO1ZboeMEWr+rjE0P1JvqyAUp6G/Q5XB6DJ4+Li2xM9d2DJiB+VR5Q==' 
     717    'ZEDz4RHVwUByR+QXwgZcNeIyg9T3hAgxl0taabVKjbv0DbxTmHYK9fgqlCtBSAvmNntk03DMKrIPpaLuAV3UcA==' 
    712718 
    713719    >>> clear_sig = blank.unblind_signature(blind_sig) 
    714720    >>> base64.b64encode(clear_sig) 
    715     'cK8f0bus8nP73pbNP/8Hm+7WojucymlijU1ERmR2Z0WMs44PVpqxnj81ZuBy8ojEA8xepFaEQScSENcoHz26dQ==' 
     721    'HIck+fim0TkjVupU1AeKpuSGN1CxLnDmT2jpBHMZSgdpYhKE90XoAsQVznljEn4NTXvRs5cXslWUNvcUeAuv2A==' 
    716722 
    717723    Check for the same signature 
     
    724730 
    725731    >>> coin.toJson() 
    726     '[["standard_identifier","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["denomination",1],["key_identifier","sj17RxE1hfO06+oTgBs9Z7xLut/3NN+nHJbXSJYTks0="],["serial","YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo="],["signature","cK8f0bus8nP73pbNP/8Hm+7WojucymlijU1ERmR2Z0WMs44PVpqxnj81ZuBy8ojEA8xepFaEQScSENcoHz26dQ=="]]' 
     732    '[["standard_identifier","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["denomination","1"],["key_identifier","sj17RxE1hfO06+oTgBs9Z7xLut/3NN+nHJbXSJYTks0="],["serial","YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo="],["signature","HIck+fim0TkjVupU1AeKpuSGN1CxLnDmT2jpBHMZSgdpYhKE90XoAsQVznljEn4NTXvRs5cXslWUNvcUeAuv2A=="]]' 
    727733 
    728734    >>> coin2 = blank.newCoin(clear_sig, CDD, mintKey1) 
     
    749755 
    750756    Test other blank functions. 
    751     >>> blank2 = CurrencyBlank(standard_identifier=CDD.standard_version, 
     757    >>> blank2 = CurrencyBlank(standard_identifier=CDD.standard_identifier, 
    752758    ...                       currency_identifier=CDD.currency_identifier, 
    753     ...                       denomination=1, 
     759    ...                       denomination='1', 
    754760    ...                       key_identifier=mintKey1.key_identifier, 
    755761    ...                       serial='abcdefghijklmnopqrstuvwxyz') 
    756762    >>> blank2.setBlind(blind_alg, mintKey1.public_key, 'blind factor') 
    757763    >>> base64.b64encode(blank2.unblind_signature(blind_sig)) 
    758     'cK8f0bus8nP73pbNP/8Hm+7WojucymlijU1ERmR2Z0WMs44PVpqxnj81ZuBy8ojEA8xepFaEQScSENcoHz26dQ==' 
    759  
    760     >>> blank3 = CurrencyBlank(standard_identifier=CDD.standard_version, 
     764    'HIck+fim0TkjVupU1AeKpuSGN1CxLnDmT2jpBHMZSgdpYhKE90XoAsQVznljEn4NTXvRs5cXslWUNvcUeAuv2A==' 
     765 
     766    >>> blank3 = CurrencyBlank(standard_identifier=CDD.standard_identifier, 
    761767    ...                       currency_identifier=CDD.currency_identifier, 
    762     ...                       denomination=1, 
     768    ...                       denomination='1', 
    763769    ...                       key_identifier=mintKey1.key_identifier, 
    764770    ...                       serial='abcdefghijklmnopqrstuvwxyz', 
     
    766772    >>> blank3.setBlind(blind_alg, mintKey1.public_key) 
    767773    >>> base64.b64encode(blank3.unblind_signature(blind_sig)) 
    768     'cK8f0bus8nP73pbNP/8Hm+7WojucymlijU1ERmR2Z0WMs44PVpqxnj81ZuBy8ojEA8xepFaEQScSENcoHz26dQ==' 
     774    'HIck+fim0TkjVupU1AeKpuSGN1CxLnDmT2jpBHMZSgdpYhKE90XoAsQVznljEn4NTXvRs5cXslWUNvcUeAuv2A==' 
    769775 
    770776    And this is the normal and standard way to make a blank and blind 
    771     >>> blank4 = CurrencyBlank(standard_identifier=CDD.standard_version, 
     777    >>> blank4 = CurrencyBlank(standard_identifier=CDD.standard_identifier, 
    772778    ...                       currency_identifier=CDD.currency_identifier, 
    773     ...                       denomination=1, 
     779    ...                       denomination='1', 
    774780    ...                       key_identifier=mintKey1.key_identifier) 
    775781    >>> blank4.generateSerial() 
     
    860866    >>> mintKey = mintKeys[0] 
    861867 
    862     >>> signature = 'cK8f0bus8nP73pbNP/8Hm+7WojucymlijU1ERmR2Z0WMs44PVpqxnj81ZuBy8ojEA8xepFaEQScSENcoHz26dQ==' 
    863  
    864     >>> coin = CurrencyCoin(standard_identifier=CDD.standard_version, 
     868    >>> signature = 'HIck+fim0TkjVupU1AeKpuSGN1CxLnDmT2jpBHMZSgdpYhKE90XoAsQVznljEn4NTXvRs5cXslWUNvcUeAuv2A==' 
     869 
     870    >>> coin = CurrencyCoin(standard_identifier=CDD.standard_identifier, 
    865871    ...                     currency_identifier=CDD.currency_identifier, 
    866     ...                     denomination=1, 
     872    ...                     denomination='1', 
    867873    ...                     key_identifier=mintKey.key_identifier, 
    868874    ...                     serial='abcdefghijklmnopqrstuvwxyz', 
     
    870876 
    871877    >>> coin.toJson() 
    872     '[["standard_identifier","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["denomination",1],["key_identifier","sj17RxE1hfO06+oTgBs9Z7xLut/3NN+nHJbXSJYTks0="],["serial","YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo="],["signature","cK8f0bus8nP73pbNP/8Hm+7WojucymlijU1ERmR2Z0WMs44PVpqxnj81ZuBy8ojEA8xepFaEQScSENcoHz26dQ=="]]' 
     878    '[["standard_identifier","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["denomination","1"],["key_identifier","sj17RxE1hfO06+oTgBs9Z7xLut/3NN+nHJbXSJYTks0="],["serial","YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo="],["signature","HIck+fim0TkjVupU1AeKpuSGN1CxLnDmT2jpBHMZSgdpYhKE90XoAsQVznljEn4NTXvRs5cXslWUNvcUeAuv2A=="]]' 
    873879 
    874880    >>> coin.content_part() 
    875     '[["standard_identifier","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["denomination",1],["key_identifier","sj17RxE1hfO06+oTgBs9Z7xLut/3NN+nHJbXSJYTks0="],["serial","YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo="]]' 
     881    '[["standard_identifier","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["denomination","1"],["key_identifier","sj17RxE1hfO06+oTgBs9Z7xLut/3NN+nHJbXSJYTks0="],["serial","YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo="]]' 
    876882 
    877883    >>> coin2 = CurrencyCoin().fromJson(coin.toJson()) 
  • trunk/pyopencoin/oc/entities.py

    r167 r168  
    102102        True 
    103103        >>> test_coins[0].denomination 
    104         2 
     104        '2' 
    105105        >>> test_coins[3].denomination 
    106         5 
     106        '5' 
    107107        >>> test_coins[4].denomination 
    108         10 
     108        '10' 
    109109        >>> sum(test_coins) 
    110110        21 
     
    212212            return [] 
    213213 
    214         if sum(denomination_list) != sum(self.coins): 
     214        int_denomination_list = [int(d) for d in denomination_list] 
     215 
     216        if sum(int_denomination_list) != sum(self.coins): 
    215217            raise Exception('denomination_list and self.coins differ!') 
    216218 
    217         denominations_to_use = my_split(denomination_list, amount) 
     219        denominations_to_use = my_split(int_denomination_list, amount) 
    218220 
    219221        if not denominations_to_use: 
    220222            raise UnableToDoError('Not enough tokens') 
     223 
     224        denominations_to_use = [str(d) for d in denominations_to_use] 
    221225 
    222226        to_use = [] 
  • trunk/pyopencoin/oc/protocols.py

    r163 r168  
    352352    >>> ttr.state = ttr.start 
    353353    >>> ttr.state(Message('TRANSFER_TOKEN_REQUEST',['1234', 'my account', blindslist, [], [['type', 'mint']]])) 
    354     <Message('TRANSFER_TOKEN_ACCEPT',['1234', [['sj17RxE1hfO06+oTgBs9Z7xLut/3NN+nHJbXSJYTks0=', ['jWUOkVfIulEvPjR4HfdxOtEF2vk3ss8vkKSL6aSd2w4Sj0vChSjtmiabkWdbxLTLth13dmigB0vBXDggjBzM7w==']], ['WbXTWO4M60oZ/LGY+sccKf5Oq6HxrjrY4qAxrBDXuek=', ['xBzoYV7W/2NuWdQQrwal7xFbky5D/m3D5Y9aTtuwZPirvK4gx7Po5+VrfGm04BuHo7kwnZ3ZGfUDIXIoILm2ng==']]]])> 
     354    <Message('TRANSFER_TOKEN_ACCEPT',['1234', [['sj17RxE1hfO06+oTgBs9Z7xLut/3NN+nHJbXSJYTks0=', ['Do0el3uxdyFMF8NdXtowBLBOxXM0r7xR9hXkaZWEhPUBQCe8yaYGO09wnxrWEVFlt0r9M6bCZxKtzNGDGw3/XQ==']], ['WbXTWO4M60oZ/LGY+sccKf5Oq6HxrjrY4qAxrBDXuek=', ['dTnL8yTkdelG9fW//ZoKzUl7LTjBXiElaHkfyMLgVetEM7pmEzfcdfRWhm2PP3IhnkZ8CmAR1uOJ99rJ+XBASA==']]]])> 
    355355 
    356356    Now, check to make sure the implemenation is good 
  • trunk/pyopencoin/oc/tests.py

    r165 r168  
    88 
    99>>> CDD.toJson() 
    10 '[["standard_version","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["short_currency_identifier","OC"],["issuer_service_location","opencoin://issuer.opencent.net:8002"],["denominations",[1,2,5,10,20,50,100,200,500,1000]],["issuer_cipher_suite",["RSASigningAlgorithm","RSABlindingAlgorithm","SHA256HashingAlgorithm"]],["issuer_public_master_key","sloGu4+P4rslyC4RiAJrZbG0Z90FwEV88eW1JnNv7BDU33+uIhi2G0f/XL+AoUwmF1VsdhQhzEtGNVjnlx0TViWgqvrYX6AqB1/R3zYP9+JnuIIyHiyS+Z+Y3uoB0sLMD+dvHcDRo7cbb+ZNAvlcPoQ4Hb3+tuxwBMmVkZMaOu8=,AQAB"],["signature",[["keyprint","hxz5pRwS+RFp88qQliXYm3R5uNighktwxqEh4RMOuuk="],["signature","fmgREXeLvrziaPMFa4/KNR9aNda4DZPO+6noROTlbNVX+7ht2Gp/58t6V5eO9HUD2yOWLmVvOlLfVIwmC8PJDefRhMC7ZYt/5tw9ydtiD/zBJzzHGPnK6akB1l2/bkBHEQPXm0PmTFfY5qH069CK0HxzCOj7O6uYFOUqg9slQek="]]]]' 
     10'[["standard_identifier","http://opencoin.org/OpenCoinProtocol/1.0"],["currency_identifier","http://opencent.net/OpenCent"],["short_currency_identifier","OC"],["issuer_service_location","opencoin://issuer.opencent.net:8002"],["denominations",["1","2","5","10","20","50","100","200","500","1000"]],["issuer_cipher_suite",["RSASigningAlgorithm","RSABlindingAlgorithm","SHA256HashingAlgorithm"]],["options",[]],["issuer_public_master_key","sloGu4+P4rslyC4RiAJrZbG0Z90FwEV88eW1JnNv7BDU33+uIhi2G0f/XL+AoUwmF1VsdhQhzEtGNVjnlx0TViWgqvrYX6AqB1/R3zYP9+JnuIIyHiyS+Z+Y3uoB0sLMD+dvHcDRo7cbb+ZNAvlcPoQ4Hb3+tuxwBMmVkZMaOu8=,AQAB"],["signature",[["keyprint","hxz5pRwS+RFp88qQliXYm3R5uNighktwxqEh4RMOuuk="],["signature","fifLuwjQXpviAD6ruHXaW09HipPNmrX41n125Ku+AAplbNDMHs/+jCRQGwJ4yMyk0hNsX/Idqhm3ckebZAujync03mWMRA4pZEMLmYdkjLsOSdw7YoPFO2+Ah5GILnGB4WRm3L1q9yeaCCrjuoZO135vUV1ykUl7k2LBOKMxw4A="]]]]' 
    1111 
    1212Lets test without having any keys in the mint 
     
    103103    public_key = private_key.newPublicKeyPair() 
    104104 
    105     cdd = containers.CDD(standard_version='http://opencoin.org/OpenCoinProtocol/1.0', 
     105    cdd = containers.CDD(standard_identifier='http://opencoin.org/OpenCoinProtocol/1.0', 
    106106                         currency_identifier = 'http://opencent.net/OpenCent', 
    107107                         short_currency_identifier = 'OC', 
    108108                         issuer_service_location = 'opencoin://issuer.opencent.net:8002', 
    109                          denominations = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000], 
     109                         denominations = ['1', '2', '5', '10', '20', '50', '100', '200', '500', '1000'], 
    110110                         issuer_cipher_suite = ics, 
     111                         options = [], 
    111112                         issuer_public_master_key = public_key) 
    112113 
     
    205206     
    206207    >>> base64.b64encode(mintkey1.signature.signature) 
    207     'l6viHZFCZSlYVRVXrawzb7MYPmgVbkuCbjot5giOiGWJ7PuiTUOFd5O/CTf5QRX6snrzQhLqImQ414Z2vNChcVBBu1zIslQ9Pxti1WW9EA0Z8akeQoWG11S4eqbwvbBHStO1uB6vGQAkR9g1zJvS+NG3vzF/vYnADtD5CQ4bpvg=' 
     208    'YaVpcSavYfEwKuoaR3PPsSMBD3c2bMSP4iHdHAUKqmOFrb5qgrNPhLwPNAeSZe6qoLB09bIFVFFW46Xv+FzZ3WghmlRmtKD+LFV9+2xu/jXAjwi+VqSFwjLjttbxSbeYWce6IiWKlklHBBZ2zwXY5CP2QqZ6Zt5i0HE6fEM8KRU=' 
    208209 
    209210    >>> base64.b64encode(mintkey2.signature.signature) 
    210     'iVcVpYvER6702tkYvqqdiOuugMKqhHAwln1jDLTk1sGyZPr0y5b1V/qqgYpJUBayZM/hRtWlN4NxiRQbISjU1ZGAZTmARYfU+MigCXbATZXaS1GjZjx2/gIZnTFHF9T6N6elTKTmqQdV0ZExjWZmHDmco0alwOKK9n+ta5o7pvs=' 
     211    'Es5my5lRwFVYx49EVMJwZPgoXC00QBFCvS0H0MRC+rxCufY+s59ivai20+aTjq+cO5hslEIE4L3ne0bMpNliG2d4XP9fuLCggGbtzrCLEAt6GLS9xEzIsk0EbGAxLxceL28zJTJHQqZm1pRKHbH0Gv5pxZmMx3AmGB80uOCjdBU=' 
    211212     
    212213    >>> base64.b64encode(mintkey5.signature.signature) 
    213     'IJmSiWPoNOt+kMZle3Z/4Fex17l4D8Hq1tr1l01MCGWHS1+6syOxIIJ2giSQmPQlZRrTwRrbUOEblGs9K0G+e4OlbzB5CywDo6z9FDWSSnXqlEEEt4tYzzsAjqvhjPq3/i182J5sucb70ea+vrIj7Kll5V9JYAxMocgd16dXwDc=' 
     214    'epNc+/Nq3lshowLTi4tue26m0ED62cue95vqvMSllDtV4cBZ23YCEDGD8aHmcJZ7bB12MCE/lAWO6aR4FQDfyc1U6LAbuOuuAERnZhaDc9ZKWvamn3uPvjV3722vje4P6Ic2sbJ+ch7NItrmdktnG4Vap88iIAPCnWl/zivZUWA=' 
    214215     
    215216    >>> base64.b64encode(mintkey10.signature.signature) 
    216     'nx5Jthxo4QMPTmyEui/TVyKyDxjCnhhJLeAbgYyl5tkk+VNNzdkBd7Ry/wCv5ijs8lSUTkPaQt/d3AVHlMxSTF93/5y1/vl47hFpAyclXlMkqagGuGrFSsnQYYqEnhnCcaAl6i9rBGcrQh4YYFA3fIVkkVa/fL2aIYpPpoMvKcg=' 
     217    'EwgUD6dZVkIEw8ALyVAIkSQLqbfzdNEMD3cYIZZHZ3TuxoKtvT3RG9NnN+PhWKH956ehNmbyVVOLqmEABMIi+3CXLGhkO2YqVCW9619gAF5S/UaYRVE+ijWcAYbAWoBestRhirnBEEBvBcFRk1rQJx8IqEzBMyUk//UbvcneVog=' 
    217218    """ 
    218219    from containers import MintKey 
     
    230231                          not_before=timegm((2008,1,1,0,0,0)), 
    231232                          key_not_after=timegm((2008,2,1,0,0,0)), 
    232                           coin_not_after=timegm((2008,4,1,0,0,0)), 
     233                          token_not_after=timegm((2008,4,1,0,0,0)), 
    233234                          public_key=public) 
    234235        addSignature(mintKey, hash_alg, sign_alg, CDD_private, CDD.signature.keyprint) 
     
    238239    private0 = keys512[0] 
    239240    public0 = private0.newPublicKeyPair() 
    240     mintKey0 = makeMintKey(1, public0, private0) 
     241    mintKey0 = makeMintKey('1', public0, private0) 
    241242 
    242243    private1 = keys512[1] 
    243244    public1 = private1.newPublicKeyPair() 
    244     mintKey1 = makeMintKey(2, public1, private1) 
     245    mintKey1 = makeMintKey('2', public1, private1) 
    245246 
    246247    private2 = keys512[2] 
    247248    public2 = private2.newPublicKeyPair() 
    248     mintKey2 = makeMintKey(5, public2, private2)   
     249    mintKey2 = makeMintKey('5', public2, private2)   
    249250 
    250251    private3 = keys512[3] 
    251252    public3 = private3.newPublicKeyPair() 
    252     mintKey3 = makeMintKey(10, public3, private3)   
     253    mintKey3 = makeMintKey('10', public3, private3)   
    253254 
    254255    return (mintKey0, mintKey1, mintKey2, mintKey3) 
     
    290291     
    291292    def makeCoin(serial, private_key, mint_key): 
    292         coin = CurrencyCoin(standard_identifier=CDD.standard_version, 
     293        coin = CurrencyCoin(standard_identifier=CDD.standard_identifier, 
    293294                            currency_identifier=CDD.currency_identifier, 
    294295                            denomination=mint_key.denomination, 
  • trunk/standards/protocol-containers.txt

    r123 r168  
    3636Currency Description Document (CCD) = 
    3737{ 
    38     standard version            = http://opencoin.org/OpenCoinProtocol/1.0 
     38    standard identifier         = http://opencoin.org/OpenCoinProtocol/1.0 
    3939    currency identifier         = http://opencent.net/OpenCent 
    4040    short currency identifier   = OC  
    4141    issuer service location     = opencoin://issuer.opencent.net:8002 
    42     denominations               = 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000  #list of strings seperated by commas 
     42    denominations               = ['1', '2', '5', ...] #list of strings 
    4343    issuer cipher suite         = HASH-ALG, SIGN-ALG, BLINDING-ALG 
     44    options                     = list(options) | list() 
    4445    issuer public master key    = base64(pM) 
    4546 
     
    5657    not_before          = TIME(...) 
    5758    key_not_after       = TIME(...) 
    58     coin_not_after      = TIME(...) 
     59    token_not_after     = TIME(...) 
    5960    public key          = base64(pP) 
    6061 
  • trunk/standards/protocol.txt

    r144 r168  
    2929   - "Introduction" 
    3030   - replace "COIN_SPEND" with "TRANSFER_TOKEN" 
    31    - decide whether the protocol atoms are tokens or lists of tokens 
    3231   - throw out reduntant "TRANSFER_TOKEN" explanatoins 
    3332   - add authentication and authorization, at least for "target" 
    34      when mintig 
     33     when minting 
    3534   - add mandatory trusted channel (Bluetooth, TLS) 
    3635 
     
    107106   
    108107  Questions: 
    109   * CDD? (What does this question mean?) 
    110  
    111 * issuer creates DSDB keypair (pD,sD) 
    112  
    113   { 
    114     key identifier   = base64(hash(pD)) 
    115     not_before       = TIME(...) 
    116     not_after        = TIME(...) 
    117     cipher           = ENCRYPTION-ALG 
    118     public key       = base64(pD) 
    119  
    120     issuer           = base64(hash(pM)) 
    121     signature        = base64(sig(sM, hash(content part))) 
    122  
    123     signer           = base64(hash(pM)) 
    124     signature        = base64(sig(sM, hash(content part))) 
    125   }    
    126  
     108  * CDD? 
    127109 
    128110* issuer fires up issuer service (=IS) at <opencoin://issuer.opencent.net:8002> 
     
    163145   
    164146 
    165 3.3.5 "TRANSFER_TOKEN": A generic wallet-issuer request 
     147t 3.3.5 "TRANSFER_TOKEN": A generic wallet-issuer request 
    166148 
    167149The atom for this transaction is a list of tokens - if one of the tokens /blanks 
     
    199181  If the request is accepted with no delay, IS answers 
    200182 
    201     TRANSFER_TOKEN_ACCEPT( transaction_id, message, list_of_singed_blinds) 
     183    TRANSFER_TOKEN_ACCEPT( transaction_id, message, list_of_signed_blinds) 
    202184 
    203185  (with list_of_singed_blinds empty if no minting was required) 
     
    308290    A:      COIN_SPEND( transaction_id, list(token1, ...) ) 
    309291 
     292* The atom for a COIN_SPEND is the entire list of tokens 
    310293 
    311294* Wallet Bob checks if the sum of their values matches the announced sum, if