Changeset 168
- Timestamp:
- 03/04/08 20:13:12 (4 years ago)
- Location:
- trunk
- Files:
-
- 6 modified
-
pyopencoin/oc/containers.py (modified) (25 diffs)
-
pyopencoin/oc/entities.py (modified) (2 diffs)
-
pyopencoin/oc/protocols.py (modified) (1 diff)
-
pyopencoin/oc/tests.py (modified) (6 diffs)
-
standards/protocol-containers.txt (modified) (2 diffs)
-
standards/protocol.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pyopencoin/oc/containers.py
r163 r168 1 import base64,json 1 import base64 2 import json 3 import types 2 4 3 5 class Container(object): … … 258 260 ... hashing=crypto.SHA256HashingAlgorithm) 259 261 260 >>> cdd = CDD(standard_ version= 'http://opencoin.org/OpenCoinProtocol/1.0',262 >>> cdd = CDD(standard_identifier = 'http://opencoin.org/OpenCoinProtocol/1.0', 261 263 ... currency_identifier = 'http://opencent.net/OpenCent', 262 264 ... short_currency_identifier = 'OC', 263 265 ... 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'], 265 267 ... issuer_cipher_suite = ics, 268 ... options = [], 266 269 ... issuer_public_master_key = crypto.RSAKeyPair(e=17L,n=3233L)) 267 270 268 271 >>> j = cdd.content_part() 269 272 >>> 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=="]]' 271 274 272 275 >>> cdd2 = CDD().fromJson(j) … … 278 281 279 282 >>> 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=="]]]]' 281 284 282 285 … … 304 307 from crypto import encodeCryptoContainer, decodeCryptoContainer, decodeRSAKeyPair 305 308 306 fields = ['standard_ version',309 fields = ['standard_identifier', 307 310 'currency_identifier', 308 311 'short_currency_identifier', … … 310 313 'denominations', 311 314 'issuer_cipher_suite', 315 'options', 312 316 'issuer_public_master_key'] 313 317 … … 348 352 >>> mintKey = MintKey(key_identifier=key_id, 349 353 ... currency_identifier='http://opencent.net/OpenCent', 350 ... denomination= 1,354 ... denomination="1", 351 355 ... not_before=timegm((2008,1,1,0,0,0)), 352 356 ... 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)), 354 358 ... public_key=public) 355 359 … … 369 373 370 374 >>> 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","..."]]]]' 372 376 373 377 Well, we are going to test that verify_with_CDD works now. We've already … … 444 448 'not_before', 445 449 'key_not_after', 446 ' coin_not_after',450 'token_not_after', 447 451 'public_key'] 448 452 … … 453 457 'not_before':{'encode':encodeTime,'decode':decodeTime}, 454 458 'key_not_after':{'encode':encodeTime,'decode':decodeTime}, 455 ' coin_not_after':{'encode':encodeTime,'decode':decodeTime}}459 'token_not_after':{'encode':encodeTime,'decode':decodeTime}} 456 460 457 461 def __init__(self, **kwargs): 458 462 ContainerWithSignature.__init__(self, **kwargs) 459 463 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') 460 466 461 467 def verify_with_CDD(self, currency_description_document): … … 491 497 492 498 can_mint = time >= self.not_before and time <= self.key_not_after 493 can_redeem = time >= self.not_before and time <= self. coin_not_after499 can_redeem = time >= self.not_before and time <= self.token_not_after 494 500 495 501 return (can_mint, can_redeem) … … 500 506 501 507 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', 503 509 ... currency_identifier = 'http://opencent.net/OpenCent', 504 510 ... denomination = '1', … … 521 527 522 528 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', 524 530 ... currency_identifier = 'http://opencent.net/OpenCent', 525 531 ... denomination = '1', … … 529 535 >>> j = b.toJson() 530 536 >>> 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=="]]' 532 538 533 539 >>> b == CurrencyBase().fromJson(j) … … 587 593 return False 588 594 589 if self.standard_identifier != cdd.standard_ version:595 if self.standard_identifier != cdd.standard_identifier: 590 596 return False 591 597 … … 621 627 >>> blank = CurrencyBlank(standard_identifier='http://OpenCoin/1.0/', 622 628 ... currency_identifier='http://OpenCent', 623 ... denomination= 1,629 ... denomination='1', 624 630 ... key_identifier='cent') 625 631 … … 632 638 633 639 >>> 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"]]' 635 641 636 642 >>> blank.serial = None … … 665 671 >>> mintKey1 = MintKey(key_identifier=public1.key_id(hash_alg), 666 672 ... currency_identifier='http://opencent.net/OpenCent', 667 ... denomination= 1,673 ... denomination='1', 668 674 ... not_before=timegm((2008,1,1,0,0,0)), 669 675 ... 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)), 671 677 ... public_key=public1) 672 678 >>> mintKey1 = addSignature(mintKey1, hash_alg, sign_alg, CDD_private, CDD.signature.keyprint) … … 679 685 >>> mintKey5 = MintKey(key_identifier=public5.key_id(hash_alg), 680 686 ... currency_identifier='http://opencent.net/OpenCent', 681 ... denomination= 5,687 ... denomination='5', 682 688 ... not_before=timegm((2008,1,1,0,0,0)), 683 689 ... 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)), 685 691 ... public_key=public5) 686 692 >>> mintKey5 = addSignature(mintKey5, hash_alg, sign_alg, CDD_private, CDD.signature.keyprint) … … 690 696 691 697 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, 693 699 ... currency_identifier=CDD.currency_identifier, 694 ... denomination= 1,700 ... denomination='1', 695 701 ... key_identifier=mintKey1.key_identifier, 696 702 ... serial='abcdefghijklmnopqrstuvwxyz') 697 703 698 704 >>> 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="]]' 700 706 701 707 >>> blank.content_part() == blank.toJson() … … 704 710 >>> blind_value = blank.blind_blank(CDD, mintKey1, blind_factor='blind factor') 705 711 >>> base64.b64encode(blind_value) 706 ' Ni+1wlpQxCL+zDhK4K2KKfq1MgeX5+t2VXIuP2qhqe4nw3OZGphOW30/jZfmlBuLUFomdIc7g4iRwRF34D7gCQ=='712 'FtDSI1eT2FsXK+R/zJVk9mGTRan4KQsogVmSMFts3kVrdV4y3mkIuYEaZ3B0ZP491rqR0QtIlVEAYf8sQNgbhQ==' 707 713 708 714 Do some magic as the mint 709 715 >>> blind_sig = sign_alg(private1).sign(blind_value) 710 716 >>> base64.b64encode(blind_sig) 711 ' BaH8tyK3D6qg3UaxIZ7zVRWee7vMsBMbkO1ZboeMEWr+rjE0P1JvqyAUp6G/Q5XB6DJ4+Li2xM9d2DJiB+VR5Q=='717 'ZEDz4RHVwUByR+QXwgZcNeIyg9T3hAgxl0taabVKjbv0DbxTmHYK9fgqlCtBSAvmNntk03DMKrIPpaLuAV3UcA==' 712 718 713 719 >>> clear_sig = blank.unblind_signature(blind_sig) 714 720 >>> base64.b64encode(clear_sig) 715 ' cK8f0bus8nP73pbNP/8Hm+7WojucymlijU1ERmR2Z0WMs44PVpqxnj81ZuBy8ojEA8xepFaEQScSENcoHz26dQ=='721 'HIck+fim0TkjVupU1AeKpuSGN1CxLnDmT2jpBHMZSgdpYhKE90XoAsQVznljEn4NTXvRs5cXslWUNvcUeAuv2A==' 716 722 717 723 Check for the same signature … … 724 730 725 731 >>> 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=="]]' 727 733 728 734 >>> coin2 = blank.newCoin(clear_sig, CDD, mintKey1) … … 749 755 750 756 Test other blank functions. 751 >>> blank2 = CurrencyBlank(standard_identifier=CDD.standard_ version,757 >>> blank2 = CurrencyBlank(standard_identifier=CDD.standard_identifier, 752 758 ... currency_identifier=CDD.currency_identifier, 753 ... denomination= 1,759 ... denomination='1', 754 760 ... key_identifier=mintKey1.key_identifier, 755 761 ... serial='abcdefghijklmnopqrstuvwxyz') 756 762 >>> blank2.setBlind(blind_alg, mintKey1.public_key, 'blind factor') 757 763 >>> 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, 761 767 ... currency_identifier=CDD.currency_identifier, 762 ... denomination= 1,768 ... denomination='1', 763 769 ... key_identifier=mintKey1.key_identifier, 764 770 ... serial='abcdefghijklmnopqrstuvwxyz', … … 766 772 >>> blank3.setBlind(blind_alg, mintKey1.public_key) 767 773 >>> base64.b64encode(blank3.unblind_signature(blind_sig)) 768 ' cK8f0bus8nP73pbNP/8Hm+7WojucymlijU1ERmR2Z0WMs44PVpqxnj81ZuBy8ojEA8xepFaEQScSENcoHz26dQ=='774 'HIck+fim0TkjVupU1AeKpuSGN1CxLnDmT2jpBHMZSgdpYhKE90XoAsQVznljEn4NTXvRs5cXslWUNvcUeAuv2A==' 769 775 770 776 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, 772 778 ... currency_identifier=CDD.currency_identifier, 773 ... denomination= 1,779 ... denomination='1', 774 780 ... key_identifier=mintKey1.key_identifier) 775 781 >>> blank4.generateSerial() … … 860 866 >>> mintKey = mintKeys[0] 861 867 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, 865 871 ... currency_identifier=CDD.currency_identifier, 866 ... denomination= 1,872 ... denomination='1', 867 873 ... key_identifier=mintKey.key_identifier, 868 874 ... serial='abcdefghijklmnopqrstuvwxyz', … … 870 876 871 877 >>> 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=="]]' 873 879 874 880 >>> 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="]]' 876 882 877 883 >>> coin2 = CurrencyCoin().fromJson(coin.toJson()) -
trunk/pyopencoin/oc/entities.py
r167 r168 102 102 True 103 103 >>> test_coins[0].denomination 104 2104 '2' 105 105 >>> test_coins[3].denomination 106 5106 '5' 107 107 >>> test_coins[4].denomination 108 10108 '10' 109 109 >>> sum(test_coins) 110 110 21 … … 212 212 return [] 213 213 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): 215 217 raise Exception('denomination_list and self.coins differ!') 216 218 217 denominations_to_use = my_split( denomination_list, amount)219 denominations_to_use = my_split(int_denomination_list, amount) 218 220 219 221 if not denominations_to_use: 220 222 raise UnableToDoError('Not enough tokens') 223 224 denominations_to_use = [str(d) for d in denominations_to_use] 221 225 222 226 to_use = [] -
trunk/pyopencoin/oc/protocols.py
r163 r168 352 352 >>> ttr.state = ttr.start 353 353 >>> 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==']]]])> 355 355 356 356 Now, check to make sure the implemenation is good -
trunk/pyopencoin/oc/tests.py
r165 r168 8 8 9 9 >>> 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="]]]]' 11 11 12 12 Lets test without having any keys in the mint … … 103 103 public_key = private_key.newPublicKeyPair() 104 104 105 cdd = containers.CDD(standard_ version='http://opencoin.org/OpenCoinProtocol/1.0',105 cdd = containers.CDD(standard_identifier='http://opencoin.org/OpenCoinProtocol/1.0', 106 106 currency_identifier = 'http://opencent.net/OpenCent', 107 107 short_currency_identifier = 'OC', 108 108 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'], 110 110 issuer_cipher_suite = ics, 111 options = [], 111 112 issuer_public_master_key = public_key) 112 113 … … 205 206 206 207 >>> base64.b64encode(mintkey1.signature.signature) 207 ' l6viHZFCZSlYVRVXrawzb7MYPmgVbkuCbjot5giOiGWJ7PuiTUOFd5O/CTf5QRX6snrzQhLqImQ414Z2vNChcVBBu1zIslQ9Pxti1WW9EA0Z8akeQoWG11S4eqbwvbBHStO1uB6vGQAkR9g1zJvS+NG3vzF/vYnADtD5CQ4bpvg='208 'YaVpcSavYfEwKuoaR3PPsSMBD3c2bMSP4iHdHAUKqmOFrb5qgrNPhLwPNAeSZe6qoLB09bIFVFFW46Xv+FzZ3WghmlRmtKD+LFV9+2xu/jXAjwi+VqSFwjLjttbxSbeYWce6IiWKlklHBBZ2zwXY5CP2QqZ6Zt5i0HE6fEM8KRU=' 208 209 209 210 >>> base64.b64encode(mintkey2.signature.signature) 210 ' iVcVpYvER6702tkYvqqdiOuugMKqhHAwln1jDLTk1sGyZPr0y5b1V/qqgYpJUBayZM/hRtWlN4NxiRQbISjU1ZGAZTmARYfU+MigCXbATZXaS1GjZjx2/gIZnTFHF9T6N6elTKTmqQdV0ZExjWZmHDmco0alwOKK9n+ta5o7pvs='211 'Es5my5lRwFVYx49EVMJwZPgoXC00QBFCvS0H0MRC+rxCufY+s59ivai20+aTjq+cO5hslEIE4L3ne0bMpNliG2d4XP9fuLCggGbtzrCLEAt6GLS9xEzIsk0EbGAxLxceL28zJTJHQqZm1pRKHbH0Gv5pxZmMx3AmGB80uOCjdBU=' 211 212 212 213 >>> base64.b64encode(mintkey5.signature.signature) 213 ' IJmSiWPoNOt+kMZle3Z/4Fex17l4D8Hq1tr1l01MCGWHS1+6syOxIIJ2giSQmPQlZRrTwRrbUOEblGs9K0G+e4OlbzB5CywDo6z9FDWSSnXqlEEEt4tYzzsAjqvhjPq3/i182J5sucb70ea+vrIj7Kll5V9JYAxMocgd16dXwDc='214 'epNc+/Nq3lshowLTi4tue26m0ED62cue95vqvMSllDtV4cBZ23YCEDGD8aHmcJZ7bB12MCE/lAWO6aR4FQDfyc1U6LAbuOuuAERnZhaDc9ZKWvamn3uPvjV3722vje4P6Ic2sbJ+ch7NItrmdktnG4Vap88iIAPCnWl/zivZUWA=' 214 215 215 216 >>> base64.b64encode(mintkey10.signature.signature) 216 ' nx5Jthxo4QMPTmyEui/TVyKyDxjCnhhJLeAbgYyl5tkk+VNNzdkBd7Ry/wCv5ijs8lSUTkPaQt/d3AVHlMxSTF93/5y1/vl47hFpAyclXlMkqagGuGrFSsnQYYqEnhnCcaAl6i9rBGcrQh4YYFA3fIVkkVa/fL2aIYpPpoMvKcg='217 'EwgUD6dZVkIEw8ALyVAIkSQLqbfzdNEMD3cYIZZHZ3TuxoKtvT3RG9NnN+PhWKH956ehNmbyVVOLqmEABMIi+3CXLGhkO2YqVCW9619gAF5S/UaYRVE+ijWcAYbAWoBestRhirnBEEBvBcFRk1rQJx8IqEzBMyUk//UbvcneVog=' 217 218 """ 218 219 from containers import MintKey … … 230 231 not_before=timegm((2008,1,1,0,0,0)), 231 232 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)), 233 234 public_key=public) 234 235 addSignature(mintKey, hash_alg, sign_alg, CDD_private, CDD.signature.keyprint) … … 238 239 private0 = keys512[0] 239 240 public0 = private0.newPublicKeyPair() 240 mintKey0 = makeMintKey( 1, public0, private0)241 mintKey0 = makeMintKey('1', public0, private0) 241 242 242 243 private1 = keys512[1] 243 244 public1 = private1.newPublicKeyPair() 244 mintKey1 = makeMintKey( 2, public1, private1)245 mintKey1 = makeMintKey('2', public1, private1) 245 246 246 247 private2 = keys512[2] 247 248 public2 = private2.newPublicKeyPair() 248 mintKey2 = makeMintKey( 5, public2, private2)249 mintKey2 = makeMintKey('5', public2, private2) 249 250 250 251 private3 = keys512[3] 251 252 public3 = private3.newPublicKeyPair() 252 mintKey3 = makeMintKey( 10, public3, private3)253 mintKey3 = makeMintKey('10', public3, private3) 253 254 254 255 return (mintKey0, mintKey1, mintKey2, mintKey3) … … 290 291 291 292 def makeCoin(serial, private_key, mint_key): 292 coin = CurrencyCoin(standard_identifier=CDD.standard_ version,293 coin = CurrencyCoin(standard_identifier=CDD.standard_identifier, 293 294 currency_identifier=CDD.currency_identifier, 294 295 denomination=mint_key.denomination, -
trunk/standards/protocol-containers.txt
r123 r168 36 36 Currency Description Document (CCD) = 37 37 { 38 standard version= http://opencoin.org/OpenCoinProtocol/1.038 standard identifier = http://opencoin.org/OpenCoinProtocol/1.0 39 39 currency identifier = http://opencent.net/OpenCent 40 40 short currency identifier = OC 41 41 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 commas42 denominations = ['1', '2', '5', ...] #list of strings 43 43 issuer cipher suite = HASH-ALG, SIGN-ALG, BLINDING-ALG 44 options = list(options) | list() 44 45 issuer public master key = base64(pM) 45 46 … … 56 57 not_before = TIME(...) 57 58 key_not_after = TIME(...) 58 coin_not_after= TIME(...)59 token_not_after = TIME(...) 59 60 public key = base64(pP) 60 61 -
trunk/standards/protocol.txt
r144 r168 29 29 - "Introduction" 30 30 - replace "COIN_SPEND" with "TRANSFER_TOKEN" 31 - decide whether the protocol atoms are tokens or lists of tokens32 31 - throw out reduntant "TRANSFER_TOKEN" explanatoins 33 32 - add authentication and authorization, at least for "target" 34 when minti g33 when minting 35 34 - add mandatory trusted channel (Bluetooth, TLS) 36 35 … … 107 106 108 107 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? 127 109 128 110 * issuer fires up issuer service (=IS) at <opencoin://issuer.opencent.net:8002> … … 163 145 164 146 165 3.3.5 "TRANSFER_TOKEN": A generic wallet-issuer request147 t 3.3.5 "TRANSFER_TOKEN": A generic wallet-issuer request 166 148 167 149 The atom for this transaction is a list of tokens - if one of the tokens /blanks … … 199 181 If the request is accepted with no delay, IS answers 200 182 201 TRANSFER_TOKEN_ACCEPT( transaction_id, message, list_of_si nged_blinds)183 TRANSFER_TOKEN_ACCEPT( transaction_id, message, list_of_signed_blinds) 202 184 203 185 (with list_of_singed_blinds empty if no minting was required) … … 308 290 A: COIN_SPEND( transaction_id, list(token1, ...) ) 309 291 292 * The atom for a COIN_SPEND is the entire list of tokens 310 293 311 294 * Wallet Bob checks if the sum of their values matches the announced sum, if
