{"action":"created","issue":{"url":"https://api.github.com/repos/ugorji/go/issues/93","labels_url":"https://api.github.com/repos/ugorji/go/issues/93/labels{/name}","comments_url":"https://api.github.com/repos/ugorji/go/issues/93/comments","events_url":"https://api.github.com/repos/ugorji/go/issues/93/events","html_url":"https://github.com/ugorji/go/issues/93","id":101529984,"number":93,"title":"cbor encoding fails to produce equal buffers (with canonical = true)?","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-17T23:24:29Z","updated_at":"2015-08-18T23:06:13Z","closed_at":"2015-08-18T21:42:53Z","body":"I have a few cases where cbor encoding fails to produce the exact same output with `h.Canonical = true`. \r\n\r\nPlease see https://github.com/jbenet/test-ugorji-cbor\r\n\r\nSetup:\r\n\r\n- some test maps\r\n- a roundtrip function that compares the two cbor bufs in a roundtrip:\r\n\r\n    ```\r\n    go map -> cbor buf 1 -> go map 2 -> cbor buf 2\r\n    bytes.Equal(cbor buf 1, cbor buf 2)\r\n    ```\r\n- buffers not equal, even though `h.Canonical = true`\r\n- deep equals on maps fails too, not sure why (probably has to do with map types stuff)\r\n\r\nOutput: \r\n```\r\n> go test\r\n--- FAIL: TestRoundtripBasic (0.00s)\r\n    rt_test.go:42: marshalled values not equal\r\n    rt_test.go:43: [163 97 97 1 97 98 101 104 101 108 108 111 97 99 164 99 99 47 97 1 99 99 47 98 101 119 111 114 108 100 99 99 47 99 132 1 2 3 4 99 99 47 100 166 101 99 47 100 47 97 120 32 102 100 105 115 97 106 102 111 105 100 115 97 106 102 111 112 100 106 115 97 111 112 102 106 100 115 97 112 111 102 100 97 101 99 47 100 47 98 120 56 102 100 115 97 102 106 100 112 111 115 97 107 102 111 100 112 115 97 107 102 111 112 100 115 97 107 102 112 111 100 115 97 107 102 112 111 100 107 115 97 111 112 102 107 100 115 111 112 97 102 107 100 111 112 115 97 101 99 47 100 47 99 120 66 112 111 105 114 48 50 32 32 105 114 51 48 113 105 102 52 112 48 51 113 105 114 48 112 111 103 106 102 112 111 97 101 114 102 103 106 112 32 111 102 107 101 91 112 97 100 102 107 91 101 119 97 112 102 32 107 100 112 91 97 102 101 112 91 97 119 101 99 47 100 47 100 120 61 102 100 115 111 112 97 102 107 100 91 115 97 32 102 45 51 50 113 111 114 45 61 52 113 101 111 102 32 45 97 102 111 45 101 114 102 111 32 114 45 101 97 102 111 32 52 101 45 32 32 111 32 114 52 45 113 119 111 32 97 103 101 99 47 100 47 101 120 76 107 102 101 112 91 97 32 115 102 107 114 48 91 112 97 102 91 97 32 102 111 101 45 91 119 113 32 32 101 119 112 102 97 111 45 113 32 114 111 51 45 113 32 114 111 45 52 113 111 102 52 45 113 111 114 32 51 45 101 32 111 114 102 107 114 111 112 122 106 98 118 111 105 115 100 98 101 99 47 100 47 102 96]\r\n    rt_test.go:44: [163 97 97 1 97 98 101 104 101 108 108 111 97 99 164 99 99 47 100 166 101 99 47 100 47 98 120 56 102 100 115 97 102 106 100 112 111 115 97 107 102 111 100 112 115 97 107 102 111 112 100 115 97 107 102 112 111 100 115 97 107 102 112 111 100 107 115 97 111 112 102 107 100 115 111 112 97 102 107 100 111 112 115 97 101 99 47 100 47 99 120 66 112 111 105 114 48 50 32 32 105 114 51 48 113 105 102 52 112 48 51 113 105 114 48 112 111 103 106 102 112 111 97 101 114 102 103 106 112 32 111 102 107 101 91 112 97 100 102 107 91 101 119 97 112 102 32 107 100 112 91 97 102 101 112 91 97 119 101 99 47 100 47 100 120 61 102 100 115 111 112 97 102 107 100 91 115 97 32 102 45 51 50 113 111 114 45 61 52 113 101 111 102 32 45 97 102 111 45 101 114 102 111 32 114 45 101 97 102 111 32 52 101 45 32 32 111 32 114 52 45 113 119 111 32 97 103 101 99 47 100 47 101 120 76 107 102 101 112 91 97 32 115 102 107 114 48 91 112 97 102 91 97 32 102 111 101 45 91 119 113 32 32 101 119 112 102 97 111 45 113 32 114 111 51 45 113 32 114 111 45 52 113 111 102 52 45 113 111 114 32 51 45 101 32 111 114 102 107 114 111 112 122 106 98 118 111 105 115 100 98 101 99 47 100 47 102 96 101 99 47 100 47 97 120 32 102 100 105 115 97 106 102 111 105 100 115 97 106 102 111 112 100 106 115 97 111 112 102 106 100 115 97 112 111 102 100 97 99 99 47 97 1 99 99 47 98 101 119 111 114 108 100 99 99 47 99 132 1 2 3 4]\r\nFAIL\r\nexit status 1\r\nFAIL    _/tmp/testcanonical 0.012s\r\n```\r\n\r\nany help much appreciated, as we'd like to use cbor but need output buffers to be equal for cryptographic protocols to work at all."},"comment":{"url":"https://api.github.com/repos/ugorji/go/issues/comments/132386941","html_url":"https://github.com/ugorji/go/issues/93#issuecomment-132386941","issue_url":"https://api.github.com/repos/ugorji/go/issues/93","id":132386941,"user":{"login":"ugorji","id":1222082,"avatar_url":"https://avatars.githubusercontent.com/u/1222082?v=3","gravatar_id":"","url":"https://api.github.com/users/ugorji","html_url":"https://github.com/ugorji","followers_url":"https://api.github.com/users/ugorji/followers","following_url":"https://api.github.com/users/ugorji/following{/other_user}","gists_url":"https://api.github.com/users/ugorji/gists{/gist_id}","starred_url":"https://api.github.com/users/ugorji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ugorji/subscriptions","organizations_url":"https://api.github.com/users/ugorji/orgs","repos_url":"https://api.github.com/users/ugorji/repos","events_url":"https://api.github.com/users/ugorji/events{/privacy}","received_events_url":"https://api.github.com/users/ugorji/received_events","type":"User","site_admin":false},"created_at":"2015-08-18T23:06:13Z","updated_at":"2015-08-18T23:06:13Z","body":"Dude! Relax. Your #3 was totally unnecessary, and frankly deserves an apology!"}}