{"action":"created","comment":{"url":"https://api.github.com/repos/nucypher/pyUmbral/pulls/comments/184015306","pull_request_review_id":115123048,"id":184015306,"diff_hunk":"@@ -20,29 +21,27 @@ def __init__(self, bignum, curve_nid, group, order):\n         self.order = order\n \n     @classmethod\n-    def gen_rand(cls, curve: ec.EllipticCurve = None):\n+    def get_size(cls, curve: ec.EllipticCurve=None):\n         \"\"\"\n-        Returns a BigNum object with a cryptographically secure BigNum based\n-        on the given curve.\n+        Returns the size (in bytes) of a CurveBN given the curve.\n+        If no curve is provided, it uses the default.\n         \"\"\"\n         curve = curve if curve is not None else default_curve()\n-        curve_nid = backend._elliptic_curve_to_nid(curve)\n-\n-        group = backend._lib.EC_GROUP_new_by_curve_name(curve_nid)\n-        backend.openssl_assert(group != backend._ffi.NULL)\n+        return get_curve_keysize_bytes(curve)\n \n-        order = backend._lib.BN_new()\n-        backend.openssl_assert(order != backend._ffi.NULL)\n-        order = backend._ffi.gc(order, backend._lib.BN_clear_free)\n-\n-        with backend._tmp_bn_ctx() as bn_ctx:\n-            res = backend._lib.EC_GROUP_get_order(group, order, bn_ctx)\n-            backend.openssl_assert(res == 1)\n+    @classmethod\n+    def gen_rand(cls, curve: ec.EllipticCurve=None):\n+        \"\"\"\n+        Returns a CurveBN object with a cryptographically secure OpenSSL BIGNUM\n+        based on the given curve.\n+        \"\"\"\n+        curve = curve if curve is not None else default_curve()\n+        curve_nid = backend._elliptic_curve_to_nid(curve)\n \n-        new_rand_bn = backend._lib.BN_new()\n-        backend.openssl_assert(new_rand_bn != backend._ffi.NULL)\n-        new_rand_bn = backend._ffi.gc(new_rand_bn, backend._lib.BN_clear_free)\n+        group = openssl._get_ec_group_by_curve_nid(curve_nid)\n+        order = openssl._get_ec_order_by_curve_nid(curve_nid)\n \n+        new_rand_bn = openssl._get_new_BN()\n         rand_res = backend._lib.BN_rand_range(new_rand_bn, order)","path":"umbral/curvebn.py","position":59,"original_position":59,"commit_id":"7eec2a0c75422fa4f48431eec65e751ecef4ff39","original_commit_id":"7eec2a0c75422fa4f48431eec65e751ecef4ff39","user":{"login":"cygnusv","id":2564234,"avatar_url":"https://avatars1.githubusercontent.com/u/2564234?v=4","gravatar_id":"","url":"https://api.github.com/users/cygnusv","html_url":"https://github.com/cygnusv","followers_url":"https://api.github.com/users/cygnusv/followers","following_url":"https://api.github.com/users/cygnusv/following{/other_user}","gists_url":"https://api.github.com/users/cygnusv/gists{/gist_id}","starred_url":"https://api.github.com/users/cygnusv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cygnusv/subscriptions","organizations_url":"https://api.github.com/users/cygnusv/orgs","repos_url":"https://api.github.com/users/cygnusv/repos","events_url":"https://api.github.com/users/cygnusv/events{/privacy}","received_events_url":"https://api.github.com/users/cygnusv/received_events","type":"User","site_admin":false},"body":"I just noticed that this allows the BN to be 0, which we don't want (we want it to be in the interval `[1, q-1]`, for `q` the order of the curve). A better way would be to call `BN_rand_range(new_rand_bn, order_minus_1)` and then add 1 to the result. This ensures the resulting BN is in `[1, q-1]`","created_at":"2018-04-25T10:47:00Z","updated_at":"2018-04-25T10:47:00Z","html_url":"https://github.com/nucypher/pyUmbral/pull/127#discussion_r184015306","pull_request_url":"https://api.github.com/repos/nucypher/pyUmbral/pulls/127","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/nucypher/pyUmbral/pulls/comments/184015306"},"html":{"href":"https://github.com/nucypher/pyUmbral/pull/127#discussion_r184015306"},"pull_request":{"href":"https://api.github.com/repos/nucypher/pyUmbral/pulls/127"}}},"pull_request":{"url":"https://api.github.com/repos/nucypher/pyUmbral/pulls/127","id":183509576,"html_url":"https://github.com/nucypher/pyUmbral/pull/127","diff_url":"https://github.com/nucypher/pyUmbral/pull/127.diff","patch_url":"https://github.com/nucypher/pyUmbral/pull/127.patch","issue_url":"https://api.github.com/repos/nucypher/pyUmbral/issues/127","number":127,"state":"open","locked":false,"title":"Cleanup pyUmbral codebase and resolve various issues","user":{"login":"tuxxy","id":3598318,"avatar_url":"https://avatars1.githubusercontent.com/u/3598318?v=4","gravatar_id":"","url":"https://api.github.com/users/tuxxy","html_url":"https://github.com/tuxxy","followers_url":"https://api.github.com/users/tuxxy/followers","following_url":"https://api.github.com/users/tuxxy/following{/other_user}","gists_url":"https://api.github.com/users/tuxxy/gists{/gist_id}","starred_url":"https://api.github.com/users/tuxxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuxxy/subscriptions","organizations_url":"https://api.github.com/users/tuxxy/orgs","repos_url":"https://api.github.com/users/tuxxy/repos","events_url":"https://api.github.com/users/tuxxy/events{/privacy}","received_events_url":"https://api.github.com/users/tuxxy/received_events","type":"User","site_admin":false},"body":"### What this does:\r\n1. Moves some OpenSSL functions out of `BigNum` (now `CurveBN`) and `Point` to the `openssl` module and resolves the third TODO in #119.\r\n2. These operations include:\r\n    1. BN init/creation\r\n    2. Getting curve domain parameters (group, order, generator)\r\n    3. Checking if a BN is on a provided curve\r\n    4. Converting a Python int to a BN and checking if the new BN is on a curve\r\n    5. EC_POINT init/creation\r\n    6. EC_POINT creation via affine coordinates\r\n    7. Getting affine coordinates via an EC_POINT.\r\n3. Renames `BigNum` to `CurveBN` and resolves the first TODO in #119.\r\n4. Resolves #121 by caching the public key on `UmbralPrivateKey`.\r\n5. Resolves #56 by adding `get_size` classmethods to `CurveBN`, `Point`, `KFrag`, `CapsuleFrag`, and `ChallengeResponse`.\r\n6. Resolves #116 by changing `Capsule._attached_cfrags` to a list.","created_at":"2018-04-23T17:49:10Z","updated_at":"2018-04-25T10:47:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"76ae87d8bfd6041c99fad9c4b1a3e9c66829b541","assignee":null,"assignees":[],"requested_reviewers":[{"login":"jMyles","id":311973,"avatar_url":"https://avatars2.githubusercontent.com/u/311973?v=4","gravatar_id":"","url":"https://api.github.com/users/jMyles","html_url":"https://github.com/jMyles","followers_url":"https://api.github.com/users/jMyles/followers","following_url":"https://api.github.com/users/jMyles/following{/other_user}","gists_url":"https://api.github.com/users/jMyles/gists{/gist_id}","starred_url":"https://api.github.com/users/jMyles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jMyles/subscriptions","organizations_url":"https://api.github.com/users/jMyles/orgs","repos_url":"https://api.github.com/users/jMyles/repos","events_url":"https://api.github.com/users/jMyles/events{/privacy}","received_events_url":"https://api.github.com/users/jMyles/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/nucypher/pyUmbral/pulls/127/commits","review_comments_url":"https://api.github.com/repos/nucypher/pyUmbral/pulls/127/comments","review_comment_url":"https://api.github.com/repos/nucypher/pyUmbral/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nucypher/pyUmbral/issues/127/comments","statuses_url":"https://api.github.com/repos/nucypher/pyUmbral/statuses/7eec2a0c75422fa4f48431eec65e751ecef4ff39","head":{"label":"tuxxy:cleanup","ref":"cleanup","sha":"7eec2a0c75422fa4f48431eec65e751ecef4ff39","user":{"login":"tuxxy","id":3598318,"avatar_url":"https://avatars1.githubusercontent.com/u/3598318?v=4","gravatar_id":"","url":"https://api.github.com/users/tuxxy","html_url":"https://github.com/tuxxy","followers_url":"https://api.github.com/users/tuxxy/followers","following_url":"https://api.github.com/users/tuxxy/following{/other_user}","gists_url":"https://api.github.com/users/tuxxy/gists{/gist_id}","starred_url":"https://api.github.com/users/tuxxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuxxy/subscriptions","organizations_url":"https://api.github.com/users/tuxxy/orgs","repos_url":"https://api.github.com/users/tuxxy/repos","events_url":"https://api.github.com/users/tuxxy/events{/privacy}","received_events_url":"https://api.github.com/users/tuxxy/received_events","type":"User","site_admin":false},"repo":{"id":116438486,"name":"pyUmbral","full_name":"tuxxy/pyUmbral","owner":{"login":"tuxxy","id":3598318,"avatar_url":"https://avatars1.githubusercontent.com/u/3598318?v=4","gravatar_id":"","url":"https://api.github.com/users/tuxxy","html_url":"https://github.com/tuxxy","followers_url":"https://api.github.com/users/tuxxy/followers","following_url":"https://api.github.com/users/tuxxy/following{/other_user}","gists_url":"https://api.github.com/users/tuxxy/gists{/gist_id}","starred_url":"https://api.github.com/users/tuxxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuxxy/subscriptions","organizations_url":"https://api.github.com/users/tuxxy/orgs","repos_url":"https://api.github.com/users/tuxxy/repos","events_url":"https://api.github.com/users/tuxxy/events{/privacy}","received_events_url":"https://api.github.com/users/tuxxy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tuxxy/pyUmbral","description":"Nucypher KMS implementation of Umbral using OpenSSL and Cryptography.io","fork":true,"url":"https://api.github.com/repos/tuxxy/pyUmbral","forks_url":"https://api.github.com/repos/tuxxy/pyUmbral/forks","keys_url":"https://api.github.com/repos/tuxxy/pyUmbral/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tuxxy/pyUmbral/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tuxxy/pyUmbral/teams","hooks_url":"https://api.github.com/repos/tuxxy/pyUmbral/hooks","issue_events_url":"https://api.github.com/repos/tuxxy/pyUmbral/issues/events{/number}","events_url":"https://api.github.com/repos/tuxxy/pyUmbral/events","assignees_url":"https://api.github.com/repos/tuxxy/pyUmbral/assignees{/user}","branches_url":"https://api.github.com/repos/tuxxy/pyUmbral/branches{/branch}","tags_url":"https://api.github.com/repos/tuxxy/pyUmbral/tags","blobs_url":"https://api.github.com/repos/tuxxy/pyUmbral/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tuxxy/pyUmbral/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tuxxy/pyUmbral/git/refs{/sha}","trees_url":"https://api.github.com/repos/tuxxy/pyUmbral/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tuxxy/pyUmbral/statuses/{sha}","languages_url":"https://api.github.com/repos/tuxxy/pyUmbral/languages","stargazers_url":"https://api.github.com/repos/tuxxy/pyUmbral/stargazers","contributors_url":"https://api.github.com/repos/tuxxy/pyUmbral/contributors","subscribers_url":"https://api.github.com/repos/tuxxy/pyUmbral/subscribers","subscription_url":"https://api.github.com/repos/tuxxy/pyUmbral/subscription","commits_url":"https://api.github.com/repos/tuxxy/pyUmbral/commits{/sha}","git_commits_url":"https://api.github.com/repos/tuxxy/pyUmbral/git/commits{/sha}","comments_url":"https://api.github.com/repos/tuxxy/pyUmbral/comments{/number}","issue_comment_url":"https://api.github.com/repos/tuxxy/pyUmbral/issues/comments{/number}","contents_url":"https://api.github.com/repos/tuxxy/pyUmbral/contents/{+path}","compare_url":"https://api.github.com/repos/tuxxy/pyUmbral/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tuxxy/pyUmbral/merges","archive_url":"https://api.github.com/repos/tuxxy/pyUmbral/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tuxxy/pyUmbral/downloads","issues_url":"https://api.github.com/repos/tuxxy/pyUmbral/issues{/number}","pulls_url":"https://api.github.com/repos/tuxxy/pyUmbral/pulls{/number}","milestones_url":"https://api.github.com/repos/tuxxy/pyUmbral/milestones{/number}","notifications_url":"https://api.github.com/repos/tuxxy/pyUmbral/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tuxxy/pyUmbral/labels{/name}","releases_url":"https://api.github.com/repos/tuxxy/pyUmbral/releases{/id}","deployments_url":"https://api.github.com/repos/tuxxy/pyUmbral/deployments","created_at":"2018-01-05T23:49:19Z","updated_at":"2018-04-17T18:45:01Z","pushed_at":"2018-04-24T23:02:28Z","git_url":"git://github.com/tuxxy/pyUmbral.git","ssh_url":"git@github.com:tuxxy/pyUmbral.git","clone_url":"https://github.com/tuxxy/pyUmbral.git","svn_url":"https://github.com/tuxxy/pyUmbral","homepage":null,"size":506,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nucypher:master","ref":"master","sha":"c5a9fc6dd92506c0583bf343974e7745d6fe7b21","user":{"login":"nucypher","id":24552990,"avatar_url":"https://avatars0.githubusercontent.com/u/24552990?v=4","gravatar_id":"","url":"https://api.github.com/users/nucypher","html_url":"https://github.com/nucypher","followers_url":"https://api.github.com/users/nucypher/followers","following_url":"https://api.github.com/users/nucypher/following{/other_user}","gists_url":"https://api.github.com/users/nucypher/gists{/gist_id}","starred_url":"https://api.github.com/users/nucypher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nucypher/subscriptions","organizations_url":"https://api.github.com/users/nucypher/orgs","repos_url":"https://api.github.com/users/nucypher/repos","events_url":"https://api.github.com/users/nucypher/events{/privacy}","received_events_url":"https://api.github.com/users/nucypher/received_events","type":"Organization","site_admin":false},"repo":{"id":115219228,"name":"pyUmbral","full_name":"nucypher/pyUmbral","owner":{"login":"nucypher","id":24552990,"avatar_url":"https://avatars0.githubusercontent.com/u/24552990?v=4","gravatar_id":"","url":"https://api.github.com/users/nucypher","html_url":"https://github.com/nucypher","followers_url":"https://api.github.com/users/nucypher/followers","following_url":"https://api.github.com/users/nucypher/following{/other_user}","gists_url":"https://api.github.com/users/nucypher/gists{/gist_id}","starred_url":"https://api.github.com/users/nucypher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nucypher/subscriptions","organizations_url":"https://api.github.com/users/nucypher/orgs","repos_url":"https://api.github.com/users/nucypher/repos","events_url":"https://api.github.com/users/nucypher/events{/privacy}","received_events_url":"https://api.github.com/users/nucypher/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nucypher/pyUmbral","description":"Nucypher KMS implementation of Umbral using OpenSSL and Cryptography.io","fork":false,"url":"https://api.github.com/repos/nucypher/pyUmbral","forks_url":"https://api.github.com/repos/nucypher/pyUmbral/forks","keys_url":"https://api.github.com/repos/nucypher/pyUmbral/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nucypher/pyUmbral/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nucypher/pyUmbral/teams","hooks_url":"https://api.github.com/repos/nucypher/pyUmbral/hooks","issue_events_url":"https://api.github.com/repos/nucypher/pyUmbral/issues/events{/number}","events_url":"https://api.github.com/repos/nucypher/pyUmbral/events","assignees_url":"https://api.github.com/repos/nucypher/pyUmbral/assignees{/user}","branches_url":"https://api.github.com/repos/nucypher/pyUmbral/branches{/branch}","tags_url":"https://api.github.com/repos/nucypher/pyUmbral/tags","blobs_url":"https://api.github.com/repos/nucypher/pyUmbral/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nucypher/pyUmbral/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nucypher/pyUmbral/git/refs{/sha}","trees_url":"https://api.github.com/repos/nucypher/pyUmbral/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nucypher/pyUmbral/statuses/{sha}","languages_url":"https://api.github.com/repos/nucypher/pyUmbral/languages","stargazers_url":"https://api.github.com/repos/nucypher/pyUmbral/stargazers","contributors_url":"https://api.github.com/repos/nucypher/pyUmbral/contributors","subscribers_url":"https://api.github.com/repos/nucypher/pyUmbral/subscribers","subscription_url":"https://api.github.com/repos/nucypher/pyUmbral/subscription","commits_url":"https://api.github.com/repos/nucypher/pyUmbral/commits{/sha}","git_commits_url":"https://api.github.com/repos/nucypher/pyUmbral/git/commits{/sha}","comments_url":"https://api.github.com/repos/nucypher/pyUmbral/comments{/number}","issue_comment_url":"https://api.github.com/repos/nucypher/pyUmbral/issues/comments{/number}","contents_url":"https://api.github.com/repos/nucypher/pyUmbral/contents/{+path}","compare_url":"https://api.github.com/repos/nucypher/pyUmbral/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nucypher/pyUmbral/merges","archive_url":"https://api.github.com/repos/nucypher/pyUmbral/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nucypher/pyUmbral/downloads","issues_url":"https://api.github.com/repos/nucypher/pyUmbral/issues{/number}","pulls_url":"https://api.github.com/repos/nucypher/pyUmbral/pulls{/number}","milestones_url":"https://api.github.com/repos/nucypher/pyUmbral/milestones{/number}","notifications_url":"https://api.github.com/repos/nucypher/pyUmbral/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nucypher/pyUmbral/labels{/name}","releases_url":"https://api.github.com/repos/nucypher/pyUmbral/releases{/id}","deployments_url":"https://api.github.com/repos/nucypher/pyUmbral/deployments","created_at":"2017-12-23T20:10:04Z","updated_at":"2018-04-25T10:02:47Z","pushed_at":"2018-04-25T10:02:46Z","git_url":"git://github.com/nucypher/pyUmbral.git","ssh_url":"git@github.com:nucypher/pyUmbral.git","clone_url":"https://github.com/nucypher/pyUmbral.git","svn_url":"https://github.com/nucypher/pyUmbral","homepage":null,"size":476,"stargazers_count":40,"watchers_count":40,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"archived":false,"open_issues_count":17,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":11,"open_issues":17,"watchers":40,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nucypher/pyUmbral/pulls/127"},"html":{"href":"https://github.com/nucypher/pyUmbral/pull/127"},"issue":{"href":"https://api.github.com/repos/nucypher/pyUmbral/issues/127"},"comments":{"href":"https://api.github.com/repos/nucypher/pyUmbral/issues/127/comments"},"review_comments":{"href":"https://api.github.com/repos/nucypher/pyUmbral/pulls/127/comments"},"review_comment":{"href":"https://api.github.com/repos/nucypher/pyUmbral/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nucypher/pyUmbral/pulls/127/commits"},"statuses":{"href":"https://api.github.com/repos/nucypher/pyUmbral/statuses/7eec2a0c75422fa4f48431eec65e751ecef4ff39"}},"author_association":"OWNER"}}
{"actor":{"display_login":"cygnusv"}}