@@ -144,11 +144,11 @@ to:
144144 In [0]: from ipld import multihash, marshal
145145
146146 In [0]: bicycle = [{
147- ...: 'data':
147+ ...: 'data':
148148 ...: multihash( marshal( { 'bicycle': {
149149 ...: 'serial_number': 'abcd1234',
150150 ...: 'manufacturer': 'bkfab',
151- ...: },
151+ ...: },
152152 ...: } )),
153153 ...: }]
154154
@@ -497,7 +497,7 @@ The Fulfilled Transaction
497497
498498 In [0]: import json
499499
500- In [0]: from sha3 import sha3_256
500+ In [0]: from hashlib import sha3_256
501501
502502 In [0]: # fulfill prepared transaction
503503
@@ -537,7 +537,7 @@ The transaction's id is essentially a SHA3-256 hash of the entire transaction
537537
538538 In [0]: import json
539539
540- In [0]: from sha3 import sha3_256
540+ In [0]: from hashlib import sha3_256
541541
542542 In [0]: json_str_tx = json.dumps(
543543 ...: handcrafted_creation_tx,
@@ -582,7 +582,7 @@ Handcrafting a ``CREATE`` transaction can be done as follows:
582582 import json
583583
584584 import base58
585- import sha3
585+ import hashlib
586586 from planetmint_cryptoconditions import Ed25519Sha256
587587
588588 from planetmint_driver.crypto import generate_keypair
@@ -644,7 +644,7 @@ Handcrafting a ``CREATE`` transaction can be done as follows:
644644 ensure_ascii = False ,
645645 )
646646
647- message = sha3 .sha3_256(message.encode())
647+ message = hashlib .sha3_256(message.encode())
648648
649649 ed25519.sign(message.digest(), base58.b58decode(alice.private_key))
650650
@@ -659,7 +659,7 @@ Handcrafting a ``CREATE`` transaction can be done as follows:
659659 ensure_ascii = False ,
660660 )
661661
662- creation_txid = sha3 .sha3_256(json_str_tx.encode()).hexdigest()
662+ creation_txid = hashlib .sha3_256(json_str_tx.encode()).hexdigest()
663663
664664 handcrafted_creation_tx[' id' ] = creation_txid
665665
@@ -973,7 +973,7 @@ The Fulfilled Transaction
973973
974974 In [0]: from planetmint_driver.offchain import fulfill_transaction
975975
976- In [0]: from sha3 import sha3_256
976+ In [0]: from hashlib import sha3_256
977977
978978 In [0]: # fulfill prepared transaction
979979
10131013
10141014 In [0]: import json
10151015
1016- In [0]: from sha3 import sha3_256
1016+ In [0]: from hashlib import sha3_256
10171017
10181018 In [0]: json_str_tx = json.dumps(
10191019 ...: handcrafted_transfer_tx,
@@ -1050,7 +1050,7 @@ In a nutshell
10501050 import json
10511051
10521052 import base58
1053- import sha3
1053+ import hashlib
10541054 from planetmint_cryptoconditions import Ed25519Sha256
10551055
10561056 from planetmint_driver.crypto import generate_keypair
@@ -1104,7 +1104,7 @@ In a nutshell
11041104 ensure_ascii = False ,
11051105 )
11061106
1107- message = sha3 .sha3_256(message.encode())
1107+ message = hashlib .sha3_256(message.encode())
11081108
11091109 message.update(' {}{} ' .format(
11101110 handcrafted_transfer_tx[' inputs' ][0 ][' fulfills' ][' transaction_id' ],
@@ -1124,7 +1124,7 @@ In a nutshell
11241124 ensure_ascii = False ,
11251125 )
11261126
1127- transfer_txid = sha3 .sha3_256(json_str_tx.encode()).hexdigest()
1127+ transfer_txid = hashlib .sha3_256(json_str_tx.encode()).hexdigest()
11281128
11291129 handcrafted_transfer_tx[' id' ] = transfer_txid
11301130
@@ -1164,7 +1164,7 @@ Handcrafting the ``CREATE`` transaction for our :ref:`bicycle sharing example
11641164 import json
11651165
11661166 import base58
1167- import sha3
1167+ import hashlib
11681168 from planetmint_cryptoconditions import Ed25519Sha256
11691169
11701170 from planetmint_driver.crypto import generate_keypair
@@ -1230,7 +1230,7 @@ Handcrafting the ``CREATE`` transaction for our :ref:`bicycle sharing example
12301230 ensure_ascii = False ,
12311231 )
12321232
1233- message = sha3 .sha3_256(message.encode())
1233+ message = hashlib .sha3_256(message.encode())
12341234
12351235 # CRYPTO-CONDITIONS: sign the serialized transaction-without-id
12361236 ed25519.sign(message.digest(), base58.b58decode(bob.private_key))
@@ -1250,7 +1250,7 @@ Handcrafting the ``CREATE`` transaction for our :ref:`bicycle sharing example
12501250 )
12511251
12521252 # SHA3: hash the serialized id-less transaction to generate the id
1253- shared_creation_txid = sha3 .sha3_256(json_str_tx.encode()).hexdigest()
1253+ shared_creation_txid = hashlib .sha3_256(json_str_tx.encode()).hexdigest()
12541254
12551255 # add the id
12561256 token_creation_tx[' id' ] = shared_creation_txid
@@ -1358,7 +1358,7 @@ to Bob:
13581358 ensure_ascii = False ,
13591359 )
13601360
1361- message = sha3 .sha3_256(message.encode())
1361+ message = hashlib .sha3_256(message.encode())
13621362
13631363 message.update(' {}{} ' .format(
13641364 token_transfer_tx[' inputs' ][0 ][' fulfills' ][' transaction_id' ],
@@ -1383,7 +1383,7 @@ to Bob:
13831383 )
13841384
13851385 # SHA3: hash the serialized id-less transaction to generate the id
1386- shared_transfer_txid = sha3 .sha3_256(json_str_tx.encode()).hexdigest()
1386+ shared_transfer_txid = hashlib .sha3_256(json_str_tx.encode()).hexdigest()
13871387
13881388 # add the id
13891389 token_transfer_tx[' id' ] = shared_transfer_txid
@@ -1526,7 +1526,7 @@ sha3, and cryptoconditions):
15261526
15271527 In [0]: import base58
15281528
1529- In [0]: from sha3 import sha3_256
1529+ In [0]: from hashlib import sha3_256
15301530
15311531 In [0]: from planetmint_cryptoconditions import Ed25519Sha256, ThresholdSha256
15321532
@@ -1788,7 +1788,7 @@ Handcrafting the ``'CREATE'`` transaction
17881788 import json
17891789
17901790 import base58
1791- from sha3 import sha3_256
1791+ from hashlib import sha3_256
17921792 from planetmint_cryptoconditions import Ed25519Sha256, ThresholdSha256
17931793
17941794 from planetmint_driver.crypto import generate_keypair
@@ -2043,7 +2043,7 @@ Handcrafting the ``'CREATE'`` transaction
20432043 import json
20442044
20452045 import base58
2046- import sha3
2046+ import hashlib
20472047 from planetmint_cryptoconditions import Ed25519Sha256, ThresholdSha256
20482048
20492049 from planetmint_driver.crypto import generate_keypair
@@ -2128,7 +2128,7 @@ Handcrafting the ``'CREATE'`` transaction
21282128 ensure_ascii = False ,
21292129 )
21302130
2131- message = sha3 .sha3_256(message.encode())
2131+ message = hashlib .sha3_256(message.encode())
21322132
21332133 # CRYPTO-CONDITIONS: sign the serialized transaction-without-id
21342134 alice_ed25519.sign(message.digest(), base58.b58decode(alice.private_key))
@@ -2150,7 +2150,7 @@ Handcrafting the ``'CREATE'`` transaction
21502150 )
21512151
21522152 # SHA3: hash the serialized id-less transaction to generate the id
2153- car_creation_txid = sha3 .sha3_256(json_str_tx.encode()).hexdigest()
2153+ car_creation_txid = hashlib .sha3_256(json_str_tx.encode()).hexdigest()
21542154
21552155 # add the id
21562156 handcrafted_car_creation_tx[' id' ] = car_creation_txid
@@ -2230,7 +2230,7 @@ Handcrafting the ``'TRANSFER'`` transaction
22302230 ensure_ascii = False ,
22312231 )
22322232
2233- message = sha3 .sha3_256(message.encode())
2233+ message = hashlib .sha3_256(message.encode())
22342234
22352235 message.update(' {}{} ' .format(
22362236 handcrafted_car_transfer_tx[' inputs' ][0 ][' fulfills' ][' transaction_id' ],
@@ -2258,7 +2258,7 @@ Handcrafting the ``'TRANSFER'`` transaction
22582258 ensure_ascii = False ,
22592259 )
22602260
2261- car_transfer_txid = sha3 .sha3_256(json_str_tx.encode()).hexdigest()
2261+ car_transfer_txid = hashlib .sha3_256(json_str_tx.encode()).hexdigest()
22622262
22632263 handcrafted_car_transfer_tx[' id' ] = car_transfer_txid
22642264
@@ -2276,7 +2276,6 @@ will return after the transaction is validated, while ``async`` will return righ
22762276 returned_car_transfer_tx = bdb.transactions.send_async(handcrafted_car_transfer_tx)
22772277
22782278
2279- .. _sha3 : https://github.com/tiran/pysha3
22802279 .. _cryptoconditions : https://github.com/planetmint/cryptoconditions
22812280.. _cryptoconditions internet draft : https://tools.ietf.org/html/draft-thomas-crypto-conditions-02
22822281.. _The Transaction Model : https://docs.planetmint.com/projects/server/en/latest/data-models/transaction-model.html
0 commit comments