Title: Sometimes sendClassical changes a msg from one thing into another thing · Issue #59 · SoftwareQuTech/CQC-Python · GitHub
Open Graph Title: Sometimes sendClassical changes a msg from one thing into another thing · Issue #59 · SoftwareQuTech/CQC-Python
X Title: Sometimes sendClassical changes a msg from one thing into another thing · Issue #59 · SoftwareQuTech/CQC-Python
Description: Say Alice calls sendClassical with msg = b'01' (= two bytes, first character 0 = ASCII 48, second character 1 = ASCII 49). When Bob calls recvClassical it receives a different msg = b'\x01' (= one byte, value 1). This is because of the f...
Open Graph Description: Say Alice calls sendClassical with msg = b'01' (= two bytes, first character 0 = ASCII 48, second character 1 = ASCII 49). When Bob calls recvClassical it receives a different msg = b'\x01' (= one ...
X Description: Say Alice calls sendClassical with msg = b'01' (= two bytes, first character 0 = ASCII 48, second character 1 = ASCII 49). When Bob calls recvClassical it receives a different msg = b'\...
Opengraph URL: https://github.com/SoftwareQuTech/CQC-Python/issues/59
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Sometimes sendClassical changes a msg from one thing into another thing","articleBody":"Say Alice calls sendClassical with msg = b'01' (= two bytes, first character 0 = ASCII 48, second character 1 = ASCII 49).\r\n\r\nWhen Bob calls recvClassical it receives a different msg = b'\\x01' (= one byte, value 1).\r\n\r\nThis is because of the following piece of code:\r\n\r\n try:\r\n to_send = bytes([int(msg)])\r\n except (TypeError, ValueError):\r\n to_send = bytes(msg)\r\n\r\nYou can see that:\r\n\r\n \u003e\u003e\u003e msg = b'01'\r\n \u003e\u003e\u003e bytes([int(msg)])\r\n b'\\x01'\r\n\r\nThe better approach would be something along the lines of:\r\n\r\n if isinstance(msg, bytes):\r\n # Already provided as bytes, nothing to do\r\n else:\r\n # Provided as something else than bytes, convert to bytes\r\n\r\nAnd even that is not ideal, because there are still corner cases where the receiver gets something different than the sender sent.\r\n\r\nA better option could be to use pickle to serialize messages on-the-wire.\r\n\r\nI know it is \"not safe\" to unpickle messages received on-the-wire from an untrusted source, but it's probably good enough for simulations.\r\n\r\nThe pickling and unpickling could be done inside sendClassical and recvClassical, or the burden could be put on the application and sendClassical and recvClassical could insist on only getting messages of type bytes.\r\n\r\nThe former is more convenient for the application, the latter gives the application their own choice of serialization method (including the option of using something more safe than pickle).\r\n\r\n@AckslD Feel free to assign to me. I can fix the issue and generate a pull request.","author":{"url":"https://github.com/brunorijsman","@type":"Person","name":"brunorijsman"},"datePublished":"2019-12-06T14:05:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/59/CQC-Python/issues/59"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:528bfd76-750c-f1bb-a9c7-8eb6b168aab9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA16:146F00:AD808:EAE41:6981B5FF |
| html-safe-nonce | 110f1f017f2c9b4911cb2f9b50c4412390988898162a30ce24adb9565731c7f8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTE2OjE0NkYwMDpBRDgwODpFQUU0MTo2OTgxQjVGRiIsInZpc2l0b3JfaWQiOiI2MTg5MjU1MzA1MDQ2NjM2MDMxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6ee8ed8dea388cf20663dcb6b0010fa4b575ae26eedaac33949a059991fd7ae8 |
| hovercard-subject-tag | issue:534010420 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/SoftwareQuTech/CQC-Python/59/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ed2e438fd85e1ca5cd891b1f2ae95246f83f568f95e9ec85b7f910d6fa183428/SoftwareQuTech/CQC-Python/issues/59 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ed2e438fd85e1ca5cd891b1f2ae95246f83f568f95e9ec85b7f910d6fa183428/SoftwareQuTech/CQC-Python/issues/59 |
| og:image:alt | Say Alice calls sendClassical with msg = b'01' (= two bytes, first character 0 = ASCII 48, second character 1 = ASCII 49). When Bob calls recvClassical it receives a different msg = b'\x01' (= one ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | brunorijsman |
| hostname | github.com |
| expected-hostname | github.com |
| None | e137814e266030874fd2c86863529d0622b13889eeda04148c57654b6ea84ad6 |
| turbo-cache-control | no-preview |
| go-import | github.com/SoftwareQuTech/CQC-Python git https://github.com/SoftwareQuTech/CQC-Python.git |
| octolytics-dimension-user_id | 43809204 |
| octolytics-dimension-user_login | SoftwareQuTech |
| octolytics-dimension-repository_id | 177956316 |
| octolytics-dimension-repository_nwo | SoftwareQuTech/CQC-Python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 177956316 |
| octolytics-dimension-repository_network_root_nwo | SoftwareQuTech/CQC-Python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | dd58d68a7813bbec9c91422c8c35f4af33832d70 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width