{"action":"created","comment":{"url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/comments/231915797","pull_request_review_id":172992180,"id":231915797,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMTkxNTc5Nw==","diff_hunk":"@@ -126,30 +126,50 @@ static void secp256k1_ge_set_gej_var(secp256k1_ge *r, secp256k1_gej *a) {\n     r->y = a->y;\n }\n \n-static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a, size_t len, const secp256k1_callback *cb) {\n-    secp256k1_fe *az;\n-    secp256k1_fe *azi;\n+static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a, size_t len) {\n+    secp256k1_fe u;\n     size_t i;\n-    size_t count = 0;\n-    az = (secp256k1_fe *)checked_malloc(cb, sizeof(secp256k1_fe) * len);\n+    size_t last_i = SIZE_MAX;\n+    size_t first_i = SIZE_MAX;\n+\n     for (i = 0; i < len; i++) {\n         if (!a[i].infinity) {\n-            az[count++] = a[i].z;\n+            /* Use destination's x coordinates as scratch space */\n+            if (last_i == SIZE_MAX) {\n+                r[i].x = a[i].z;\n+                first_i = last_i = i;\n+            } else {\n+                secp256k1_fe_mul(&r[i].x, &r[last_i].x, &a[i].z);\n+                last_i = i;\n+            }\n         }\n     }\n+    if (last_i == SIZE_MAX) {\n+        return;\n+    }\n+    secp256k1_fe_inv_var(&u, &r[last_i].x);\n \n-    azi = (secp256k1_fe *)checked_malloc(cb, sizeof(secp256k1_fe) * count);\n-    secp256k1_fe_inv_all_var(azi, az, count);\n-    free(az);\n+    i = last_i + 1;","path":"src/group_impl.h","position":null,"original_position":36,"commit_id":"0d05ad04bd25b65900fe4743e74af06a49ad06af","original_commit_id":"8b9cc17d8cfb75dced958203db69b2a7dfee327e","user":{"login":"apoelstra","id":1351933,"node_id":"MDQ6VXNlcjEzNTE5MzM=","avatar_url":"https://avatars0.githubusercontent.com/u/1351933?v=4","gravatar_id":"","url":"https://api.github.com/users/apoelstra","html_url":"https://github.com/apoelstra","followers_url":"https://api.github.com/users/apoelstra/followers","following_url":"https://api.github.com/users/apoelstra/following{/other_user}","gists_url":"https://api.github.com/users/apoelstra/gists{/gist_id}","starred_url":"https://api.github.com/users/apoelstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apoelstra/subscriptions","organizations_url":"https://api.github.com/users/apoelstra/orgs","repos_url":"https://api.github.com/users/apoelstra/repos","events_url":"https://api.github.com/users/apoelstra/events{/privacy}","received_events_url":"https://api.github.com/users/apoelstra/received_events","type":"User","site_admin":false},"body":"Ah, nice","created_at":"2018-11-08T14:46:48Z","updated_at":"2018-11-08T14:46:48Z","html_url":"https://github.com/bitcoin-core/secp256k1/pull/557#discussion_r231915797","pull_request_url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/557","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/comments/231915797"},"html":{"href":"https://github.com/bitcoin-core/secp256k1/pull/557#discussion_r231915797"},"pull_request":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/557"}},"in_reply_to_id":231747116},"pull_request":{"url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/557","id":217480027,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE3NDgwMDI3","html_url":"https://github.com/bitcoin-core/secp256k1/pull/557","diff_url":"https://github.com/bitcoin-core/secp256k1/pull/557.diff","patch_url":"https://github.com/bitcoin-core/secp256k1/pull/557.patch","issue_url":"https://api.github.com/repos/bitcoin-core/secp256k1/issues/557","number":557,"state":"open","locked":false,"title":"Eliminate scratch memory used when generating contexts","user":{"login":"apoelstra","id":1351933,"node_id":"MDQ6VXNlcjEzNTE5MzM=","avatar_url":"https://avatars0.githubusercontent.com/u/1351933?v=4","gravatar_id":"","url":"https://api.github.com/users/apoelstra","html_url":"https://github.com/apoelstra","followers_url":"https://api.github.com/users/apoelstra/followers","following_url":"https://api.github.com/users/apoelstra/following{/other_user}","gists_url":"https://api.github.com/users/apoelstra/gists{/gist_id}","starred_url":"https://api.github.com/users/apoelstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apoelstra/subscriptions","organizations_url":"https://api.github.com/users/apoelstra/orgs","repos_url":"https://api.github.com/users/apoelstra/repos","events_url":"https://api.github.com/users/apoelstra/events{/privacy}","received_events_url":"https://api.github.com/users/apoelstra/received_events","type":"User","site_admin":false},"body":"Builds on #553 ","created_at":"2018-09-22T21:43:52Z","updated_at":"2018-11-08T14:46:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"74e7fdfcf77b927fb9e87a1db012cf29568da409","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/557/commits","review_comments_url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/557/comments","review_comment_url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bitcoin-core/secp256k1/issues/557/comments","statuses_url":"https://api.github.com/repos/bitcoin-core/secp256k1/statuses/0d05ad04bd25b65900fe4743e74af06a49ad06af","head":{"label":"apoelstra:2018-09-no-scratch-memory-in-context-build","ref":"2018-09-no-scratch-memory-in-context-build","sha":"0d05ad04bd25b65900fe4743e74af06a49ad06af","user":{"login":"apoelstra","id":1351933,"node_id":"MDQ6VXNlcjEzNTE5MzM=","avatar_url":"https://avatars0.githubusercontent.com/u/1351933?v=4","gravatar_id":"","url":"https://api.github.com/users/apoelstra","html_url":"https://github.com/apoelstra","followers_url":"https://api.github.com/users/apoelstra/followers","following_url":"https://api.github.com/users/apoelstra/following{/other_user}","gists_url":"https://api.github.com/users/apoelstra/gists{/gist_id}","starred_url":"https://api.github.com/users/apoelstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apoelstra/subscriptions","organizations_url":"https://api.github.com/users/apoelstra/orgs","repos_url":"https://api.github.com/users/apoelstra/repos","events_url":"https://api.github.com/users/apoelstra/events{/privacy}","received_events_url":"https://api.github.com/users/apoelstra/received_events","type":"User","site_admin":false},"repo":{"id":33787691,"node_id":"MDEwOlJlcG9zaXRvcnkzMzc4NzY5MQ==","name":"secp256k1","full_name":"apoelstra/secp256k1","private":false,"owner":{"login":"apoelstra","id":1351933,"node_id":"MDQ6VXNlcjEzNTE5MzM=","avatar_url":"https://avatars0.githubusercontent.com/u/1351933?v=4","gravatar_id":"","url":"https://api.github.com/users/apoelstra","html_url":"https://github.com/apoelstra","followers_url":"https://api.github.com/users/apoelstra/followers","following_url":"https://api.github.com/users/apoelstra/following{/other_user}","gists_url":"https://api.github.com/users/apoelstra/gists{/gist_id}","starred_url":"https://api.github.com/users/apoelstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apoelstra/subscriptions","organizations_url":"https://api.github.com/users/apoelstra/orgs","repos_url":"https://api.github.com/users/apoelstra/repos","events_url":"https://api.github.com/users/apoelstra/events{/privacy}","received_events_url":"https://api.github.com/users/apoelstra/received_events","type":"User","site_admin":false},"html_url":"https://github.com/apoelstra/secp256k1","description":"Optimized C library for EC operations on curve secp256k1","fork":true,"url":"https://api.github.com/repos/apoelstra/secp256k1","forks_url":"https://api.github.com/repos/apoelstra/secp256k1/forks","keys_url":"https://api.github.com/repos/apoelstra/secp256k1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apoelstra/secp256k1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apoelstra/secp256k1/teams","hooks_url":"https://api.github.com/repos/apoelstra/secp256k1/hooks","issue_events_url":"https://api.github.com/repos/apoelstra/secp256k1/issues/events{/number}","events_url":"https://api.github.com/repos/apoelstra/secp256k1/events","assignees_url":"https://api.github.com/repos/apoelstra/secp256k1/assignees{/user}","branches_url":"https://api.github.com/repos/apoelstra/secp256k1/branches{/branch}","tags_url":"https://api.github.com/repos/apoelstra/secp256k1/tags","blobs_url":"https://api.github.com/repos/apoelstra/secp256k1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apoelstra/secp256k1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apoelstra/secp256k1/git/refs{/sha}","trees_url":"https://api.github.com/repos/apoelstra/secp256k1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apoelstra/secp256k1/statuses/{sha}","languages_url":"https://api.github.com/repos/apoelstra/secp256k1/languages","stargazers_url":"https://api.github.com/repos/apoelstra/secp256k1/stargazers","contributors_url":"https://api.github.com/repos/apoelstra/secp256k1/contributors","subscribers_url":"https://api.github.com/repos/apoelstra/secp256k1/subscribers","subscription_url":"https://api.github.com/repos/apoelstra/secp256k1/subscription","commits_url":"https://api.github.com/repos/apoelstra/secp256k1/commits{/sha}","git_commits_url":"https://api.github.com/repos/apoelstra/secp256k1/git/commits{/sha}","comments_url":"https://api.github.com/repos/apoelstra/secp256k1/comments{/number}","issue_comment_url":"https://api.github.com/repos/apoelstra/secp256k1/issues/comments{/number}","contents_url":"https://api.github.com/repos/apoelstra/secp256k1/contents/{+path}","compare_url":"https://api.github.com/repos/apoelstra/secp256k1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apoelstra/secp256k1/merges","archive_url":"https://api.github.com/repos/apoelstra/secp256k1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apoelstra/secp256k1/downloads","issues_url":"https://api.github.com/repos/apoelstra/secp256k1/issues{/number}","pulls_url":"https://api.github.com/repos/apoelstra/secp256k1/pulls{/number}","milestones_url":"https://api.github.com/repos/apoelstra/secp256k1/milestones{/number}","notifications_url":"https://api.github.com/repos/apoelstra/secp256k1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apoelstra/secp256k1/labels{/name}","releases_url":"https://api.github.com/repos/apoelstra/secp256k1/releases{/id}","deployments_url":"https://api.github.com/repos/apoelstra/secp256k1/deployments","created_at":"2015-04-11T18:42:06Z","updated_at":"2018-11-06T13:46:27Z","pushed_at":"2018-11-08T14:46:11Z","git_url":"git://github.com/apoelstra/secp256k1.git","ssh_url":"git@github.com:apoelstra/secp256k1.git","clone_url":"https://github.com/apoelstra/secp256k1.git","svn_url":"https://github.com/apoelstra/secp256k1","homepage":null,"size":1898,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"bitcoin-core:master","ref":"master","sha":"314a61d72474aa29ff4afba8472553ad91d88e9d","user":{"login":"bitcoin-core","id":13464320,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDY0MzIw","avatar_url":"https://avatars2.githubusercontent.com/u/13464320?v=4","gravatar_id":"","url":"https://api.github.com/users/bitcoin-core","html_url":"https://github.com/bitcoin-core","followers_url":"https://api.github.com/users/bitcoin-core/followers","following_url":"https://api.github.com/users/bitcoin-core/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin-core/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin-core/subscriptions","organizations_url":"https://api.github.com/users/bitcoin-core/orgs","repos_url":"https://api.github.com/users/bitcoin-core/repos","events_url":"https://api.github.com/users/bitcoin-core/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin-core/received_events","type":"Organization","site_admin":false},"repo":{"id":16648618,"node_id":"MDEwOlJlcG9zaXRvcnkxNjY0ODYxOA==","name":"secp256k1","full_name":"bitcoin-core/secp256k1","private":false,"owner":{"login":"bitcoin-core","id":13464320,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDY0MzIw","avatar_url":"https://avatars2.githubusercontent.com/u/13464320?v=4","gravatar_id":"","url":"https://api.github.com/users/bitcoin-core","html_url":"https://github.com/bitcoin-core","followers_url":"https://api.github.com/users/bitcoin-core/followers","following_url":"https://api.github.com/users/bitcoin-core/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin-core/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin-core/subscriptions","organizations_url":"https://api.github.com/users/bitcoin-core/orgs","repos_url":"https://api.github.com/users/bitcoin-core/repos","events_url":"https://api.github.com/users/bitcoin-core/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin-core/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/bitcoin-core/secp256k1","description":"Optimized C library for EC operations on curve secp256k1","fork":false,"url":"https://api.github.com/repos/bitcoin-core/secp256k1","forks_url":"https://api.github.com/repos/bitcoin-core/secp256k1/forks","keys_url":"https://api.github.com/repos/bitcoin-core/secp256k1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bitcoin-core/secp256k1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bitcoin-core/secp256k1/teams","hooks_url":"https://api.github.com/repos/bitcoin-core/secp256k1/hooks","issue_events_url":"https://api.github.com/repos/bitcoin-core/secp256k1/issues/events{/number}","events_url":"https://api.github.com/repos/bitcoin-core/secp256k1/events","assignees_url":"https://api.github.com/repos/bitcoin-core/secp256k1/assignees{/user}","branches_url":"https://api.github.com/repos/bitcoin-core/secp256k1/branches{/branch}","tags_url":"https://api.github.com/repos/bitcoin-core/secp256k1/tags","blobs_url":"https://api.github.com/repos/bitcoin-core/secp256k1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bitcoin-core/secp256k1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bitcoin-core/secp256k1/git/refs{/sha}","trees_url":"https://api.github.com/repos/bitcoin-core/secp256k1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bitcoin-core/secp256k1/statuses/{sha}","languages_url":"https://api.github.com/repos/bitcoin-core/secp256k1/languages","stargazers_url":"https://api.github.com/repos/bitcoin-core/secp256k1/stargazers","contributors_url":"https://api.github.com/repos/bitcoin-core/secp256k1/contributors","subscribers_url":"https://api.github.com/repos/bitcoin-core/secp256k1/subscribers","subscription_url":"https://api.github.com/repos/bitcoin-core/secp256k1/subscription","commits_url":"https://api.github.com/repos/bitcoin-core/secp256k1/commits{/sha}","git_commits_url":"https://api.github.com/repos/bitcoin-core/secp256k1/git/commits{/sha}","comments_url":"https://api.github.com/repos/bitcoin-core/secp256k1/comments{/number}","issue_comment_url":"https://api.github.com/repos/bitcoin-core/secp256k1/issues/comments{/number}","contents_url":"https://api.github.com/repos/bitcoin-core/secp256k1/contents/{+path}","compare_url":"https://api.github.com/repos/bitcoin-core/secp256k1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bitcoin-core/secp256k1/merges","archive_url":"https://api.github.com/repos/bitcoin-core/secp256k1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bitcoin-core/secp256k1/downloads","issues_url":"https://api.github.com/repos/bitcoin-core/secp256k1/issues{/number}","pulls_url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls{/number}","milestones_url":"https://api.github.com/repos/bitcoin-core/secp256k1/milestones{/number}","notifications_url":"https://api.github.com/repos/bitcoin-core/secp256k1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bitcoin-core/secp256k1/labels{/name}","releases_url":"https://api.github.com/repos/bitcoin-core/secp256k1/releases{/id}","deployments_url":"https://api.github.com/repos/bitcoin-core/secp256k1/deployments","created_at":"2014-02-08T17:30:06Z","updated_at":"2018-11-07T08:32:07Z","pushed_at":"2018-11-08T14:46:13Z","git_url":"git://github.com/bitcoin-core/secp256k1.git","ssh_url":"git@github.com:bitcoin-core/secp256k1.git","clone_url":"https://github.com/bitcoin-core/secp256k1.git","svn_url":"https://github.com/bitcoin-core/secp256k1","homepage":null,"size":1803,"stargazers_count":671,"watchers_count":671,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":425,"mirror_url":null,"archived":false,"open_issues_count":109,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":425,"open_issues":109,"watchers":671,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/557"},"html":{"href":"https://github.com/bitcoin-core/secp256k1/pull/557"},"issue":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/issues/557"},"comments":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/issues/557/comments"},"review_comments":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/557/comments"},"review_comment":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/557/commits"},"statuses":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/statuses/0d05ad04bd25b65900fe4743e74af06a49ad06af"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"apoelstra"}}