{"action":"created","comment":{"url":"https://api.github.com/repos/monero-project/monero/pulls/comments/173974338","pull_request_review_id":103251309,"id":173974338,"diff_hunk":"@@ -0,0 +1,451 @@\n+// Copyright (c) 2018, The Monero Project\n+// \n+// All rights reserved.\n+// \n+// Redistribution and use in source and binary forms, with or without modification, are\n+// permitted provided that the following conditions are met:\n+// \n+// 1. Redistributions of source code must retain the above copyright notice, this list of\n+//    conditions and the following disclaimer.\n+// \n+// 2. Redistributions in binary form must reproduce the above copyright notice, this list\n+//    of conditions and the following disclaimer in the documentation and/or other\n+//    materials provided with the distribution.\n+// \n+// 3. Neither the name of the copyright holder nor the names of its contributors may be\n+//    used to endorse or promote products derived from this software without specific\n+//    prior written permission.\n+// \n+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY\n+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\n+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF\n+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+\n+#include <lmdb.h>\n+#include <boost/algorithm/string.hpp>\n+#include <boost/range/adaptor/transformed.hpp>\n+#include <boost/filesystem.hpp>\n+#include \"misc_log_ex.h\"\n+#include \"misc_language.h\"\n+#include \"wallet_errors.h\"\n+#include \"ringdb.h\"\n+\n+#undef MONERO_DEFAULT_LOG_CATEGORY\n+#define MONERO_DEFAULT_LOG_CATEGORY \"wallet.ringdb\"\n+\n+static const char zerokey[8] = {0};\n+static const MDB_val zerokeyval = { sizeof(zerokey), (void *)zerokey };\n+\n+static int compare_hash32(const MDB_val *a, const MDB_val *b)\n+{\n+  uint32_t *va = (uint32_t*) a->mv_data;\n+  uint32_t *vb = (uint32_t*) b->mv_data;\n+  for (int n = 7; n >= 0; n--)\n+  {\n+    if (va[n] == vb[n])\n+      continue;\n+    return va[n] < vb[n] ? -1 : 1;\n+  }\n+\n+  return 0;\n+}\n+\n+static std::string compress_ring(const std::vector<uint64_t> &ring)\n+{\n+  std::string s;\n+  for (uint64_t out: ring)\n+    s += tools::get_varint_data(out);\n+  return s;\n+}\n+\n+static std::vector<uint64_t> decompress_ring(const std::string &s)\n+{\n+  std::vector<uint64_t> ring;\n+  int read = 0;\n+  for (std::string::const_iterator i = s.begin(); i != s.cend(); std::advance(i, read))\n+  {\n+    uint64_t out;\n+    std::string tmp(i, s.cend());","path":"src/wallet/ringdb.cpp","position":73,"original_position":73,"commit_id":"691b8aeecb6b0173d2464bf9885ad5e29150fd8e","original_commit_id":"5e5f61c4b372a84f66212a786a7365c95a63ab18","user":{"login":"moneromooo-monero","id":8851073,"avatar_url":"https://avatars3.githubusercontent.com/u/8851073?v=4","gravatar_id":"","url":"https://api.github.com/users/moneromooo-monero","html_url":"https://github.com/moneromooo-monero","followers_url":"https://api.github.com/users/moneromooo-monero/followers","following_url":"https://api.github.com/users/moneromooo-monero/following{/other_user}","gists_url":"https://api.github.com/users/moneromooo-monero/gists{/gist_id}","starred_url":"https://api.github.com/users/moneromooo-monero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moneromooo-monero/subscriptions","organizations_url":"https://api.github.com/users/moneromooo-monero/orgs","repos_url":"https://api.github.com/users/moneromooo-monero/repos","events_url":"https://api.github.com/users/moneromooo-monero/events{/privacy}","received_events_url":"https://api.github.com/users/moneromooo-monero/received_events","type":"User","site_admin":false},"body":"and frankly getting one less string copy when there's I/O read next to it anyway isn't worth spending time on it so I'll leave it as is.","created_at":"2018-03-12T23:07:10Z","updated_at":"2018-03-12T23:07:10Z","html_url":"https://github.com/monero-project/monero/pull/3322#discussion_r173974338","pull_request_url":"https://api.github.com/repos/monero-project/monero/pulls/3322","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/monero-project/monero/pulls/comments/173974338"},"html":{"href":"https://github.com/monero-project/monero/pull/3322#discussion_r173974338"},"pull_request":{"href":"https://api.github.com/repos/monero-project/monero/pulls/3322"}},"in_reply_to_id":172745118},"pull_request":{"url":"https://api.github.com/repos/monero-project/monero/pulls/3322","id":171929457,"html_url":"https://github.com/monero-project/monero/pull/3322","diff_url":"https://github.com/monero-project/monero/pull/3322.diff","patch_url":"https://github.com/monero-project/monero/pull/3322.patch","issue_url":"https://api.github.com/repos/monero-project/monero/issues/3322","number":3322,"state":"open","locked":false,"title":"[RELEASE] Several mitigations for attacking privacy via key reusing forks","user":{"login":"moneromooo-monero","id":8851073,"avatar_url":"https://avatars3.githubusercontent.com/u/8851073?v=4","gravatar_id":"","url":"https://api.github.com/users/moneromooo-monero","html_url":"https://github.com/moneromooo-monero","followers_url":"https://api.github.com/users/moneromooo-monero/followers","following_url":"https://api.github.com/users/moneromooo-monero/following{/other_user}","gists_url":"https://api.github.com/users/moneromooo-monero/gists{/gist_id}","starred_url":"https://api.github.com/users/moneromooo-monero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moneromooo-monero/subscriptions","organizations_url":"https://api.github.com/users/moneromooo-monero/orgs","repos_url":"https://api.github.com/users/moneromooo-monero/repos","events_url":"https://api.github.com/users/moneromooo-monero/events{/privacy}","received_events_url":"https://api.github.com/users/moneromooo-monero/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-28T11:41:41Z","updated_at":"2018-03-12T23:07:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"530bd0b376fa3edaca4f44beb113ee54e41c629e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/monero-project/monero/pulls/3322/commits","review_comments_url":"https://api.github.com/repos/monero-project/monero/pulls/3322/comments","review_comment_url":"https://api.github.com/repos/monero-project/monero/pulls/comments{/number}","comments_url":"https://api.github.com/repos/monero-project/monero/issues/3322/comments","statuses_url":"https://api.github.com/repos/monero-project/monero/statuses/691b8aeecb6b0173d2464bf9885ad5e29150fd8e","head":{"label":"moneromooo-monero:detfake-master","ref":"detfake-master","sha":"691b8aeecb6b0173d2464bf9885ad5e29150fd8e","user":{"login":"moneromooo-monero","id":8851073,"avatar_url":"https://avatars3.githubusercontent.com/u/8851073?v=4","gravatar_id":"","url":"https://api.github.com/users/moneromooo-monero","html_url":"https://github.com/moneromooo-monero","followers_url":"https://api.github.com/users/moneromooo-monero/followers","following_url":"https://api.github.com/users/moneromooo-monero/following{/other_user}","gists_url":"https://api.github.com/users/moneromooo-monero/gists{/gist_id}","starred_url":"https://api.github.com/users/moneromooo-monero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moneromooo-monero/subscriptions","organizations_url":"https://api.github.com/users/moneromooo-monero/orgs","repos_url":"https://api.github.com/users/moneromooo-monero/repos","events_url":"https://api.github.com/users/moneromooo-monero/events{/privacy}","received_events_url":"https://api.github.com/users/moneromooo-monero/received_events","type":"User","site_admin":false},"repo":{"id":24294045,"name":"bitmonero","full_name":"moneromooo-monero/bitmonero","owner":{"login":"moneromooo-monero","id":8851073,"avatar_url":"https://avatars3.githubusercontent.com/u/8851073?v=4","gravatar_id":"","url":"https://api.github.com/users/moneromooo-monero","html_url":"https://github.com/moneromooo-monero","followers_url":"https://api.github.com/users/moneromooo-monero/followers","following_url":"https://api.github.com/users/moneromooo-monero/following{/other_user}","gists_url":"https://api.github.com/users/moneromooo-monero/gists{/gist_id}","starred_url":"https://api.github.com/users/moneromooo-monero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moneromooo-monero/subscriptions","organizations_url":"https://api.github.com/users/moneromooo-monero/orgs","repos_url":"https://api.github.com/users/moneromooo-monero/repos","events_url":"https://api.github.com/users/moneromooo-monero/events{/privacy}","received_events_url":"https://api.github.com/users/moneromooo-monero/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/moneromooo-monero/bitmonero","description":"Monero: the secure, private, untraceable cryptocurrency","fork":true,"url":"https://api.github.com/repos/moneromooo-monero/bitmonero","forks_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/forks","keys_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/keys{/key_id}","collaborators_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/teams","hooks_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/hooks","issue_events_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/issues/events{/number}","events_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/events","assignees_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/assignees{/user}","branches_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/branches{/branch}","tags_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/tags","blobs_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/git/refs{/sha}","trees_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/git/trees{/sha}","statuses_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/statuses/{sha}","languages_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/languages","stargazers_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/stargazers","contributors_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/contributors","subscribers_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/subscribers","subscription_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/subscription","commits_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/commits{/sha}","git_commits_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/git/commits{/sha}","comments_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/comments{/number}","issue_comment_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/issues/comments{/number}","contents_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/contents/{+path}","compare_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/compare/{base}...{head}","merges_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/merges","archive_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/downloads","issues_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/issues{/number}","pulls_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/pulls{/number}","milestones_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/milestones{/number}","notifications_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/labels{/name}","releases_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/releases{/id}","deployments_url":"https://api.github.com/repos/moneromooo-monero/bitmonero/deployments","created_at":"2014-09-21T15:04:04Z","updated_at":"2018-02-11T03:48:17Z","pushed_at":"2018-03-12T08:55:25Z","git_url":"git://github.com/moneromooo-monero/bitmonero.git","ssh_url":"git@github.com:moneromooo-monero/bitmonero.git","clone_url":"https://github.com/moneromooo-monero/bitmonero.git","svn_url":"https://github.com/moneromooo-monero/bitmonero","homepage":"https://getmonero.org","size":141993,"stargazers_count":12,"watchers_count":12,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":4,"open_issues":0,"watchers":12,"default_branch":"master"}},"base":{"label":"monero-project:master","ref":"master","sha":"e9f41e405f1f75533ef6e9d5adc76ba41dd29e8c","user":{"login":"monero-project","id":7450663,"avatar_url":"https://avatars2.githubusercontent.com/u/7450663?v=4","gravatar_id":"","url":"https://api.github.com/users/monero-project","html_url":"https://github.com/monero-project","followers_url":"https://api.github.com/users/monero-project/followers","following_url":"https://api.github.com/users/monero-project/following{/other_user}","gists_url":"https://api.github.com/users/monero-project/gists{/gist_id}","starred_url":"https://api.github.com/users/monero-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monero-project/subscriptions","organizations_url":"https://api.github.com/users/monero-project/orgs","repos_url":"https://api.github.com/users/monero-project/repos","events_url":"https://api.github.com/users/monero-project/events{/privacy}","received_events_url":"https://api.github.com/users/monero-project/received_events","type":"User","site_admin":false},"repo":{"id":19316619,"name":"monero","full_name":"monero-project/monero","owner":{"login":"monero-project","id":7450663,"avatar_url":"https://avatars2.githubusercontent.com/u/7450663?v=4","gravatar_id":"","url":"https://api.github.com/users/monero-project","html_url":"https://github.com/monero-project","followers_url":"https://api.github.com/users/monero-project/followers","following_url":"https://api.github.com/users/monero-project/following{/other_user}","gists_url":"https://api.github.com/users/monero-project/gists{/gist_id}","starred_url":"https://api.github.com/users/monero-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monero-project/subscriptions","organizations_url":"https://api.github.com/users/monero-project/orgs","repos_url":"https://api.github.com/users/monero-project/repos","events_url":"https://api.github.com/users/monero-project/events{/privacy}","received_events_url":"https://api.github.com/users/monero-project/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/monero-project/monero","description":"Monero: the secure, private, untraceable cryptocurrency","fork":false,"url":"https://api.github.com/repos/monero-project/monero","forks_url":"https://api.github.com/repos/monero-project/monero/forks","keys_url":"https://api.github.com/repos/monero-project/monero/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monero-project/monero/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monero-project/monero/teams","hooks_url":"https://api.github.com/repos/monero-project/monero/hooks","issue_events_url":"https://api.github.com/repos/monero-project/monero/issues/events{/number}","events_url":"https://api.github.com/repos/monero-project/monero/events","assignees_url":"https://api.github.com/repos/monero-project/monero/assignees{/user}","branches_url":"https://api.github.com/repos/monero-project/monero/branches{/branch}","tags_url":"https://api.github.com/repos/monero-project/monero/tags","blobs_url":"https://api.github.com/repos/monero-project/monero/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monero-project/monero/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monero-project/monero/git/refs{/sha}","trees_url":"https://api.github.com/repos/monero-project/monero/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monero-project/monero/statuses/{sha}","languages_url":"https://api.github.com/repos/monero-project/monero/languages","stargazers_url":"https://api.github.com/repos/monero-project/monero/stargazers","contributors_url":"https://api.github.com/repos/monero-project/monero/contributors","subscribers_url":"https://api.github.com/repos/monero-project/monero/subscribers","subscription_url":"https://api.github.com/repos/monero-project/monero/subscription","commits_url":"https://api.github.com/repos/monero-project/monero/commits{/sha}","git_commits_url":"https://api.github.com/repos/monero-project/monero/git/commits{/sha}","comments_url":"https://api.github.com/repos/monero-project/monero/comments{/number}","issue_comment_url":"https://api.github.com/repos/monero-project/monero/issues/comments{/number}","contents_url":"https://api.github.com/repos/monero-project/monero/contents/{+path}","compare_url":"https://api.github.com/repos/monero-project/monero/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monero-project/monero/merges","archive_url":"https://api.github.com/repos/monero-project/monero/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monero-project/monero/downloads","issues_url":"https://api.github.com/repos/monero-project/monero/issues{/number}","pulls_url":"https://api.github.com/repos/monero-project/monero/pulls{/number}","milestones_url":"https://api.github.com/repos/monero-project/monero/milestones{/number}","notifications_url":"https://api.github.com/repos/monero-project/monero/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monero-project/monero/labels{/name}","releases_url":"https://api.github.com/repos/monero-project/monero/releases{/id}","deployments_url":"https://api.github.com/repos/monero-project/monero/deployments","created_at":"2014-04-30T14:38:28Z","updated_at":"2018-03-12T16:13:05Z","pushed_at":"2018-03-12T18:49:57Z","git_url":"git://github.com/monero-project/monero.git","ssh_url":"git@github.com:monero-project/monero.git","clone_url":"https://github.com/monero-project/monero.git","svn_url":"https://github.com/monero-project/monero","homepage":"https://getmonero.org","size":137911,"stargazers_count":2657,"watchers_count":2657,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1210,"mirror_url":null,"archived":false,"open_issues_count":205,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1210,"open_issues":205,"watchers":2657,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/monero-project/monero/pulls/3322"},"html":{"href":"https://github.com/monero-project/monero/pull/3322"},"issue":{"href":"https://api.github.com/repos/monero-project/monero/issues/3322"},"comments":{"href":"https://api.github.com/repos/monero-project/monero/issues/3322/comments"},"review_comments":{"href":"https://api.github.com/repos/monero-project/monero/pulls/3322/comments"},"review_comment":{"href":"https://api.github.com/repos/monero-project/monero/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/monero-project/monero/pulls/3322/commits"},"statuses":{"href":"https://api.github.com/repos/monero-project/monero/statuses/691b8aeecb6b0173d2464bf9885ad5e29150fd8e"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"moneromooo-monero"}}