Ejemplo n.º 1
0
    async def revoke(self, password, community):
        """
        Revoke self-identity on server, not in blockchain

        :param str password: The account SigningKey password
        :param sakia.core.community.Community community: The community target of the revokation
        """
        revoked = await self._identities_registry.future_find(self.pubkey, community)

        revokation = Revocation(PROTOCOL_VERSION, community.currency, None)
        selfcert = await revoked.selfcert(community)

        key = SigningKey(self.salt, password)
        revokation.sign(selfcert, [key])

        logging.debug("Self-Revokation Document : \n{0}".format(revokation.raw(selfcert)))
        logging.debug("Signature : \n{0}".format(revokation.signatures[0]))

        data = {
            'pubkey': revoked.pubkey,
            'self_': selfcert.signed_raw(),
            'sig': revokation.signatures[0]
        }
        logging.debug("Posted data : {0}".format(data))
        responses = await community.bma_access.broadcast(bma.wot.Revoke, {}, data)
        result = (False, "")
        for r in responses:
            if r.status == 200:
                result = (True, (await r.json()))
            elif not result[0]:
                result = (False, (await r.text()))
            else:
                await r.release()
        return result
Ejemplo n.º 2
0
    async def revoke(self, currency, identity, salt, password):
        """
        Revoke self-identity on server, not in blockchain

        :param str currency: The currency of the identity
        :param sakia.data.entities.IdentityDoc identity: The certified identity
        :param str salt: The account SigningKey salt
        :param str password: The account SigningKey password
        """
        revocation = Revocation(10, currency, None)
        self_cert = identity.document()

        key = SigningKey(salt, password)
        revocation.sign(self_cert, [key])

        self._logger.debug("Self-Revokation Document : \n{0}".format(
            revocation.raw(self_cert)))
        self._logger.debug("Signature : \n{0}".format(
            revocation.signatures[0]))

        data = {
            'pubkey': identity.pubkey,
            'self_': self_cert.signed_raw(),
            'sig': revocation.signatures[0]
        }
        self._logger.debug("Posted data : {0}".format(data))
        responses = await self._bma_connector.broadcast(
            currency, bma.wot.Revoke, {}, data)
        result = await parse_bma_responses(responses)
        return result
Ejemplo n.º 3
0
    def generate_revocation(self, connection, secret_key, password):
        """
        Generate account revocation document for given community

        :param sakia.data.entities.Connection connection: The connection of the identity
        :param str secret_key: The account SigningKey secret key
        :param str password: The account SigningKey password
        """
        document = Revocation(10, connection.currency, connection.pubkey, "")
        identity = self._identities_processor.get_identity(
            connection.currency, connection.pubkey, connection.uid)
        if not identity:
            identity = self.generate_identity(connection)
            identity_doc = identity.document()
            key = SigningKey(connection.salt, connection.password,
                             connection.scrypt_params)
            identity_doc.sign([key])
            identity.signature = identity_doc.signatures[0]
            self._identities_processor.insert_or_update_identity(identity)

        self_cert = identity.document()

        key = SigningKey(secret_key, password, connection.scrypt_params)

        document.sign(self_cert, [key])
        return document.signed_raw(self_cert), identity
Ejemplo n.º 4
0
    async def revoke(self, currency, identity, salt, password):
        """
        Revoke self-identity on server, not in blockchain

        :param str currency: The currency of the identity
        :param sakia.data.entities.IdentityDoc identity: The certified identity
        :param str salt: The account SigningKey salt
        :param str password: The account SigningKey password
        """
        revocation = Revocation(10, currency, None)
        self_cert = identity.document()

        key = SigningKey(salt, password)
        revocation.sign(self_cert, [key])

        self._logger.debug("Self-Revokation Document : \n{0}".format(revocation.raw(self_cert)))
        self._logger.debug("Signature : \n{0}".format(revocation.signatures[0]))

        data = {
            'pubkey': identity.pubkey,
            'self_': self_cert.signed_raw(),
            'sig': revocation.signatures[0]
        }
        self._logger.debug("Posted data : {0}".format(data))
        responses = await self._bma_connector.broadcast(currency, bma.wot.Revoke, {}, data)
        result = await parse_bma_responses(responses)
        return result
Ejemplo n.º 5
0
    async def revoke(self, password, community):
        """
        Revoke self-identity on server, not in blockchain

        :param str password: The account SigningKey password
        :param sakia.core.community.Community community: The community target of the revokation
        """
        revoked = await self._identities_registry.future_find(self.pubkey, community)

        revokation = Revocation(PROTOCOL_VERSION, community.currency, None)
        selfcert = await revoked.selfcert(community)

        key = SigningKey(self.salt, password)
        revokation.sign(selfcert, [key])

        logging.debug("Self-Revokation Document : \n{0}".format(revokation.raw(selfcert)))
        logging.debug("Signature : \n{0}".format(revokation.signatures[0]))

        data = {
            'pubkey': revoked.pubkey,
            'self_': selfcert.signed_raw(),
            'sig': revokation.signatures[0]
        }
        logging.debug("Posted data : {0}".format(data))
        responses = await community.bma_access.broadcast(bma.wot.Revoke, {}, data)
        result = (False, "")
        for r in responses:
            if r.status == 200:
                result = (True, (await r.json()))
            elif not result[0]:
                result = (False, (await r.text()))
            else:
                await r.release()
        return result
def get_signed_raw_revocation_document(identity: Identity, salt: str, password: str) -> str:
    """
    Generate account revocation document for given identity

    :param identity: Self Certification of the identity
    :param salt: Salt
    :param password: Password

    :rtype: str
    """
    revocation = Revocation(PROTOCOL_VERSION, identity.currency, identity, "")

    key = SigningKey.from_credentials(salt, password)
    revocation.sign([key])
    return revocation.signed_raw()
Ejemplo n.º 7
0
    async def generate_revokation(self, community, password):
        """
        Generate account revokation document for given community
        :param sakia.core.Community community: the community
        :param str password: the password
        :return: the revokation document
        :rtype: duniterpy.documents.certification.Revocation
        """
        document = Revocation(PROTOCOL_VERSION, community.currency, self.pubkey, "")
        identity = await self.identity(community)
        selfcert = await identity.selfcert(community)

        key = SigningKey(self.salt, password)

        document.sign(selfcert, [key])
        return document.signed_raw(selfcert)
Ejemplo n.º 8
0
def get_signed_raw_revocation_document(identity: Identity, salt: str,
                                       password: str) -> str:
    """
    Generate account revocation document for given identity

    :param identity: Self Certification of the identity
    :param salt: Salt
    :param password: Password

    :rtype: str
    """
    revocation = Revocation(PROTOCOL_VERSION, identity.currency, identity, "")

    key = SigningKey.from_credentials(salt, password)
    revocation.sign([key])
    return revocation.signed_raw()
Ejemplo n.º 9
0
    async def generate_revokation(self, community, password):
        """
        Generate account revokation document for given community
        :param sakia.core.Community community: the community
        :param str password: the password
        :return: the revokation document
        :rtype: duniterpy.documents.certification.Revocation
        """
        document = Revocation(PROTOCOL_VERSION, community.currency, self.pubkey, "")
        identity = await self.identity(community)
        selfcert = await identity.selfcert(community)

        key = SigningKey(self.salt, password)

        document.sign(selfcert, [key])
        return document.signed_raw(selfcert)
Ejemplo n.º 10
0
async def get_revoke_document(identity, salt, password):
    """
    Generate account revocation document for given identity

    :param SelfCertification identity: Self Certification of the identity
    :param str salt: Salt
    :param str password: Password

    :return: the revokation document
    :rtype: duniterpy.documents.certification.Revocation
    """
    document = Revocation(PROTOCOL_VERSION, identity.currency, identity.pubkey,
                          "")

    key = SigningKey(salt, password)
    document.sign(identity, [key])
    return document.signed_raw(identity)
Ejemplo n.º 11
0
    def generate_revocation(self, connection, secret_key, password):
        """
        Generate account revocation document for given community

        :param sakia.data.entities.Connection connection: The connection of the identity
        :param str secret_key: The account SigningKey secret key
        :param str password: The account SigningKey password
        """
        document = Revocation(10, connection.currency, connection.pubkey, "")
        identity = self._identities_processor.get_identity(connection.currency, connection.pubkey, connection.uid)
        if not identity:
            identity = self.generate_identity(connection)
            identity_doc = identity.document()
            key = SigningKey(connection.salt, connection.password, connection.scrypt_params)
            identity_doc.sign([key])
            identity.signature = identity_doc.signatures[0]
            self._identities_processor.insert_or_update_identity(identity)

        self_cert = identity.document()

        key = SigningKey(secret_key, password, connection.scrypt_params)

        document.sign(self_cert, [key])
        return document.signed_raw(self_cert), identity