code: def test_rsa_signature_validator():
      receiver_validator = RSASignatureValidator()
      sender_validator = RSASignatureValidator(RSAPrivateKey())
      mallory_validator = RSASignatureValidator(RSAPrivateKey())
  
      plain_record = DHTRecord(
          key=b"key",
          subkey=b"subkey",
          value=b"value",
          expiration_time=get_dht_time() + 10,
      )
      protected_records = [
          dataclasses.replace(
              plain_record,
              key=plain_record.key + sender_validator.local_public_key,
          ),
          dataclasses.replace(
              plain_record,
              subkey=plain_record.subkey
              + sender_validator.local_public_key,
          ),
      ]
  
      # test 1: Non-protected record (no signature added)
      assert (
          sender_validator.sign_value(plain_record)
          == plain_record.value
      )
      assert receiver_validator.validate(plain_record)
  
      # test 2: Correct signatures
      signed_records = [
          dataclasses.replace(
              record, value=sender_validator.sign_value(record)
          )
          for record in protected_records
      ]
      for record in signed_records:
          assert receiver_validator.validate(record)
          assert receiver_validator.strip_value(record) == b"value"
  
      # test 3: Invalid signatures
      signed_records = protected_records  # Without signature
      signed_records += [
          dataclasses.replace(
              record, value=record.value + b"[signature:INVALID_BYTES]"
          )
          for record in protected_records
      ]  # With invalid signature
      signed_records += [
          dataclasses.replace(
              record, value=mallory_validator.sign_value(record)
          )
          for record in protected_records
      ]  # With someone else's signature
      for record in signed_records:
          assert not receiver_validator.validate(record)
  
file_path: hivemind/tests/test_dht_crypto.py
imports: import dataclasses
  import multiprocessing
  import pickle
  import pytest
  import hivemind
  from hivemind.dht.crypto import RSASignatureValidator
  from hivemind.dht.node import DHTNode
  from hivemind.dht.validation import DHTRecord
  from hivemind.utils.crypto import RSAPrivateKey
  from hivemind.utils.timed_storage import get_dht_time
label_desc: Use image node_id 1 for calling a global function with example usage: test_rsa_signature_validator() without return types