예제 #1
0
    def certify(self, password, community, pubkey):
        """
        Certify an other identity

        :param str password: The account SigningKey password
        :param cutecoin.core.community.Community community: The community target of the certification
        :param str pubkey: The certified identity pubkey
        """
        certified = Person.lookup(pubkey, community)
        blockid = community.current_blockid()

        certification = Certification(PROTOCOL_VERSION, community.currency,
                                      self.pubkey, certified.pubkey,
                                      blockid['number'], blockid['hash'], None)

        selfcert = certified.selfcert(community)
        logging.debug("SelfCertification : {0}".format(selfcert.raw()))

        key = SigningKey(self.salt, password)
        certification.sign(selfcert, [key])
        signed_cert = certification.signed_raw(selfcert)
        logging.debug("Certification : {0}".format(signed_cert))

        data = {'pubkey': certified.pubkey,
                'self_': selfcert.signed_raw(),
                'other': "{0}\n".format(certification.inline())}
        logging.debug("Posted data : {0}".format(data))
        community.broadcast(bma.wot.Add, {}, data)
예제 #2
0
파일: account.py 프로젝트: zero-code/sakia
    def certify(self, password, community, pubkey):
        """
        Certify an other identity

        :param str password: The account SigningKey password
        :param sakia.core.community.Community community: The community target of the certification
        :param str pubkey: The certified identity pubkey
        """
        logging.debug("Certdata")
        blockid = yield from community.blockid()
        identity = yield from self._identities_registry.future_find(pubkey, community)
        selfcert = yield from identity.selfcert(community)
        if selfcert:
            certification = Certification(PROTOCOL_VERSION, community.currency,
                                          self.pubkey, pubkey,
                                          blockid.number, blockid.sha_hash, None)

            key = SigningKey(self.salt, password)
            certification.sign(selfcert, [key])
            signed_cert = certification.signed_raw(selfcert)
            logging.debug("Certification : {0}".format(signed_cert))

            data = {'pubkey': pubkey,
                    'self_': selfcert.signed_raw(),
                    'other': "{0}\n".format(certification.inline())}
            logging.debug("Posted data : {0}".format(data))
            responses = yield from community.bma_access.broadcast(bma.wot.Add, {}, data)
            result = (False, "")
            for r in responses:
                if r.status == 200:
                    result = (True, (yield from r.json()))
                    # signal certification to all listeners
                    self.certification_accepted.emit()
                elif not result[0]:
                    result = (False, (yield from r.text()))
                else:
                    yield from r.release()
            return result
        else:
            return (False, self.tr("Could not find user self certification."))
예제 #3
0
    def certify(self, password, community, pubkey):
        """
        Certify an other identity

        :param str password: The account SigningKey password
        :param cutecoin.core.community.Community community: The community target of the certification
        :param str pubkey: The certified identity pubkey
        """
        certified = Person.lookup(pubkey, community)
        blockid = community.current_blockid()

        certification = Certification(PROTOCOL_VERSION, community.currency,
                                      self.pubkey, certified.pubkey,
                                      blockid['number'], blockid['hash'], None)

        selfcert = certified.selfcert(community)
        logging.debug("SelfCertification : {0}".format(selfcert.raw()))

        key = SigningKey(self.salt, password)
        certification.sign(selfcert, [key])
        signed_cert = certification.signed_raw(selfcert)
        logging.debug("Certification : {0}".format(signed_cert))

        data = {
            'pubkey': certified.pubkey,
            'self_': selfcert.signed_raw(),
            'other': "{0}\n".format(certification.inline())
        }
        logging.debug("Posted data : {0}".format(data))
        community.broadcast(bma.wot.Add, {}, data)