Ejemplo n.º 1
0
def test_to_json(message):
    result = Message(**message['data'])
    json_data = result.to_json()
    data = json.loads(json_data)
    assert data['signature'] == message['data']['signature']
    assert data['public_key'] == message['data']['public_key']
    assert data['message'] == message['data']['message']
Ejemplo n.º 2
0
 def verify(self):
     """Verify the transaction. Method will raise an exception if invalid, if it's valid nothing
     will happen.
     """
     transaction = self.to_bytes()
     message = Message(transaction, self.signature, self.senderPublicKey)
     is_valid = message.verify()
     if not is_valid:
         raise ArkInvalidTransaction('Transaction could not be verified')
Ejemplo n.º 3
0
    def second_verify(self, passphrase):
        """Verify the transaction using the 2nd passphrase

        Args:
            passphrase (str): 2nd passphrase associated with the account sending this transaction
        """
        transaction = sha256(self.to_bytes()).digest()
        message = Message(transaction, self.signSignature,
                          self.senderPublicKey)
        is_valid = message.verify()
        if not is_valid:
            raise ArkInvalidTransaction('Transaction could not be verified')
Ejemplo n.º 4
0
    def second_sign(self, passphrase):
        """Sign the transaction using the given second passphrase

        Args:
            passphrase (str): 2nd passphrase associated with the account sending this transaction
        """
        message = Message.sign(self.transaction.to_bytes(skip_signature=False), passphrase)
        self.transaction.signSignature = message.signature
        self.transaction.id = self.transaction.get_id()
Ejemplo n.º 5
0
    def sign(self, passphrase):
        """Sign the transaction using the given passphrase

        Args:
            passphrase (str): passphrase associated with the account sending this transaction
        """
        self.transaction.senderPublicKey = PublicKey.from_passphrase(passphrase)
        message = Message.sign(self.transaction.to_bytes(), passphrase)
        self.transaction.signature = message.signature
        self.transaction.id = self.transaction.get_id()
Ejemplo n.º 6
0
def test_signing(message):
    result = Message.sign(message['data']['message'], message['passphrase'])
    assert result.to_dict() == message['data']
Ejemplo n.º 7
0
def test_to_dict(message):
    result = Message(**message['data'])
    assert result.to_dict() == message['data']
Ejemplo n.º 8
0
def test_verify(message):
    result = Message(**message['data'])
    assert result.verify() is True
Ejemplo n.º 9
0
def test_to_dict(message):
    result = Message(**message['camelCase_pk'])
    assert result.to_dict() == message['camelCase_pk']
Ejemplo n.º 10
0
def test_verify_with_publicKey(message):
    result = Message(**message['camelCase_pk'])
    assert result.verify() is True
Ejemplo n.º 11
0
def test_verify_with_publickey(message):
    result = Message(**message['snake_case_pk'])
    assert result.verify() is True