diff --git a/examples/create_and_publish_identity.py b/examples/send_identity.py similarity index 90% rename from examples/create_and_publish_identity.py rename to examples/send_identity.py index 7c388993509a38f3c0c879d97054765345efe436..c024a50f12bd8c8a576bb84144589f24a7536293 100644 --- a/examples/create_and_publish_identity.py +++ b/examples/send_identity.py @@ -18,15 +18,16 @@ BMAS_ENDPOINT = "BMAS g1-test.duniter.org 443" def get_identity_document( - current_block: dict, uid: str, salt: str, password: str + current_block: dict, + uid: str, + key: SigningKey, ) -> Identity: """ Get an Identity document :param current_block: Current block data :param uid: Unique IDentifier - :param salt: Passphrase of the account - :param password: Password of the account + :param key: cryptographic key to sign documents :rtype: Identity """ @@ -34,9 +35,6 @@ def get_identity_document( # get current block BlockStamp timestamp = BlockUID(current_block["number"], current_block["hash"]) - # create keys from credentials - key = SigningKey.from_credentials(salt, password) - # create identity document identity = Identity( version=10, @@ -76,10 +74,13 @@ async def main(): # prompt hidden user entry password = getpass.getpass("Enter your password: ") + # create keys from credentials + key = SigningKey.from_credentials(salt, password) + # create our signed identity document - identity = get_identity_document(current_block, uid, salt, password) + identity = get_identity_document(current_block, uid, key) - # send the identity document to the node + # send the identity signed raw document to the node response = await client(bma.wot.add, identity.signed_raw()) if response.status == 200: print(await response.text())