async def create_proof_request(conn):
    # 1. Init entities
    public_repo = PublicRepoInMemory()
    attr_repo = AttributeRepoInMemory()
    issuer = Issuer(IssuerWalletInMemory('issuer1', public_repo), attr_repo)

    # 2. Create a Schema
    schema = await issuer.genSchema('GVT', '1.0', GVT.attribNames())
    schema_id = ID(schema.getKey())

    # 3. Create keys for the Schema
    global global_dict
    await issuer.wallet.submitPublicKeys(schema_id, global_dict['public_key'])

    # 4. set attributes for user1
    prover_id = 'BzfFCYk'
    attributes = GVT.attribs(name='Alex', age=28, height=175, sex='male')
    attr_repo.addAttributes(schema.getKey(), prover_id, attributes)

    verifier = Verifier(WalletInMemory('verifier1', public_repo))

    proof_request = ProofRequest(
        name='Test_proof', version='1.0',
        nonce=verifier.generateNonce(),
        verifiableAttributes={
            'attr_uuid': AttributeInfo('name', schema.seqId)},
        predicates={'predicate_uuid': PredicateGE('age', 18)})

    global_dict['verifier'] = verifier
    global_dict['proof_request'] = proof_request

    conn.send(json.dumps(proof_request.to_str_dict()).encode())
예제 #2
0
    async def sendProofAsync(self, link: Link, proofRequest: ProofRequest):
        # TODO _F_ this nonce should be from the Proof Request, not from an
        # invitation
        # TODO rename presentProof to buildProof or generateProof

        proof = await self.prover.presentProof(proofRequest)
        proof.requestedProof.self_attested_attrs.update(proofRequest.selfAttestedAttrs)

        op = {
            TYPE: PROOF,
            NONCE: link.invitationNonce,
            PROOF_FIELD: proof.to_str_dict(),
            PROOF_REQUEST_FIELD: proofRequest.to_str_dict()
        }

        self.signAndSendToLink(msg=op, linkName=link.name)
예제 #3
0
    async def sendProofAsync(self, link: Connection,
                             proofRequest: ProofRequest):
        # TODO _F_ this nonce should be from the Proof Request, not from an
        # invitation
        # TODO rename presentProof to buildProof or generateProof

        proof = await self.prover.presentProof(proofRequest)
        proof.requestedProof.self_attested_attrs.update(
            proofRequest.selfAttestedAttrs)

        op = {
            TYPE: PROOF,
            NONCE: link.request_nonce,
            PROOF_FIELD: proof.to_str_dict(),
            PROOF_REQUEST_FIELD: proofRequest.to_str_dict()
        }

        self.signAndSendToLink(msg=op, linkName=link.name)
예제 #4
0
    def sendProofReq(self, link: Link, proofReqSchemaKey):
        if self._proofRequestsSchema and (
                    proofReqSchemaKey in self._proofRequestsSchema):
            proofRequest = self._proofRequestsSchema[proofReqSchemaKey]

            proofRequest = ProofRequest(
                proofRequest[NAME],
                proofRequest[VERSION],
                getNonceForProof(link.invitationNonce),
                proofRequest[ATTRIBUTES],
                proofRequest[VERIFIABLE_ATTRIBUTES] if VERIFIABLE_ATTRIBUTES in proofRequest else [],
                proofRequest[PREDICATES] if PREDICATES in proofRequest else []
            )

            op = {
                TYPE: PROOF_REQUEST,
                PROOF_REQUEST_FIELD: proofRequest.to_str_dict()
            }

            self.signAndSendToLink(msg=op, linkName=link.name)
        else:
            return ERR_NO_PROOF_REQUEST_SCHEMA_FOUND