-
Notifications
You must be signed in to change notification settings - Fork 0
/
alice_create_with_message_id_flow.py
48 lines (41 loc) · 1.69 KB
/
alice_create_with_message_id_flow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import asyncio
from alice import connect, accept_offer, create_proof, init
from demo_utils import download_message
from vcx.api.credential import Credential
from vcx.api.disclosed_proof import DisclosedProof
# logging.basicConfig(level=0)
async def main():
await init()
connection_to_faber = None
while True:
answer = input(
"Would you like to do? \n "
"0 - establish connection \n "
"1 - check for credential offer \n "
"2 - check for proof request \n "
"else finish \n") \
.lower().strip()
if answer == '0':
connection_to_faber = await connect()
elif answer == '1':
print("Check agency for a credential offer")
pw_did = await connection_to_faber.get_my_pw_did()
uid, offer, _ = await download_message(pw_did, 'credential-offer')
print(uid)
credential = await Credential.create_with_msgid('credential', connection_to_faber, uid)
await accept_offer(connection_to_faber, credential)
elif answer == '2':
print("Check agency for a proof request")
pw_did = await connection_to_faber.get_my_pw_did()
uid, request, _ = await download_message(pw_did, 'presentation-request')
print("#23 Create a Disclosed proof object from proof request")
proof = await DisclosedProof.create_with_msgid('proof', connection_to_faber, uid)
await create_proof(connection_to_faber, proof)
else:
pass
# break
print(answer)
print("Finished")
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())