{
  "title": "Password Provider Demo",
  "description": "Script that will use password providers to encrypt and decrypt data using by default password a CIP8 signature with current wallet address",
  "type": "script",
  "return": {
    "mode": "some",
    "keys": [
      "modal"
    ]
  },
  "exportAs": "PasswordProviderDemo",
  "run": {
    "sealToSign": {
      "type": "data",
      "value": "PasswordProviderDemo"
    },
    "dataToEncrypt": {
      "type": "data",
      "value": "Hello world of encryption!"
    },
    "address": {
      "type": "getCurrentAddress"
    },
    "sign": {
      "type": "signDataWithAddress",
      "address": "{get('cache.address')}",
      "dataHex": "{strToHex(get('cache.sealToSign'))}"
    },
    "modal": {
      "type": "script",
      "return": {
        "mode": "some",
        "keys": [
          "encrypt",
          "decrypt"
        ]
      },
      "run": {
        "encrypt": {
          "type": "encrypt",
          "requirePassword": {
            "kind": "modal",
            "description": "A password is required to encrypt this data.\n By default your password is a CIP8 signature\n using your current address to sign.\n\n It's recomended to accept the suggested password.",
            "weak": true,
            "default": "{get('cache.sign.signature')}"
          },
          "messageHex": "{strToHex(get('cache.dataToEncrypt'))}"
        },
        "_decrypt": {
          "type": "decrypt",
          "requirePassword": {
            "kind": "modal",
            "description": "Use the previous password to decrypt the encrypted message",
            "weak": true,
            "default": "{get('cache.sign.signature')}"
          },
          "encryptedMessageHex": "{get('cache.modal.encrypt')}"
        },
        "decrypt": {
          "type": "macro",
          "run": "{hexToStr(get('cache.modal._decrypt'))}"
        }
      }
    }
  }
}