github.com/theQRL/go-zond@v0.2.1/cmd/clef/datatypes.md (about)

     1  ## UI Client interface
     2  
     3  These data types are defined in the channel between clef and the UI
     4  ### SignDataRequest
     5  
     6  SignDataRequest contains information about a pending request to sign some data. The data to be signed can be of various types, defined by content-type. Clef has done most of the work in canonicalizing and making sense of the data, and it's up to the UI to present the user with the contents of the `message`
     7  
     8  Example:
     9  ```json
    10  {
    11    "content_type": "text/plain",
    12    "address": "ZDEADbEeF000000000000000000000000DeaDbeEf",
    13    "raw_data": "GUV0aGVyZXVtIFNpZ25lZCBNZXNzYWdlOgoxMWhlbGxvIHdvcmxk",
    14    "messages": [
    15      {
    16        "name": "message",
    17        "value": "\u0019Zond Signed Message:\n11hello world",
    18        "type": "text/plain"
    19      }
    20    ],
    21    "hash": "0xd9eba16ed0ecae432b71fe008c98cc872bb4cc214d3220a36f365326cf807d68",
    22    "meta": {
    23      "remote": "localhost:9999",
    24      "local": "localhost:8545",
    25      "scheme": "http",
    26      "User-Agent": "Firefox 3.2",
    27      "Origin": "www.malicious.ru"
    28    }
    29  }
    30  ```
    31  ### SignDataResponse - approve
    32  
    33  Response to SignDataRequest
    34  
    35  Example:
    36  ```json
    37  {
    38    "approved": true
    39  }
    40  ```
    41  ### SignDataResponse - deny
    42  
    43  Response to SignDataRequest
    44  
    45  Example:
    46  ```json
    47  {
    48    "approved": false
    49  }
    50  ```
    51  ### SignTxRequest
    52  
    53  SignTxRequest contains information about a pending request to sign a transaction. Aside from the transaction itself, there is also a `call_info`-struct. That struct contains messages of various types, that the user should be informed of.
    54  
    55  As in any request, it's important to consider that the `meta` info also contains untrusted data.
    56  
    57  The `transaction` (on input into clef) can have either `data` or `input` -- if both are set, they must be identical, otherwise an error is generated. However, Clef will always use `data` when passing this struct on (if Clef does otherwise, please file a ticket)
    58  
    59  Example:
    60  ```json
    61  {
    62    "transaction": {
    63      "from": "ZDEADbEeF000000000000000000000000DeaDbeEf",
    64      "to": null,
    65      "gas": "0x3e8",
    66      "maxFeePerGas": "0x5",
    67      "maxPriorityFeePerGas": "0x0",
    68      "value": "0x6",
    69      "nonce": "0x1",
    70      "data": "0x01020304"
    71    },
    72    "call_info": [
    73      {
    74        "type": "Warning",
    75        "message": "Something looks odd, show this message as a warning"
    76      },
    77      {
    78        "type": "Info",
    79        "message": "User should see this as well"
    80      }
    81    ],
    82    "meta": {
    83      "remote": "localhost:9999",
    84      "local": "localhost:8545",
    85      "scheme": "http",
    86      "User-Agent": "Firefox 3.2",
    87      "Origin": "www.malicious.ru"
    88    }
    89  }
    90  ```
    91  ### SignTxResponse - approve
    92  
    93  Response to request to sign a transaction. This response needs to contain the `transaction`, because the UI is free to make modifications to the transaction.
    94  
    95  Example:
    96  ```json
    97  {
    98    "transaction": {
    99      "from": "ZDEADbEeF000000000000000000000000DeaDbeEf",
   100      "to": null,
   101      "gas": "0x3e8",
   102      "maxFeePerGas": "0x5",
   103      "maxPriorityFeePerGas": "0x0",
   104      "value": "0x6",
   105      "nonce": "0x4",
   106      "data": "0x04030201"
   107    },
   108    "approved": true
   109  }
   110  ```
   111  ### SignTxResponse - deny
   112  
   113  Response to SignTxRequest. When denying a request, there's no need to provide the transaction in return
   114  
   115  Example:
   116  ```json
   117  {
   118    "transaction": {
   119      "from": "Z",
   120      "to": null,
   121      "gas": "0x0",
   122      "maxFeePerGas": "0x0",
   123      "maxPriorityFeePerGas": "0x0",
   124      "value": "0x0",
   125      "nonce": "0x0",
   126      "data": null
   127    },
   128    "approved": false
   129  }
   130  ```
   131  ### OnApproved - SignTransactionResult
   132  
   133  SignTransactionResult is used in the call `clef` -> `OnApprovedTx(result)`
   134  
   135  This occurs _after_ successful completion of the entire signing procedure, but right before the signed transaction is passed to the external caller. This method (and data) can be used by the UI to signal to the user that the transaction was signed, but it is primarily useful for ruleset implementations.
   136  
   137  A ruleset that implements a rate limitation needs to know what transactions are sent out to the external interface. By hooking into this methods, the ruleset can maintain track of that count.
   138  
   139  **OBS:** Note that if an attacker can restore your `clef` data to a previous point in time (e.g through a backup), the attacker can reset such windows, even if he/she is unable to decrypt the content.
   140  
   141  The `OnApproved` method cannot be responded to, it's purely informative
   142  
   143  Example:
   144  ```json
   145  {
   146    "raw": "0xf85d640101948a8eafb1cf62bfbeb1741769dae1a9dd47996192018026a0716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293a04e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed",
   147    "tx": {
   148      "nonce": "0x64",
   149      "maxFeePerGas": "0x1",
   150      "maxPriorityFeePerGas": "0x0",
   151      "gas": "0x1",
   152      "to": "Z8a8eafb1cf62bfbeb1741769dae1a9dd47996192",
   153      "value": "0x1",
   154      "input": "0x",
   155      "signature": "0x716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293",
   156      "publicKey": "0x4e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed",
   157      "hash": "0x662f6d772692dd692f1b5e8baa77a9ff95bbd909362df3fc3d301aafebde5441"
   158    }
   159  }
   160  ```
   161  ### UserInputRequest
   162  
   163  Sent when clef needs the user to provide data. If 'password' is true, the input field should be treated accordingly (echo-free)
   164  
   165  Example:
   166  ```json
   167  {
   168    "prompt": "The question to ask the user",
   169    "title": "The title here",
   170    "isPassword": true
   171  }
   172  ```
   173  ### UserInputResponse
   174  
   175  Response to UserInputRequest
   176  
   177  Example:
   178  ```json
   179  {
   180    "text": "The textual response from user"
   181  }
   182  ```
   183  ### ListRequest
   184  
   185  Sent when a request has been made to list addresses. The UI is provided with the full `account`s, including local directory names. Note: this information is not passed back to the external caller, who only sees the `address`es.
   186  
   187  Example:
   188  ```json
   189  {
   190    "accounts": [
   191      {
   192        "address": "Zdeadbeef000000000000000000000000deadbeef",
   193        "url": "keystore:///path/to/keyfile/a"
   194      },
   195      {
   196        "address": "Z1111111122222222222233333333334444444444",
   197        "url": "keystore:///path/to/keyfile/b"
   198      }
   199    ],
   200    "meta": {
   201      "remote": "localhost:9999",
   202      "local": "localhost:8545",
   203      "scheme": "http",
   204      "User-Agent": "Firefox 3.2",
   205      "Origin": "www.malicious.ru"
   206    }
   207  }
   208  ```
   209  ### ListResponse
   210  
   211  Response to list request. The response contains a list of all addresses to show to the caller. Note: the UI is free to respond with any address the caller, regardless of whether it exists or not
   212  
   213  Example:
   214  ```json
   215  {
   216    "accounts": [
   217      {
   218        "address": "Z0000000000000000000000000000000000000000",
   219        "url": ".. ignored .."
   220      },
   221      {
   222        "address": "Zffffffffffffffffffffffffffffffffffffffff",
   223        "url": ""
   224      }
   225    ]
   226  }
   227  ```