class_docstr: Implementation for experiment payload builder
  using public key RSA encryption.
class_docstr_tok: ["Implementation","for","experiment","payload","builder","using","public","key","RSA","encryption","."]
code: def construct(self, experiment, config, packages):
      unencrypted_payload = self.simple_builder.construct(
          experiment, config, packages
      )
      unencrypted_payload_str = json.dumps(unencrypted_payload)
  
      # Construct payload template:
      encrypted_payload = {
          "message": {
              "experiment": {
                  "status": "unknown",
                  "pythonver": "unknown",
              },
              "time_added": None,
              "experiment_lifetime": "unknown",
              "resources_needed": None,
              "payload": "None",
          }
      }
  
      # Now fill it up with experiment properties:
      enc_key, enc_payload = self._encrypt_str(unencrypted_payload_str)
  
      encrypted_payload["message"]["experiment"][
          "status"
      ] = experiment.status
      encrypted_payload["message"]["experiment"][
          "pythonver"
      ] = experiment.pythonver
      encrypted_payload["message"]["time_added"] = experiment.time_added
      encrypted_payload["message"][
          "experiment_lifetime"
      ] = experiment.max_duration
      encrypted_payload["message"][
          "resources_needed"
      ] = experiment.resources_needed
      encrypted_payload["message"]["payload"] = "{0},{1}".format(
          enc_key.decode("utf-8"), enc_payload.decode("utf-8")
      )
      if self.sender_key is not None:
          # Generate sender/workload signature:
          final_payload = encrypted_payload["message"]["payload"]
          payload_signature = self._sign_payload(
              final_payload.encode("utf-8")
          )
          encrypted_payload["message"]["signature"] = "{0}".format(
              payload_signature.decode("utf-8")
          )
          encrypted_payload["message"]["fingerprint"] = "{0}".format(
              self.sender_fingerprint
          )
  
      # print(json.dumps(encrypted_payload, indent=4))
  
      return encrypted_payload
  
imports: from Crypto.PublicKey import RSA
  from Crypto.Cipher import PKCS1_OAEP
  from Crypto.Hash import SHA256
  import nacl.secret
  import nacl.utils
  from nacl.signing import SigningKey, VerifyKey
  import base64
  import json
  from sshpubkeys import SSHKey
  from studio.ed25519_key_util import Ed25519KeyUtil
  from studio.payload_builders.payload_builder import PayloadBuilder
  from studio.util import logs
  from studio.payload_builders.unencrypted_payload_builder import UnencryptedPayloadBuilder
  from studio.util.util import check_for_kb_interrupt
label_desc: Use image node_id 10 for calling the EncryptedPayloadBuilder obj's underlying member method code with example usage: obj.construct(experiment, config, packages) and returns: encrypted_payload