dyne / restroom-mw

🛠 Easy REST API builder executing Zencode
https://restroom.dyne.org
GNU Affero General Public License v3.0
3 stars 11 forks source link

Restroom lets stuff.keys override stuff passed via REST #34

Closed andrea-dintino closed 2 years ago

andrea-dintino commented 3 years ago

Situation:

In Restroom-mw, I have:

script.zen

rule check version 1.0.0
Scenario 'ecdh': Bob verifies the signature from Alice
Given I have a 'public key' from 'Alice'
Given I have a 'string' named 'myMessage'
Given I have a 'signature' named 'myMessage.signature'
When I verify the 'myMessage' has a signature in 'myMessage.signature' by 'Alice'
Then print 'Zenroom certifies that signatures are all correct!' as 'string'
Then print the 'myMessage'

And a script.keys files that contains just {}

Then I pass via REST this data in the keys{} parameter


{
  "data": {},
  "keys": {"myMessage": "Dear Bob, your name is too short, goodbye - Alice.",
    "myMessage.signature": {
        "r": "vWerszPubruWexUib69c7IU8Dxy1iisUmMGC7h7arDw=",
        "s": "nSjxT+JAP56HMRJjrLwwB6kP+mluYySeZcG8JPBGcpY="
    },
    "Alice": {
        "public_key": "BBCQg21VcjsmfTmNsg+I+8m1Cm0neaYONTqRnXUjsJLPa8075IYH+a9w2wRO7rFM1cKmv19Igd7ntDZcUvLq3xI="
    }}
}

And I get this error:

{
  "zenroom_errors": {
    "result": "",
    "logs": " .  System memory manager in use\n .  ECDH curve is SECP256K1\n .  Memory in use: 300 KB\n .  Zencode version match: 1.0.0+d38b84d .  rule check version 1.0.0 [W] Given I have a 'public key' from 'Alice'\t2[W]  .  Scenario 'ecdh'[W]  .  Given I have a 'public key' from 'Alice'[W]  .  ERR Cannot find 'public_key' inside 'Alice'[W]  .  \u001b[31;1m[!]\u001b[0m /zencode_given.lua:191: Cannot find 'public_key' inside 'Alice'[W] {\n    a_GIVEN_in = {\n        KEYS = {\n            [\"\"] = \"\"\n        }\n    },\n    b_WHEN_ack = {},\n    c_THEN_out = {}\n}[!] Zencode execution error\n[!] Script:\nZEN:begin()\nZEN:parse([[\nrule check version 1.0.0 \nScenario 'ecdh': Bob verifies the signature from Alice \n Given I have a 'public key' from 'Alice' \nGiven I have a 'string' named 'myMessage' \nGiven I have a 'signature' named 'myMessage.signature' \nWhen I verify the 'myMessage' has a signature in 'myMessage.signature' by 'Alice' \nThen print 'Zenroom certifies that signatures are all correct!' as 'string' \nThen print the 'myMessage' \n\n]])\nZEN:run()\n\n[!] /zencode.lua:285:  Given I have a 'public key' from 'Alice' \n[!] Error detected. Execution aborted.\n[*] Zenroom teardown.\n .  Memory used: 335 KB\n"
  },
  "result": "",
  "exception": "[ZENROOM EXECUTION ERROR]\n\n\nundefined"
}

I guess that Restroom-mw overrides the data passed via REST with the stuff stored in the script.keys? Is this is a feature or a bug?

Update: actually Restroom-mw does NOT read any data passed via REST as keys{} parameter.

<3