async def main(): payment_plugin = cdll.LoadLibrary('libnullpay' + file_ext()) payment_plugin.nullpay_init() print("#7 Provision an agent and wallet, get back configuration details") config = await vcx_agent_provision(json.dumps(provisionConfig)) config = json.loads(config) # Set some additional configuration options specific to alice config['institution_name'] = 'alice' config['institution_logo_url'] = 'http://robohash.org/456' config['genesis_path'] = 'docker.txn' config = json.dumps(config) print('Alice config:\n ' + config) print("#8 Initialize libvcx with new configuration") await vcx_init_with_config(config) print("#9 Input faber.py invitation details") details = input('invite details: ') print( "#10 Convert to valid json and string and create a connection to faber" ) jdetails = json.loads(details) connection_to_faber = await Connection.create_with_details( 'faber', json.dumps(jdetails)) await connection_to_faber.connect('{"use_public_did": true}') connection_state = await connection_to_faber.update_state() while connection_state != State.Accepted: sleep(2) await connection_to_faber.update_state() connection_state = await connection_to_faber.get_state() print("Connection is established") while True: answer = input( "Would you like to do? \n " "1 - check for credential offer \n " "2 - check for proof request \n " "3 - pass vc_auth_oidc-challenge \n " "else finish \n") \ .lower().strip() if answer == '1': print("Check agency for a credential offer") offers = await Credential.get_offers(connection_to_faber) await accept_offer(connection_to_faber, offers) elif answer == '2': print("Check agency for a proof request") requests = await DisclosedProof.get_requests(connection_to_faber) await create_proof(connection_to_faber, requests[0]) elif answer == '3': request = await handle_challenge() await create_proof(None, request) else: break print("Finished")
async def main(): payment_plugin = cdll.LoadLibrary('libnullpay' + file_ext()) payment_plugin.nullpay_init() print("#1 Provision an agent and wallet, get back configuration details") config = await vcx_agent_provision(json.dumps(provisionConfig)) config = json.loads(config) # Set some additional configuration options specific to faber config['institution_name'] = 'Faber' config['institution_logo_url'] = 'http://robohash.org/234' config['genesis_path'] = 'docker.txn' print("#2 Initialize libvcx with new configuration") await vcx_init_with_config(json.dumps(config)) print("#3 Create a new schema on the ledger") version = format("%d.%d.%d" % (random.randint(1, 101), random.randint(1, 101), random.randint(1, 101))) schema = await Schema.create('schema_uuid', 'degree schema', version, ['email', 'first_name', 'last_name'], 0) schema_id = await schema.get_schema_id() print("#4 Create a new credential definition on the ledger") cred_def = await CredentialDef.create('credef_uuid', 'degree', schema_id, 0) cred_def_handle = cred_def.handle print("#5 Create a connection to alice and print out the invite details") connection_to_alice = await Connection.create('alice') await connection_to_alice.connect('{"use_public_did": true}') await connection_to_alice.update_state() details = await connection_to_alice.invite_details(False) print("**invite details**") print(json.dumps(details)) print("******************") print("#6 Poll agency and wait for alice to accept the invitation (start alice.py now)") connection_state = await connection_to_alice.get_state() while connection_state != State.Accepted: sleep(2) await connection_to_alice.update_state() connection_state = await connection_to_alice.get_state() print("Connection is established") while True: answer = input( "Would you like to do? \n " "1 - issue credential \n " "2 - ask for proof request \n " "else finish \n") \ .lower().strip() if answer == '1': await issue_credential(connection_to_alice, cred_def_handle) elif answer == '2': await ask_for_proof(connection_to_alice, config['institution_did']) else: break print("Finished")
async def main(): payment_plugin = cdll.LoadLibrary('libnullpay' + file_ext()) payment_plugin.nullpay_init() print("#1 Provision an agent and wallet, get back configuration details") config = await vcx_agent_provision(json.dumps(provisionConfig)) config = json.loads(config) # Set some additional configuration options specific to faber config['institution_name'] = 'Faber' config['institution_logo_url'] = 'http://robohash.org/234' config['genesis_path'] = 'docker.txn' config['use_latest_protocols'] = 'True' print("#2 Initialize libvcx with new configuration") await vcx_init_with_config(json.dumps(config)) print("#5 Create a connection to alice and print out the invite details") connection_to_alice = await Connection.create('alice') await connection_to_alice.connect('{"use_public_did": true}') await connection_to_alice.update_state() details = await connection_to_alice.invite_details(False) print("**invite details**") print(json.dumps(details)) print("******************") print( "#6 Poll agency and wait for alice to accept the invitation (start alice.py now)" ) connection_state = await connection_to_alice.get_state() while connection_state != State.Accepted: sleep(2) await connection_to_alice.update_state() connection_state = await connection_to_alice.get_state() print("Connection is established") while True: answer = input( "Would you like to do? \n " "1 - ask for proof request \n " "else finish \n") \ .lower().strip() if answer == '1': await ask_for_proof(connection_to_alice) else: break print("Finished")
async def main(): payment_plugin = cdll.LoadLibrary('libnullpay' + file_ext()) payment_plugin.nullpay_init() print("Provision an agent and wallet, get back configuration details") config = await vcx_agent_provision(json.dumps(provisionConfig)) config = json.loads(config) # Set some additional configuration options specific to alice config['institution_name'] = 'alice' config['institution_logo_url'] = 'http://robohash.org/456' config['genesis_path'] = 'docker.txn' config['payment_method'] = 'null' config = json.dumps(config) print('Alice config:\n ' + config) print("Initialize libvcx with new configuration") await vcx_init_with_config(config) print("Initialized alternate wallet path") connection_to_faber = None
async def main(): payment_plugin = cdll.LoadLibrary('libnullpay' + file_ext()) payment_plugin.nullpay_init() print("#7 Provision an agent and wallet, get back configuration details") config = await vcx_agent_provision(json.dumps(provisionConfig)) config = json.loads(config) # Set some additional configuration options specific to alice config['institution_name'] = 'alice' config['institution_logo_url'] = 'http://robohash.org/456' config['genesis_path'] = 'docker.txn' print("#8 Initialize libvcx with new configuration") await vcx_init_with_config(json.dumps(config)) print("#9 Input faber.py invitation details") details = input('invite details: ') print( "#10 Convert to valid json and string and create a connection to faber" ) jdetails = json.loads(details) connection_to_faber = await Connection.create_with_details( 'faber', json.dumps(jdetails)) await connection_to_faber.connect('{"use_public_did": true}') await connection_to_faber.update_state() print("#11 Wait for faber.py to issue a credential offer") sleep(10) offers = await Credential.get_offers(connection_to_faber) # Create a credential object from the credential offer credential = await Credential.create('credential', offers[0]) print("#15 After receiving credential offer, send credential request") await credential.send_request(connection_to_faber, 0) print("#16 Poll agency and accept credential offer from faber") credential_state = await credential.get_state() while credential_state != State.Accepted: sleep(2) await credential.update_state() credential_state = await credential.get_state() print("#22 Poll agency for a proof request") requests = await DisclosedProof.get_requests(connection_to_faber) print("#23 Create a Disclosed proof object from proof request") proof = await DisclosedProof.create('proof', requests[0]) print( "#24 Query for credentials in the wallet that satisfy the proof request" ) credentials = await proof.get_creds() # Use the first available credentials to satisfy the proof request for attr in credentials['attrs']: credentials['attrs'][attr] = { 'credential': credentials['attrs'][attr][0] } print("#25 Generate the proof") await proof.generate_proof(credentials, {}) print("#26 Send the proof to faber") await proof.send_proof(connection_to_faber)
async def main(): payment_plugin = cdll.LoadLibrary('libnullpay' + file_ext()) payment_plugin.nullpay_init() print("#7 Provision an agent and wallet, get back configuration details") config = await vcx_agent_provision(json.dumps(provisionConfig)) config = json.loads(config) # Set some additional configuration options specific to alice config['institution_name'] = 'alice' config['institution_logo_url'] = 'http://robohash.org/456' config['genesis_path'] = 'docker.txn' print("#8 Initialize libvcx with new configuration") await vcx_init_with_config(json.dumps(config)) print("#9 Input faber.py invitation details") details = input('invite details: ') print("#10 Convert to valid json and string and create a connection to faber") jdetails = json.loads(details) connection_to_faber = await Connection.create_with_details('faber', json.dumps(jdetails)) await connection_to_faber.connect('{"use_public_did": true}') await connection_to_faber.update_state() print("#11 Wait for faber.py to issue a credential offer") sleep(10) offers = await Credential.get_offers(connection_to_faber) # Create a credential object from the credential offer credential = await Credential.create('credential', offers[0]) print("#15 After receiving credential offer, send credential request") await credential.send_request(connection_to_faber, 0) print("#16 Poll agency and accept credential offer from faber") credential_state = await credential.get_state() while credential_state != State.Accepted: sleep(2) await credential.update_state() credential_state = await credential.get_state() print("#22 Poll agency for a proof request") requests = await DisclosedProof.get_requests(connection_to_faber) print("#23 Create a Disclosed proof object from proof request") proof = await DisclosedProof.create('proof', requests[0]) print("#24 Query for credentials in the wallet that satisfy the proof request") credentials = await proof.get_creds() # Use the first available credentials to satisfy the proof request for attr in credentials['attrs']: credentials['attrs'][attr] = { 'credential': credentials['attrs'][attr][0] } print("#25 Generate the proof") await proof.generate_proof(credentials, {}) print("#26 Send the proof to faber") await proof.send_proof(connection_to_faber)
async def main(): payment_plugin = cdll.LoadLibrary('libnullpay' + file_ext()) payment_plugin.nullpay_init() print("#1 Provision an agent and wallet, get back configuration details") config = await vcx_agent_provision(json.dumps(provisionConfig)) config = json.loads(config) # Set some additional configuration options specific to faber config['institution_name'] = 'Faber' config['institution_logo_url'] = 'http://robohash.org/234' config['genesis_path'] = 'genesis.txn' print("#2 Initialize libvcx with new configuration") await vcx_init_with_config(json.dumps(config)) print("#3 Create a new schema on the ledger") version = format("%d.%d.%d" % (random.randint(1, 101), random.randint(1, 101), random.randint(1, 101))) schema = await Schema.create('schema_uuid', 'degree schema', version, ['name', 'date', 'degree'], 0) schema_id = await schema.get_schema_id() print("#4 Create a new credential definition on the ledger") cred_def = await CredentialDef.create('credef_uuid', 'degree', schema_id, 0) cred_def_handle = cred_def.handle cred_def_id = await cred_def.get_cred_def_id() print("#5 Create a connection to alice and print out the invite details") connection_to_alice = await Connection.create('alice') await connection_to_alice.connect('{"use_public_did": true}') await connection_to_alice.update_state() details = await connection_to_alice.invite_details(False) print("**invite details**") print(json.dumps(details)) print("******************") print("#6 Poll agency and wait for alice to accept the invitation (start alice.py now)") connection_state = await connection_to_alice.get_state() while connection_state != State.Accepted: sleep(2) await connection_to_alice.update_state() connection_state = await connection_to_alice.get_state() schema_attrs = { 'name': 'alice', 'date': '05-2018', 'degree': 'maths', } print("#12 Create an IssuerCredential object using the schema and credential definition") credential = await IssuerCredential.create('alice_degree', schema_attrs, cred_def_handle, 'cred', '0') print("#13 Issue credential offer to alice") await credential.send_offer(connection_to_alice) await credential.update_state() print("#14 Poll agency and wait for alice to send a credential request") credential_state = await credential.get_state() while credential_state != State.RequestReceived: sleep(2) await credential.update_state() credential_state = await credential.get_state() print("#17 Issue credential to alice") await credential.send_credential(connection_to_alice) print("#18 Wait for alice to accept credential") await credential.update_state() credential_state = await credential.get_state() while credential_state != State.Accepted: sleep(2) await credential.update_state() credential_state = await credential.get_state() proof_attrs = [ {'name': 'name', 'restrictions': [{'issuer_did': config['institution_did']}]}, {'name': 'date', 'restrictions': [{'issuer_did': config['institution_did']}]}, {'name': 'degree', 'restrictions': [{'issuer_did': config['institution_did']}]} ] print("#19 Create a Proof object") proof = await Proof.create('proof_uuid', 'proof_from_alice', proof_attrs, {}) print("#20 Request proof of degree from alice") await proof.request_proof(connection_to_alice) print("#21 Poll agency and wait for alice to provide proof") proof_state = await proof.get_state() while proof_state != State.Accepted: sleep(2) await proof.update_state() proof_state = await proof.get_state() print("#27 Process the proof provided by alice") await proof.get_proof(connection_to_alice) print("#28 Check if proof is valid") if proof.proof_state == ProofState.Verified: print("proof is verified!!") else: print("could not verify proof :(")
async def main(): payment_plugin = cdll.LoadLibrary('libnullpay' + file_ext()) payment_plugin.nullpay_init() print("#1 Provision an agent and wallet, get back configuration details") config = await vcx_agent_provision(json.dumps(provisionConfig)) config = json.loads(config) # Set some additional configuration options specific to faber config['institution_name'] = 'Faber' config['institution_logo_url'] = 'http://robohash.org/234' config['genesis_path'] = 'docker.txn' config['payment_method'] = 'null' config['protocol_type'] = '3.0' print("#2 Initialize libvcx with new configuration") await vcx_init_with_config(json.dumps(config)) if TAA_ACCEPT: # To support ledger which transaction author agreement accept needed print("#2.1 Accept transaction author agreement") txn_author_agreement = await vcx_get_ledger_author_agreement() txn_author_agreement_json = json.loads(txn_author_agreement) first_acc_mech_type = list(txn_author_agreement_json['aml'].keys())[0] vcx_set_active_txn_author_agreement_meta( text=txn_author_agreement_json['text'], version=txn_author_agreement_json['version'], hash=None, acc_mech_type=first_acc_mech_type, time_of_acceptance=int(time.time())) print("#3 Create a new schema on the ledger") version = format("%d.%d.%d" % (random.randint( 1, 101), random.randint(1, 101), random.randint(1, 101))) schema = await Schema.create('schema_uuid', 'degree schema', version, ['email', 'first_name', 'last_name'], 0) schema_id = await schema.get_schema_id() print("#4 Create a new credential definition on the ledger") cred_def = await CredentialDef.create('credef_uuid', 'degree', schema_id, 0) cred_def_handle = cred_def.handle print("#5 Create a connection to alice and print out the invite details") connection_to_alice = await Connection.create('alice') await connection_to_alice.connect('{"use_public_did": true}') await connection_to_alice.update_state() details = await connection_to_alice.invite_details(False) print("**invite details**") print(json.dumps(details)) print("******************") print( "#6 Poll agency and wait for alice to accept the invitation (start alice.py now)" ) connection_state = await connection_to_alice.get_state() while connection_state != State.Accepted: sleep(2) await connection_to_alice.update_state() connection_state = await connection_to_alice.get_state() print("Connection is established") while True: answer = input( "Would you like to do? \n " "1 - issue credential \n " "2 - ask for proof request \n " "3 - send ping \n " "4 - update connection state \n " "else finish \n") \ .lower().strip() if answer == '1': await issue_credential(connection_to_alice, cred_def_handle) elif answer == '2': await ask_for_proof(connection_to_alice, config['institution_did']) elif answer == '3': await connection_to_alice.send_ping(None) connection_state = await connection_to_alice.get_state() while connection_state != State.Accepted: sleep(5) await connection_to_alice.update_state() connection_state = await connection_to_alice.get_state() print("State: " + str(connection_state)) elif answer == '4': await connection_to_alice.update_state() else: break print("Finished")