def nymsAddedInQuickSuccession(nodeSet, addedTrustAnchor, looper, trustAnchor, trustAnchorWallet): usigner = DidSigner() nym = usigner.verkey idy = Identity(identifier=nym) trustAnchorWallet.addTrustAnchoredIdentity(idy) # Creating a NYM request with same nym again req = idy.ledgerRequest() trustAnchorWallet._pending.appendleft((req, idy.identifier)) reqs = trustAnchorWallet.preparePending() trustAnchor.submitReqs(*reqs) def check(): assert trustAnchorWallet._trustAnchored[nym].seqNo timeout = waits.expectedTransactionExecutionTime(len(nodeSet)) looper.run(eventually(check, timeout=timeout)) timeout = waits.expectedReqNAckQuorumTime() looper.run(eventually(checkNacks, trustAnchor, req.reqId, "is already added", retryWait=1, timeout=timeout)) count = 0 for node in nodeSet: for seq, txn in node.domainLedger.getAllTxn(): if txn[TXN_TYPE] == NYM and txn[TARGET_NYM] == usigner.identifier: count += 1 assert(count == len(nodeSet))
def requestIdentity(self, identity: Identity, sender): # Used to get a nym from Sovrin self.knownIds[identity.identifier] = identity req = identity.getRequest(sender) if req: return self.prepReq(req)
def test_end_to_end(tconf): base_dir = tconf.baseDir print('*' * 20) print(base_dir) print('*' * 20) with create_local_pool(base_dir) as network: print(network.genesis_transactions) network.runFor(5) client = network.create_client(5555) bank_wallet = Wallet() bank_agent = RefAgent(name="bank", basedirpath=base_dir, client=client, wallet=bank_wallet, port=8787, endpointArgs={ 'seed': BANK_SEED, 'onlyListener': True }) network.add(bank_agent) bank_id, bank_verkey = bank_agent.new_identifier(seed=BANK_SEED) print(bank_id) print(bank_verkey) s1_agent = network.steward_agent() s1_agent.publish_trust_anchor( Identity(identifier=bank_id, verkey=bank_verkey, role=TRUST_ANCHOR)) network.runFor(5) # this allows calling asynchronous functions from a synchronous context run_async = network.run bank_attribute_definition = anoncreds.protocol.types.AttribDef( 'basic', [ anoncreds.protocol.types.AttribType('title', encode=True), anoncreds.protocol.types.AttribType('first_name', encode=True), anoncreds.protocol.types.AttribType('last_name', encode=True), anoncreds.protocol.types.AttribType('address_1', encode=True), anoncreds.protocol.types.AttribType('address_2', encode=True), anoncreds.protocol.types.AttribType('address_3', encode=True), anoncreds.protocol.types.AttribType('postcode_zip', encode=True), anoncreds.protocol.types.AttribType('date_of_birth', encode=True), anoncreds.protocol.types.AttribType('account_type', encode=True), anoncreds.protocol.types.AttribType('year_opened', encode=True), anoncreds.protocol.types.AttribType('account_status', encode=True) ]) bank_agent.add_attribute_definition(bank_attribute_definition) backend = MockBackendSystem(bank_attribute_definition) alices_id_in_banks_system = 1999891343 bobs_id_in_banks_system = 2911891343 backend.add_record(alices_id_in_banks_system, title='Mrs.', first_name='Alicia', last_name='Garcia', address_1='H-301', address_2='Street 1', address_3='UK', postcode_zip='G61 3NR', date_of_birth='December 28, 1990', account_type='savings', year_opened='2000', account_status='active') backend.add_record(bobs_id_in_banks_system, title='Mrs.', first_name='Jay', last_name='Raj', address_1='222', address_2='Baker Street', address_3='UK', postcode_zip='G61 3NR', date_of_birth='January 15, 1980', account_type='savings', year_opened='1999', account_status='active') bank_agent.set_issuer_backend(backend) schema_id = run_async( bank_agent.publish_schema('basic', schema_name='Bank Membership', schema_version='1.0')) # NOTE: do NOT use known primes in a non-test environment issuer_pub_key, revocation_pub_key = run_async( bank_agent.publish_issuer_keys(schema_id, p_prime=primes["prime1"][0], q_prime=primes["prime1"][1])) print(issuer_pub_key) print(revocation_pub_key) # TODO: Not implemented yet # accPK = run_async(bank_agent.publish_revocation_registry( # schema_id=schema_id)) # print(accPK) run_async( bank_agent._set_available_claim_by_internal_id( alices_id_in_banks_system, schema_id)) run_async( bank_agent._set_available_claim_by_internal_id( bobs_id_in_banks_system, schema_id)) alice_wallet = Wallet() alice_agent = RefAgent(name="Alice", basedirpath=base_dir, client=client, wallet=alice_wallet, port=8786) network.add(alice_agent) network.runFor(1) request = bank_agent.create_connection_request( alices_id_in_banks_system, "Alice") # Transfer of this request happens out-of-band (website, QR code, etc) alices_link_to_bank = alice_agent.load_request_str(request) # notice the link is not accepted print(alices_link_to_bank) alice_agent.accept_request(alices_link_to_bank) network.runFor(10) # notice that the link is accepted print(alices_link_to_bank) banks_link_to_alice = bank_agent.get_link_by_name( alices_id_in_banks_system) # note the available claims are now there print(banks_link_to_alice) claim_to_request = alices_link_to_bank.find_available_claim( name='Bank Membership') print(claim_to_request) run_async(alice_agent.send_claim(alices_link_to_bank, claim_to_request)) network.runFor(5) claim = run_async(alice_agent.get_claim(schema_id)) print(claim)
def changeVerkey(looper, actingClient, actingWallet, idr, verkey): idy = Identity(identifier=idr, verkey=verkey) return makeIdentityRequest(looper, actingClient, actingWallet, idy)
def suspendRole(looper, actingClient, actingWallet, did): idy = Identity(identifier=did, role=NULL) return makeIdentityRequest(looper, actingClient, actingWallet, idy)
def sendSuspendRole(actingClient, actingWallet, did): idy = Identity(identifier=did, role=NULL) return sendIdentityRequest(actingClient, actingWallet, idy)
def sendChangeVerkey(actingClient, actingWallet, idr, verkey): idy = Identity(identifier=idr, verkey=verkey) return sendIdentityRequest(actingClient, actingWallet, idy)