本文整理汇总了Python中bigchaindb.Bigchain.generate_keys方法的典型用法代码示例。如果您正苦于以下问题:Python Bigchain.generate_keys方法的具体用法?Python Bigchain.generate_keys怎么用?Python Bigchain.generate_keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bigchaindb.Bigchain
的用法示例。
在下文中一共展示了Bigchain.generate_keys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from bigchaindb import Bigchain [as 别名]
# 或者: from bigchaindb.Bigchain import generate_keys [as 别名]
# "NET PRICE": "25" ,
# "PRICE": "50" ,
# "QUANTITY": "50000" ,
# "SIDE": "S" ,
# "TYPE": "EQ"
# },
# ...]
data = []
with open('data.csv', 'r') as fid:
reader = csv.DictReader(fid)
for row in reader:
data.append(row)
# generate distinct users from the CPTY1 column and assign keys
users = []
for user_name in set([d['CPTY1'] for d in data]):
sk, vk = b.generate_keys()
user = users.append(
{
'name': user_name,
'signing_key': sk,
'verifying_key': vk
}
)
# create assets on the blockchain with the payload and assign to the user
for asset in data:
user = [u for u in users if u['name'] == asset['CPTY1']][0]
tx = b.create_transaction(b.me, user['verifying_key'], None, 'CREATE', payload=asset)
tx_signed = b.sign_transaction(tx, b.me_private)
b.write_transaction(tx_signed)
示例2: Bigchain
# 需要导入模块: from bigchaindb import Bigchain [as 别名]
# 或者: from bigchaindb.Bigchain import generate_keys [as 别名]
from bigchaindb import Bigchain
import writeout
b = Bigchain()
# create 7 test users
testuser1_priv, testuser1_pub = b.generate_keys()
writeout.exportData((testuser1_priv, testuser1_pub), "user1")
testuser2_priv, testuser2_pub = b.generate_keys()
writeout.exportData((testuser2_priv, testuser2_pub), "user2")
testuser3_priv, testuser3_pub = b.generate_keys()
writeout.exportData((testuser3_priv, testuser3_pub), "user3")
testuser4_priv, testuser4_pub = b.generate_keys()
writeout.exportData((testuser4_priv, testuser4_pub), "user4")
testuser5_priv, testuser5_pub = b.generate_keys()
writeout.exportData((testuser5_priv, testuser5_pub), "user5")
testuser6_priv, testuser6_pub = b.generate_keys()
writeout.exportData((testuser6_priv, testuser6_pub), "user6")
testuser7_priv, testuser7_pub = b.generate_keys()
writeout.exportData((testuser7_priv, testuser7_pub), "govt")