Пример #1
0
    def __init__(self,
                 basedirpath: str = None,
                 client: Client = None,
                 wallet: Wallet = None,
                 port: int = None,
                 loop=None,
                 config=None):

        super().__init__('Faber College',
                         basedirpath,
                         client,
                         wallet,
                         port=port,
                         loop=loop,
                         config=config,
                         endpointArgs=self.getEndpointArgs(wallet))

        # maps invitation nonces to internal ids
        self._invites = {
            "b1134a647eb818069c089e7694f63e6d": 1,
            "2a2eb72eca8b404e8d412c5bf79f2640": 2,
            "7513d1397e87cada4214e2a650f603eb": 3,
            "710b78be79f29fc81335abaa4ee1c5e8": 4
        }

        self._attrDef = AttribDef('Transcript', [
            AttribType('student_name', encode=True),
            AttribType('ssn', encode=True),
            AttribType('degree', encode=True),
            AttribType('year', encode=True),
            AttribType('status', encode=True)
        ])

        # maps internal ids to attributes
        self._attrs = {
            1:
            self._attrDef.attribs(student_name="Alice Garcia",
                                  ssn="123-45-6789",
                                  degree="Bachelor of Science, Marketing",
                                  year="2015",
                                  status="graduated"),
            2:
            self._attrDef.attribs(student_name="Carol Atkinson",
                                  ssn="783-41-2695",
                                  degree="Bachelor of Science, Physics",
                                  year="2012",
                                  status="graduated"),
            3:
            self._attrDef.attribs(student_name="Frank Jeffrey",
                                  ssn="996-54-1211",
                                  degree="Bachelor of Arts, History",
                                  year="2013",
                                  status="dropped"),
            4:
            self._attrDef.attribs(student_name="Craig Richards",
                                  ssn="151-44-5876",
                                  degree="MBA, Finance",
                                  year="2015",
                                  status="graduated")
        }
Пример #2
0
    def getAttributes(self, nonce):
        attrs = self._attributes.get(nonce)
        if not attrs:
            attrs = {
                "student_name": random.choice(randomData.NAMES),
                "ssn": random.choice(randomData.SSN),
                "degree": random.choice(randomData.DEGREE),
                "year": random.choice(randomData.YEAR),
                "status": random.choice(randomData.STATUS)
            }

        attribTypes = []
        for name in attrs:
            attribTypes.append(AttribType(name, encode=True))
        attribsDef = AttribDef("Transcript", attribTypes)
        attribs = attribsDef.attribs(**attrs)
        return attribs
Пример #3
0
def faberAddedAttributesForAlice(aliceAcceptedFaberInvitation, aliceCli,
                                 faberMap, faberIsRunning):
    faber, faberWallet = faberIsRunning
    aliceIdrForFaber = aliceCli.activeWallet.getLinkInvitationByTarget(
        faberMap['target']).verkey
    attrs = {
        "student_name": "Alice Garcia",
        "ssn": "123456789",
        "degree": "Bachelor of Science, Marketing",
        "year": "2015",
        "status": "graduated"
    }
    attribTypes = []
    for name in attrs:
        attribTypes.append(AttribType(name, encode=True))
    attribsDef = AttribDef("Transcript", attribTypes)
    attribs = attribsDef.attribs(**attrs)
    faber.attributeRepo.addAttributes(aliceIdrForFaber, attribs)
Пример #4
0
    def __init__(self,
                 basedirpath: str,
                 client: Client = None,
                 wallet: Wallet = None,
                 port: int = None,
                 loop=None,
                 config=None):

        super().__init__('Thrift Bank',
                         basedirpath,
                         client,
                         wallet,
                         port=port,
                         loop=loop,
                         config=config,
                         endpointArgs=self.getEndpointArgs(wallet))

        # maps invitation nonces to internal ids
        self._invites = {"77fbf9dc8c8e6acde33de98c6d747b28c": 1}

        self._attrDef = AttribDef('Thrift', [
            AttribType('title', encode=True),
            AttribType('first_name', encode=True),
            AttribType('last_name', encode=True),
            AttribType('address_1', encode=True),
            AttribType('address_2', encode=True),
            AttribType('address_3', encode=True),
            AttribType('postcode_zip', encode=True),
            AttribType('date_of_birth', encode=True)
        ])

        self._attrs = {
            1:
            self._attrDef.attribs(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')
        }
Пример #5
0
        157329491389375793912190594961134932804032426403110797476730107804356484516061051345332763141806005838436304922612495876180233509449197495032194146432047460167589034147716097417880503952139805241591622353828629383332869425029086898452227895418829799945650973848983901459733426212735979668835984691928193677469
    ),
     cmod.integer(
         151323892648373196579515752826519683836764873607632072057591837216698622729557534035138587276594156320800768525825023728398410073692081011811496168877166664537052088207068061172594879398773872352920912390983199416927388688319207946493810449203702100559271439586753256728900713990097168484829574000438573295723
     )),
    "prime2":
    (cmod.integer(
        150619677884468353208058156632953891431975271416620955614548039937246769610622017033385394658879484186852231469238992217246264205570458379437126692055331206248530723117202131739966737760399755490935589223401123762051823602343810554978803032803606907761937587101969193241921351011430750970746500680609001799529
    ),
     cmod.integer(
         171590857568436644992359347719703764048501078398666061921719064395827496970696879481740311141148273607392657321103691543916274965279072000206208571551864201305434022165176563363954921183576230072812635744629337290242954699427160362586102068962285076213200828451838142959637006048439307273563604553818326766703
     ))
}

GVT = AttribDef('gvt', [
    AttribType('name', encode=True),
    AttribType('age', encode=False),
    AttribType('height', encode=False),
    AttribType('sex', encode=True)
])
XYZCorp = AttribDef(
    'xyz',
    [AttribType('status', encode=True),
     AttribType('period', encode=False)])
# NASEMP = GVT + XYZCorp
#
iA1 = 100
iA2 = 101
#
proverId1 = 222
proverId2 = 333
Пример #6
0
    def __init__(self,
                 basedirpath: str,
                 client: Client = None,
                 wallet: Wallet = None,
                 port: int = None,
                 loop=None):
        if not basedirpath:
            config = getConfig()
            basedirpath = basedirpath or os.path.expanduser(config.baseDir)

        portParam, = self.getPassedArgs()

        super().__init__('Acme Corp',
                         basedirpath,
                         client,
                         wallet,
                         portParam or port,
                         loop=loop)

        self.availableClaims = []

        # maps invitation nonces to internal ids
        self._invites = {
            "57fbf9dc8c8e6acde33de98c6d747b28c": 1,
            "3a2eb72eca8b404e8d412c5bf79f2640": 2,
            "8513d1397e87cada4214e2a650f603eb": 3,
            "810b78be79f29fc81335abaa4ee1c5e8": 4
        }

        self._attrDefJobCert = AttribDef('Acme Job Certificat', [
            AttribType('first_name', encode=True),
            AttribType('last_name', encode=True),
            AttribType('employee_status', encode=True),
            AttribType('experience', encode=True),
            AttribType('salary_bracket', encode=True)
        ])

        self._attrDefJobApp = AttribDef('Acme Job Application', [
            AttribType('first_name', encode=True),
            AttribType('last_name', encode=True),
            AttribType('phone_number', encode=True),
            AttribType('degree', encode=True),
            AttribType('status', encode=True),
            AttribType('ssn', encode=True)
        ])

        # maps internal ids to attributes
        self._attrsJobCert = {
            1:
            self._attrDefJobCert.attribs(
                first_name="Alice",
                last_name="Garcia",
                employee_status="Permanent",
                experience="3 years",
                salary_bracket="between $50,000 to $100,000"),
            2:
            self._attrDefJobCert.attribs(
                first_name="Carol",
                last_name="Atkinson",
                employee_status="Permanent",
                experience="2 years",
                salary_bracket="between $60,000 to $90,000"),
            3:
            self._attrDefJobCert.attribs(
                first_name="Frank",
                last_name="Jeffrey",
                employee_status="Temporary",
                experience="4 years",
                salary_bracket="between $40,000 to $80,000"),
            4:
            self._attrDefJobCert.attribs(
                first_name="Craig",
                last_name="Richards",
                employee_status="On Contract",
                experience="3 years",
                salary_bracket="between $50,000 to $70,000")
        }

        self._schemaJobCertKey = SchemaKey("Job-Certificate", "0.2",
                                           self.wallet.defaultId)
        self._schemaJobAppKey = SchemaKey("Job-Application", "0.2",
                                          self.wallet.defaultId)
Пример #7
0
def create_faber(name=None,
                 wallet=None,
                 base_dir_path=None,
                 port=5555,
                 client=None):

    if client is None:
        client = create_client(base_dir_path=base_dir_path,
                               client_class=TestClient)

    endpoint_args = {'onlyListener': True}
    if wallet:
        endpoint_args['seed'] = wallet._signerById(wallet.defaultId).seed
    else:
        wallet = Wallet(name)
        wallet.addIdentifier(signer=FABER_SIGNER)
        endpoint_args['seed'] = FABER_SEED

    agent = WalletedAgent(name=name or "Faber College",
                          basedirpath=base_dir_path,
                          client=client,
                          wallet=wallet,
                          port=port,
                          endpointArgs=endpoint_args)

    agent._invites = {
        "b1134a647eb818069c089e7694f63e6d": (1, "Alice"),
        "2a2eb72eca8b404e8d412c5bf79f2640": (2, "Carol"),
        "7513d1397e87cada4214e2a650f603eb": (3, "Frank"),
        "710b78be79f29fc81335abaa4ee1c5e8": (4, "Bob")
    }

    transcript_def = AttribDef('Transcript', [
        AttribType('student_name', encode=True),
        AttribType('ssn', encode=True),
        AttribType('degree', encode=True),
        AttribType('year', encode=True),
        AttribType('status', encode=True)
    ])

    agent.add_attribute_definition(transcript_def)

    backend = MockBackendSystem(transcript_def)

    backend.add_record(1,
                       student_name="Alice Garcia",
                       ssn="123-45-6789",
                       degree="Bachelor of Science, Comp Sci",
                       year="2015",
                       status="graduated")

    backend.add_record(2,
                       student_name="Carol Atkinson",
                       ssn="783-41-2695",
                       degree="Bachelor of Science, Physics",
                       year="2012",
                       status="graduated")

    backend.add_record(3,
                       student_name="Frank Jeffrey",
                       ssn="996-54-1211",
                       degree="Bachelor of Arts, History",
                       year="2013",
                       status="dropped")

    backend.add_record(4,
                       student_name="Bob Richards",
                       ssn="151-44-5876",
                       degree="MBA, Finance",
                       year="2015",
                       status="graduated")

    agent.set_issuer_backend(backend)

    return agent
Пример #8
0
    def __init__(self,
                 basedirpath: str,
                 client: Client = None,
                 wallet: Wallet = None,
                 port: int = None,
                 loop=None):
        if not basedirpath:
            config = getConfig()
            basedirpath = basedirpath or os.path.expanduser(config.baseDir)

        portParam, = self.getPassedArgs()

        super().__init__('Faber College',
                         basedirpath,
                         client,
                         wallet,
                         portParam or port,
                         loop=loop)

        self.availableClaims = []

        # maps invitation nonces to internal ids
        self._invites = {
            "b1134a647eb818069c089e7694f63e6d": 1,
            "2a2eb72eca8b404e8d412c5bf79f2640": 2,
            "7513d1397e87cada4214e2a650f603eb": 3,
            "710b78be79f29fc81335abaa4ee1c5e8": 4
        }

        self._attrDef = AttribDef('faber', [
            AttribType('student_name', encode=True),
            AttribType('ssn', encode=True),
            AttribType('degree', encode=True),
            AttribType('year', encode=True),
            AttribType('status', encode=True)
        ])

        # maps internal ids to attributes
        self._attrs = {
            1:
            self._attrDef.attribs(student_name="Alice Garcia",
                                  ssn="123-45-6789",
                                  degree="Bachelor of Science, Marketing",
                                  year="2015",
                                  status="graduated"),
            2:
            self._attrDef.attribs(student_name="Carol Atkinson",
                                  ssn="783-41-2695",
                                  degree="Bachelor of Science, Physics",
                                  year="2012",
                                  status="graduated"),
            3:
            self._attrDef.attribs(student_name="Frank Jeffrey",
                                  ssn="996-54-1211",
                                  degree="Bachelor of Arts, History",
                                  year="2013",
                                  status="dropped"),
            4:
            self._attrDef.attribs(student_name="Craig Richards",
                                  ssn="151-44-5876",
                                  degree="MBA, Finance",
                                  year="2015",
                                  status="graduated")
        }

        self._schema = SchemaKey("Transcript", "1.2", self.wallet.defaultId)
Пример #9
0
def create_acme(name=None,
                wallet=None,
                base_dir_path=None,
                port=6666,
                client=None):
    if client is None:
        client = create_client(base_dir_path=None, client_class=TestClient)

    endpoint_args = {'onlyListener': True}
    if wallet:
        endpoint_args['seed'] = wallet._signerById(wallet.defaultId).seed
    else:
        wallet = Wallet(name)
        wallet.addIdentifier(signer=ACME_SIGNER)
        endpoint_args['seed'] = ACME_SEED

    agent = AcmeAgent(name=name or "Acme Corp",
                      basedirpath=base_dir_path,
                      client=client,
                      wallet=wallet,
                      port=port,
                      endpointArgs=endpoint_args)

    # maps request nonces to internal ids
    agent._invites = {
        "57fbf9dc8c8e6acde33de98c6d747b28c": (1, "Alice"),
        "3a2eb72eca8b404e8d412c5bf79f2640": (2, "Carol"),
        "8513d1397e87cada4214e2a650f603eb": (3, "Frank"),
        "810b78be79f29fc81335abaa4ee1c5e8": (4, "Bob")
    }

    job_cert_def = AttribDef('Job-Certificate', [
        AttribType('first_name', encode=True),
        AttribType('last_name', encode=True),
        AttribType('employee_status', encode=True),
        AttribType('experience', encode=True),
        AttribType('salary_bracket', encode=True)
    ])

    job_appl_def = AttribDef('Job-Application', [
        AttribType('first_name', encode=True),
        AttribType('last_name', encode=True),
        AttribType('phone_number', encode=True),
        AttribType('degree', encode=True),
        AttribType('status', encode=True),
        AttribType('ssn', encode=True)
    ])

    agent.add_attribute_definition(job_cert_def)
    agent.add_attribute_definition(job_appl_def)

    backend = MockBackendSystem(job_cert_def)
    backend.add_record(1,
                       first_name="Alice",
                       last_name="Garcia",
                       employee_status="Permanent",
                       experience="3 years",
                       salary_bracket="between $50,000 to $100,000")

    backend.add_record(2,
                       first_name="Carol",
                       last_name="Atkinson",
                       employee_status="Permanent",
                       experience="2 years",
                       salary_bracket="between $60,000 to $90,000")

    backend.add_record(3,
                       first_name="Frank",
                       last_name="Jeffrey",
                       employee_status="Temporary",
                       experience="4 years",
                       salary_bracket="between $40,000 to $80,000")

    backend.add_record(4,
                       first_name="Bob",
                       last_name="Richards",
                       employee_status="On Contract",
                       experience="3 years",
                       salary_bracket="between $50,000 to $70,000")

    agent.set_issuer_backend(backend)

    agent._proofRequestsSchema = {
        "Job-Application-v0.2": {
            "name": "Job-Application",
            "version": "0.2",
            "attributes": {
                "first_name": "string",
                "last_name": "string",
                "phone_number": "string",
                "degree": "string",
                "status": "string",
                "ssn": "string"
            },
            "verifiableAttributes": ["degree", "status", "ssn"]
        },
        "Job-Application-v0.3": {
            "name": "Job-Application-2",
            "version": "0.3",
            "attributes": {
                "first_name": "string",
                "last_name": "string",
                "phone_number": "string",
                "degree": "string",
                "status": "string",
                "ssn": "string"
            },
            "verifiableAttributes": ["degree", "status"]
        }
    }

    return agent
Пример #10
0
import pytest
from anoncreds.protocol.issuer import Issuer
from anoncreds.protocol.repo.attributes_repo import AttributeRepoInMemory
from anoncreds.protocol.types import AttribType, AttribDef, Schema, ID
from anoncreds.protocol.wallet.issuer_wallet import IssuerWalletInMemory

from indy_client.anon_creds.indy_public_repo import IndyPublicRepo

GVT = AttribDef('gvt', [
    AttribType('name', encode=True),
    AttribType('age', encode=False),
    AttribType('height', encode=False),
    AttribType('sex', encode=True)
])

# We perform all tests twice:
# - no revocation case (primary key only)
# - revocation case (both primary and revocation keys)
# There are two Schemas generated (one for each branch of tests)
revoc_params = ['revocation', 'no_revocation']


@pytest.fixture(scope="module")
def public_repo(steward, stewardWallet):
    return IndyPublicRepo(steward, stewardWallet)


@pytest.fixture(scope="module")
def public_repo_2(trustee, trusteeWallet):
    return IndyPublicRepo(trustee, trusteeWallet)
Пример #11
0
    def __init__(self,
                 basedirpath: str,
                 client: Client = None,
                 wallet: Wallet = None,
                 port: int = None,
                 loop=None,
                 config=None):

        super().__init__('Acme Corp',
                         basedirpath,
                         client,
                         wallet,
                         port=port,
                         loop=loop,
                         config=config,
                         endpointArgs=self.getEndpointArgs(wallet))

        # maps invitation nonces to internal ids
        self._invites = {
            "57fbf9dc8c8e6acde33de98c6d747b28c": 1,
            "3a2eb72eca8b404e8d412c5bf79f2640": 2,
            "8513d1397e87cada4214e2a650f603eb": 3,
            "810b78be79f29fc81335abaa4ee1c5e8": 4
        }

        self._attrDefJobCert = AttribDef('Job-Certificate', [
            AttribType('first_name', encode=True),
            AttribType('last_name', encode=True),
            AttribType('employee_status', encode=True),
            AttribType('experience', encode=True),
            AttribType('salary_bracket', encode=True)
        ])

        self._attrDefJobApp = AttribDef('Job-Application', [
            AttribType('first_name', encode=True),
            AttribType('last_name', encode=True),
            AttribType('phone_number', encode=True),
            AttribType('degree', encode=True),
            AttribType('status', encode=True),
            AttribType('ssn', encode=True)
        ])

        # maps internal ids to attributes
        self._attrs = {
            1:
            self._attrDefJobCert.attribs(
                first_name="Alice",
                last_name="Garcia",
                employee_status="Permanent",
                experience="3 years",
                salary_bracket="between $50,000 to $100,000"),
            2:
            self._attrDefJobCert.attribs(
                first_name="Carol",
                last_name="Atkinson",
                employee_status="Permanent",
                experience="2 years",
                salary_bracket="between $60,000 to $90,000"),
            3:
            self._attrDefJobCert.attribs(
                first_name="Frank",
                last_name="Jeffrey",
                employee_status="Temporary",
                experience="4 years",
                salary_bracket="between $40,000 to $80,000"),
            4:
            self._attrDefJobCert.attribs(
                first_name="Craig",
                last_name="Richards",
                employee_status="On Contract",
                experience="3 years",
                salary_bracket="between $50,000 to $70,000")
        }

        self._proofRequestsSchema = {
            "Job-Application-v0.2": {
                "name": "Job-Application",
                "version": "0.2",
                "attributes": {
                    "first_name": "string",
                    "last_name": "string",
                    "phone_number": "string",
                    "degree": "string",
                    "status": "string",
                    "ssn": "string"
                },
                "verifiableAttributes": ["degree", "status", "ssn"]
            }
        }
Пример #12
0
from anoncreds.protocol.prover import Prover
from config.config import cmod

from anoncreds.protocol.attribute_repo import InMemoryAttrRepo
from anoncreds.protocol.cred_def_secret_key import CredDefSecretKey
from anoncreds.protocol.issuer import Issuer
from anoncreds.protocol.credential_definition import CredentialDefinition
from anoncreds.protocol.issuer_secret_key import IssuerSecretKey
from anoncreds.protocol.types import AttribDef, AttribType
from anoncreds.protocol.verifier import Verifier
from anoncreds.test.cred_def_test_store import MemoryCredDefStore
from anoncreds.test.helper import getProofBuilderAndAttribs
from anoncreds.test.issuer_key_test_store import MemoryIssuerKeyStore

GVT = AttribDef('gvt', [
    AttribType('name', encode=True),
    AttribType('age', encode=False),
    AttribType('sex', encode=True)
])
XYZCorp = AttribDef('xyz', [AttribType('status', encode=True)])
NASEMP = GVT + XYZCorp


@pytest.fixture(scope="module")
def gvtAttrRepo():
    attrRepo = InMemoryAttrRepo()
    attrRepo.addAttributes('prover1', GVT.attribs())
    return attrRepo


# @pytest.fixture(scope="module")
Пример #13
0
    def __init__(self,
                 basedirpath: str,
                 client: Client = None,
                 wallet: Wallet = None,
                 port: int = None,
                 loop=None):
        if not basedirpath:
            config = getConfig()
            basedirpath = basedirpath or os.path.expanduser(config.baseDir)

        portParam, = self.getPassedArgs()
        agentLogger = getBulldogLogger(basedirpath)

        super().__init__('Bulldog',
                         basedirpath,
                         client,
                         wallet,
                         portParam or port,
                         loop=loop,
                         agentLogger=agentLogger)

        self.availableClaims = []

        # mapping between requester identifier and corresponding available claims
        self.requesterAvailClaims = {}

        # maps invitation nonces to internal ids
        self._invites = {'2e9882ea71976ddf9': 1, "2d03828a7383ea3ad": 2}

        self._attrDef = AttribDef('bulldog', [
            AttribType('title', encode=True),
            AttribType('first_name', encode=True),
            AttribType('last_name', encode=True),
            AttribType('address_1', encode=True),
            AttribType('address_2', encode=True),
            AttribType('address_3', encode=True),
            AttribType('postcode_zip', encode=True),
            AttribType('date_of_birth', encode=True),
            AttribType('account_type', encode=True),
            AttribType('year_opened', encode=True),
            AttribType('account_status', encode=True)
        ])

        # maps internal ids to attributes
        self._attrs = {
            1:
            self._attrDef.attribs(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'),
            2:
            self._attrDef.attribs(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')
        }

        claimVersionFileName = 'bulldog-schema-version.txt'
        claimVersionNumber = 0.8
        claimVersionFilePath = '{}/{}'.format(basedirpath,
                                              claimVersionFileName)
        # get version number from file
        if os.path.isfile(claimVersionFilePath):
            try:
                with open(claimVersionFilePath, mode='r+') as file:
                    claimVersionNumber = float(file.read()) + 0.1
                    file.seek(0)
                    # increment version and update file
                    file.write(str(claimVersionNumber))
                    file.truncate()
            except OSError as e:
                agentLogger.warn('Error occurred while reading version file:'
                                 'error:{}'.format(e))
                raise e
            except ValueError as e:
                agentLogger.warn('Invalid version number')
                raise e
        else:
            try:
                with open(claimVersionFilePath, mode='w') as file:
                    file.write(str(claimVersionNumber))
            except OSError as e:
                agentLogger.warn('Error creating version file {}'.format(e))
                raise e

        self._schemaKey = SchemaKey('Banking-Relationship',
                                    str(claimVersionNumber),
                                    self.wallet.defaultId)