예제 #1
0
    def setAlaDIDPublicEntity(self, node_name, label, DID, name, DIDDocument,
                              active, new_owner_address, caller_key):

        if node_name == "root":
            node_hash = b.to_32byte_hex(0)
        else:
            node_hash = raw_name_to_hash(node_name)

        label_hash = label_to_hash(label)

        # Calculate the hash of the DID
        DIDHash = b.Web3.keccak(text=DID)

        success, tx_receipt, tx_hash = b.send_signed_tx(
            PublicResolver.functions.setAlaDIDPublicEntity(
                node_hash,
                label_hash,
                DIDHash,
                name,
                DIDDocument,
                active,
                new_owner_address,
            ), caller_key)

        return success, tx_receipt, tx_hash
예제 #2
0
    def setCredential(self,
                      node_name="root",
                      key=None,
                      credentialHash=None,
                      participants=[],
                      caller_key=None):

        if node_name == "root":
            node_hash = b.to_32byte_hex(0)
        else:
            node_hash = raw_name_to_hash(node_name)

        participantsHash = []
        for i in range(5):
            if i < len(participants):
                participantsHash.append(self.hash(participants[i]))
            else:
                participantsHash.append(bytes(32))

        success, tx_receipt, tx_hash = b.send_signed_tx(
            PublicResolver.functions.setCredential(
                node_hash,
                key,
                credentialHash,
                participantsHash[0],
                participantsHash[1],
                participantsHash[2],
                participantsHash[3],
                participantsHash[4],
            ), caller_key)

        return success, tx_receipt, tx_hash
예제 #3
0
    def owner(self, node_name="root"):
        if node_name == "root":
            node_hash = b.to_32byte_hex(0)
        else:
            node_hash = raw_name_to_hash(node_name)

        owner = ENS.functions.owner(node_hash).call()
        return owner
예제 #4
0
    def resolver(self, node_name="root"):

        if node_name == "root":
            node_hash = b.to_32byte_hex(0)
        else:
            node_hash = raw_name_to_hash(node_name)

        Resolver_address = ENS.functions.resolver(node_hash).call()
        return Resolver_address
예제 #5
0
    def AlaTSP(self, node_name="root", node_hash=None):

        if node_hash is None:
            if node_name == "root":
                node_hash = b.to_32byte_hex(0)
            else:
                node_hash = raw_name_to_hash(node_name)

        URI, org, active = PublicResolver.functions.AlaTSP(node_hash).call()

        return URI, org, active
예제 #6
0
    def name(self, node_name="root", node_hash=None):

        if node_hash is None:
            if node_name == "root":
                node_hash = b.to_32byte_hex(0)
            else:
                node_hash = raw_name_to_hash(node_name)

        name = PublicResolver.functions.name(node_hash).call()

        return name
예제 #7
0
    def AlaTSPService(self, node_name="root", node_hash=None, index=0):

        if node_hash is None:
            if node_name == "root":
                node_hash = b.to_32byte_hex(0)
            else:
                node_hash = raw_name_to_hash(node_name)

        X509SKI, serviceName, X509Certificate, active = PublicResolver.functions.AlaTSPService(
            node_hash, index).call()

        return X509SKI, serviceName, X509Certificate, active
예제 #8
0
    def AlaTSPNumberServices(self, node_name="root", node_hash=None):

        if node_hash is None:
            if node_name == "root":
                node_hash = b.to_32byte_hex(0)
            else:
                node_hash = raw_name_to_hash(node_name)

        numServices = PublicResolver.functions.AlaTSPNumberServices(
            node_hash).call()

        return numServices
예제 #9
0
    def setResolver(self,
                    node_name="root",
                    resolver_address=None,
                    current_owner_key=None):

        if node_name == "root":
            node_hash = b.to_32byte_hex(0)
        else:
            node_hash = raw_name_to_hash(node_name)

        contract_fun = ENS.functions.setResolver(node_hash, resolver_address)
        success, tx_receipt, tx_hash = b.send_signed_tx(
            contract_fun, current_owner_key)
        return success, tx_receipt, tx_hash
예제 #10
0
    def setName(self,
                node_name="root",
                name_to_resolve="root",
                current_owner_key=None):

        if node_name == "root":
            node_hash = b.to_32byte_hex(0)
        else:
            node_hash = raw_name_to_hash(node_name)

        contract_fun = PublicResolver.functions.setName(
            node_hash, name_to_resolve)
        success, tx_receipt, tx_hash = b.send_signed_tx(
            contract_fun, current_owner_key)
        return success, tx_receipt, tx_hash
예제 #11
0
    def confirmCredential(self,
                          node_name=None,
                          key=None,
                          participantDID=None,
                          caller_key=None):

        if node_name == "root":
            node_hash = b.to_32byte_hex(0)
        else:
            node_hash = raw_name_to_hash(node_name)

        participantHash = self.hash(participantDID)

        success, tx_receipt, tx_hash = b.send_signed_tx(
            PublicResolver.functions.confirmCredential(node_hash, key,
                                                       participantHash),
            caller_key)

        return success, tx_receipt, tx_hash
예제 #12
0
    def setAlaTSP(self,
                  node_name,
                  label,
                  URI,
                  org,
                  active,
                  current_owner_key=None):

        if node_name == "root":
            node_hash = b.to_32byte_hex(0)
        else:
            node_hash = raw_name_to_hash(node_name)

        label_hash = label_to_hash(label)

        contract_fun = PublicResolver.functions.setAlaTSP(
            node_hash, label_hash, URI, org, active)
        success, tx_receipt, tx_hash = b.send_signed_tx(
            contract_fun, current_owner_key)
        return success, tx_receipt, tx_hash
예제 #13
0
    def AlaDIDPublicEntity(self, node_name="root", node_hash=None):

        if node_hash is None:
            if node_name == "root":
                node_hash = b.to_32byte_hex(0)
            else:
                node_hash = raw_name_to_hash(node_name)

        DIDHash, name, DIDDocument, active = PublicResolver.functions.AlaDIDPublicEntity(
            node_hash).call()

        if DIDDocument == "":
            return None, None, None, None

        # Verify integrity: the DIDHash should equal the hash of the DID inside the DIDDocument
        diddoc = json.loads(DIDDocument)
        DID = diddoc["id"]
        did_hash = b.Web3.keccak(text=DID)
        if did_hash == DIDHash:
            return DID, name, DIDDocument, active
        else:
            return None, None, None, None
예제 #14
0
    def addAlaTSPService(self,
                         node_name,
                         label,
                         X509SKI,
                         serviceName,
                         X509Certificate,
                         active,
                         current_owner_key=None):

        if node_name == "root":
            node_hash = b.to_32byte_hex(0)
        else:
            node_hash = raw_name_to_hash(node_name)

        label_hash = label_to_hash(label)

        contract_fun = PublicResolver.functions.addAlaTSPService(
            node_hash, label_hash, X509SKI, serviceName, X509Certificate,
            active)
        success, tx_receipt, tx_hash = b.send_signed_tx(
            contract_fun, current_owner_key)
        return success, tx_receipt, tx_hash