Beispiel #1
0
def get_identity_document(current_block, uid, salt, password):
    """
    Get an Identity document

    :param dict current_block: Current block data
    :param str uid: Unique Identifier
    :param str salt: Passphrase of the account
    :param str password: Password of the account

    :rtype: Identity
    """

    # get current block BlockStamp
    timestamp = BlockUID(current_block['number'], current_block['hash'])

    # create keys from credentials
    key = SigningKey(salt, password, ScryptParams(4096, 16, 1))

    # create identity document
    identity = Identity(version=10,
                        currency=current_block['currency'],
                        pubkey=key.pubkey,
                        uid=uid,
                        ts=timestamp,
                        signature=None)

    # sign document
    identity.sign([key])

    return identity
def get_identity_document(
    current_block: dict,
    uid: str,
    key: SigningKey,
) -> Identity:
    """
    Get an Identity document

    :param current_block: Current block data
    :param uid: Unique IDentifier
    :param key: cryptographic key to sign documents

    :rtype: Identity
    """

    # get current block BlockStamp
    timestamp = BlockUID(current_block["number"], current_block["hash"])

    # create identity document
    identity = Identity(
        version=10,
        currency=current_block["currency"],
        pubkey=key.pubkey,
        uid=uid,
        ts=timestamp,
        signature=None,
    )

    # sign document
    identity.sign([key])

    return identity
def get_identity_document(current_block: dict, uid: str, salt: str, password: str) -> Identity:
    """
    Get an Identity document

    :param current_block: Current block data
    :param uid: Unique Identifier
    :param salt: Passphrase of the account
    :param password: Password of the account

    :rtype: Identity
    """

    # get current block BlockStamp
    timestamp = BlockUID(current_block['number'], current_block['hash'])

    # create keys from credentials
    key = SigningKey.from_credentials(salt, password)

    # create identity document
    identity = Identity(
        version=10,
        currency=current_block['currency'],
        pubkey=key.pubkey,
        uid=uid,
        ts=timestamp,
        signature=None
    )

    # sign document
    identity.sign([key])

    return identity
Beispiel #4
0
    async def broadcast_identity(self, connection, secret_key, password):
        """
        Send our self certification to a target community

        :param sakia.data.entities.Connection connection: the connection published
        :param str secret_key: the private key secret key
        :param str password: the private key password
        """
        block_uid = self._blockchain_processor.current_buid(
            connection.currency)
        timestamp = self._blockchain_processor.time(connection.currency)
        selfcert = IdentityDoc(10, connection.currency, connection.pubkey,
                               connection.uid, block_uid, None)
        key = SigningKey(secret_key, password, connection.scrypt_params)
        selfcert.sign([key])
        self._logger.debug("Key publish : {0}".format(selfcert.signed_raw()))

        responses = await self._bma_connector.broadcast(
            connection.currency,
            bma.wot.add,
            req_args={'identity': selfcert.signed_raw()})
        result = await parse_bma_responses(responses)

        if result[0]:
            identity = self._identities_processor.get_identity(
                connection.currency, connection.pubkey, connection.uid)
            if not identity:
                identity = Identity(connection.currency, connection.pubkey,
                                    connection.uid)
            identity.blockstamp = block_uid
            identity.signature = selfcert.signatures[0]
            identity.timestamp = timestamp
        else:
            identity = None

        return result, identity
Beispiel #5
0
    def identity(self):
        identity = Identity(10, self.currency, self.key.pubkey, self.uid,
                            self.blockstamp, [])
        identity.sign([self.key])

        return identity