{"action":"created","comment":{"url":"https://api.github.com/repos/sfackler/rust-openssl/pulls/comments/177863479","pull_request_review_id":107816488,"id":177863479,"diff_hunk":"@@ -1401,4 +1421,37 @@ mod tests {\n         assert!(p.is_prime(100, &mut ctx).unwrap());\n         assert!(p.is_prime_fasttest(100, &mut ctx, true).unwrap());\n     }\n+\n+    #[test]\n+    fn test_exponentiation_time() {\n+        // Checks the time taken to do `(((g^x_1 mod n)^x_2 mod n)^x_3 mod n)...` using `mod_exp_mut`\n+\n+        let modulus = BigNum::from_dec_str(\"3204629348400311894981147889064213475911502950610822910497794640539580108252311103815602649702091072442089016826192705629222534383850640976103541074965825911439481511841669818218556523699545667979238433531950872370285535430396347665030321087803912182039011247460768098263564546879241877558066260767468387251243972651463237193324761892342299558684399419909028079667195672054655387173203038107042778744649155842364672936664532754000715885900524415403622527226575507346822066350920781137340258848229685505555558665781467456342659911415599377043489979596237979941386501264463874766166877146485965674900595259972161874714381016252770855749700706860768647580178487242906896883599546187195495868346449603306725234279605044720570340541521141682943069084999263530360914420274990375408153529679146137934097158741957518183323298580558730909779698051995609396227449697670716584357361212378371486020465912177797480071144296559699016912326564059836301570632836543118917475972178423287627710340103368809606657431184660768586693677060010145686280797896075497757615632909442703186036300871183851569319692562563918216157762976445282183184528709786306196550055260857987968870798605413506633826598403862811608523439523945519737279157633473140586034211201\").unwrap();\n+        let element_size = 1500;\n+        let mut accumulator = BigNum::from_dec_str(\"1915182769368569486963976668657418846122016471585262452138689064979880063217142171230525667406114297912997697884669760718181148903891406258652154564474937314809392827351229074850339882653085906709452763512017926382658040877860425398565313118206001571983057266861433787870120516963262872556160137632986790799637800187327525373894833699998137974425675888510468704041321563743266953919273330110447213516904474856325884904918747921700098338253140217925656078220294833113261362981479227102302139442862538529417112227112104830922667359007109709204936925922862592053626140248383988977967399826184116697852122995719423774656923017777301713520425580745782097460248899329835740441429284020663186635354571333690692107185946297929772630086928323118606594588790915139339431940489511850279806818826143040378319619062305629273497273725721368157955512179352674013822087432127910233025333571203452180390613181846035364105352384024395662959142236311712295552933323767329374261596612060957502167831080774021620823718240397211269873903737841346862215246685242302847894894907938934985950908016181737929997451061016202494801606490097096889822976223609532834237496884730642312786447889763148272139117981855545441295507862786712405210727374768044118436617961\").unwrap();\n+\n+        // Number of primes to exponenetiate\n+        let num_exponentiations = 100;\n+\n+        let mut primes = Vec::new();\n+        let start_since_the_epoch = SystemTime::now().duration_since(UNIX_EPOCH)\n+            .expect(\"Time went backwards\");\n+        for _ in 0..num_exponentiations {\n+            let mut p = BigNum::new().unwrap();\n+            p.generate_prime(element_size, false, None, None).unwrap();\n+            primes.push(p);\n+        }\n+        let end_since_the_epoch = SystemTime::now().duration_since(UNIX_EPOCH)","path":"openssl/src/bn.rs","position":58,"original_position":58,"commit_id":"f157c9605fbf27e6218f477430c8bfb130ff82ac","original_commit_id":"f157c9605fbf27e6218f477430c8bfb130ff82ac","user":{"login":"sfackler","id":1455697,"avatar_url":"https://avatars0.githubusercontent.com/u/1455697?v=4","gravatar_id":"","url":"https://api.github.com/users/sfackler","html_url":"https://github.com/sfackler","followers_url":"https://api.github.com/users/sfackler/followers","following_url":"https://api.github.com/users/sfackler/following{/other_user}","gists_url":"https://api.github.com/users/sfackler/gists{/gist_id}","starred_url":"https://api.github.com/users/sfackler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfackler/subscriptions","organizations_url":"https://api.github.com/users/sfackler/orgs","repos_url":"https://api.github.com/users/sfackler/repos","events_url":"https://api.github.com/users/sfackler/events{/privacy}","received_events_url":"https://api.github.com/users/sfackler/received_events","type":"User","site_admin":false},"body":"`SystemTime` shouldn't be used for timing because of the time shift issue. `Instant` doesn't have those problems.","created_at":"2018-03-28T19:25:47Z","updated_at":"2018-03-28T19:26:30Z","html_url":"https://github.com/sfackler/rust-openssl/pull/885#discussion_r177863479","pull_request_url":"https://api.github.com/repos/sfackler/rust-openssl/pulls/885","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/sfackler/rust-openssl/pulls/comments/177863479"},"html":{"href":"https://github.com/sfackler/rust-openssl/pull/885#discussion_r177863479"},"pull_request":{"href":"https://api.github.com/repos/sfackler/rust-openssl/pulls/885"}}},"pull_request":{"url":"https://api.github.com/repos/sfackler/rust-openssl/pulls/885","id":177853995,"html_url":"https://github.com/sfackler/rust-openssl/pull/885","diff_url":"https://github.com/sfackler/rust-openssl/pull/885.diff","patch_url":"https://github.com/sfackler/rust-openssl/pull/885.patch","issue_url":"https://api.github.com/repos/sfackler/rust-openssl/issues/885","number":885,"state":"open","locked":false,"title":"Modular exponentiation variant.","user":{"login":"lovesh","id":3115401,"avatar_url":"https://avatars0.githubusercontent.com/u/3115401?v=4","gravatar_id":"","url":"https://api.github.com/users/lovesh","html_url":"https://github.com/lovesh","followers_url":"https://api.github.com/users/lovesh/followers","following_url":"https://api.github.com/users/lovesh/following{/other_user}","gists_url":"https://api.github.com/users/lovesh/gists{/gist_id}","starred_url":"https://api.github.com/users/lovesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lovesh/subscriptions","organizations_url":"https://api.github.com/users/lovesh/orgs","repos_url":"https://api.github.com/users/lovesh/repos","events_url":"https://api.github.com/users/lovesh/events{/privacy}","received_events_url":"https://api.github.com/users/lovesh/received_events","type":"User","site_admin":false},"body":"Adds a method `mod_exp_mut` to `BigNumRef`.  \r\n`pub fn mod_exp_mut(&mut self, p: &BigNumRef, m: &BigNumRef, ctx: &mut BigNumContextRef) -> Result<(), ErrorStack>`  \r\nPlaces the result of `self^p mod m` in `self`. This makes it possible to avoid allocating a new `BigNum` for each exponentiation. Useful for computations like `(((g^x_1 mod n)^x_2 mod n)^x_3 mod n)...`","created_at":"2018-03-27T20:20:45Z","updated_at":"2018-03-28T19:26:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6f094aa007949d634f0ab8c2fc3b245ff52fd825","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sfackler/rust-openssl/pulls/885/commits","review_comments_url":"https://api.github.com/repos/sfackler/rust-openssl/pulls/885/comments","review_comment_url":"https://api.github.com/repos/sfackler/rust-openssl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sfackler/rust-openssl/issues/885/comments","statuses_url":"https://api.github.com/repos/sfackler/rust-openssl/statuses/f157c9605fbf27e6218f477430c8bfb130ff82ac","head":{"label":"lovesh:mod-exp-mut","ref":"mod-exp-mut","sha":"f157c9605fbf27e6218f477430c8bfb130ff82ac","user":{"login":"lovesh","id":3115401,"avatar_url":"https://avatars0.githubusercontent.com/u/3115401?v=4","gravatar_id":"","url":"https://api.github.com/users/lovesh","html_url":"https://github.com/lovesh","followers_url":"https://api.github.com/users/lovesh/followers","following_url":"https://api.github.com/users/lovesh/following{/other_user}","gists_url":"https://api.github.com/users/lovesh/gists{/gist_id}","starred_url":"https://api.github.com/users/lovesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lovesh/subscriptions","organizations_url":"https://api.github.com/users/lovesh/orgs","repos_url":"https://api.github.com/users/lovesh/repos","events_url":"https://api.github.com/users/lovesh/events{/privacy}","received_events_url":"https://api.github.com/users/lovesh/received_events","type":"User","site_admin":false},"repo":{"id":127038948,"name":"rust-openssl","full_name":"lovesh/rust-openssl","owner":{"login":"lovesh","id":3115401,"avatar_url":"https://avatars0.githubusercontent.com/u/3115401?v=4","gravatar_id":"","url":"https://api.github.com/users/lovesh","html_url":"https://github.com/lovesh","followers_url":"https://api.github.com/users/lovesh/followers","following_url":"https://api.github.com/users/lovesh/following{/other_user}","gists_url":"https://api.github.com/users/lovesh/gists{/gist_id}","starred_url":"https://api.github.com/users/lovesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lovesh/subscriptions","organizations_url":"https://api.github.com/users/lovesh/orgs","repos_url":"https://api.github.com/users/lovesh/repos","events_url":"https://api.github.com/users/lovesh/events{/privacy}","received_events_url":"https://api.github.com/users/lovesh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lovesh/rust-openssl","description":"OpenSSL bindings for Rust","fork":true,"url":"https://api.github.com/repos/lovesh/rust-openssl","forks_url":"https://api.github.com/repos/lovesh/rust-openssl/forks","keys_url":"https://api.github.com/repos/lovesh/rust-openssl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lovesh/rust-openssl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lovesh/rust-openssl/teams","hooks_url":"https://api.github.com/repos/lovesh/rust-openssl/hooks","issue_events_url":"https://api.github.com/repos/lovesh/rust-openssl/issues/events{/number}","events_url":"https://api.github.com/repos/lovesh/rust-openssl/events","assignees_url":"https://api.github.com/repos/lovesh/rust-openssl/assignees{/user}","branches_url":"https://api.github.com/repos/lovesh/rust-openssl/branches{/branch}","tags_url":"https://api.github.com/repos/lovesh/rust-openssl/tags","blobs_url":"https://api.github.com/repos/lovesh/rust-openssl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lovesh/rust-openssl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lovesh/rust-openssl/git/refs{/sha}","trees_url":"https://api.github.com/repos/lovesh/rust-openssl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lovesh/rust-openssl/statuses/{sha}","languages_url":"https://api.github.com/repos/lovesh/rust-openssl/languages","stargazers_url":"https://api.github.com/repos/lovesh/rust-openssl/stargazers","contributors_url":"https://api.github.com/repos/lovesh/rust-openssl/contributors","subscribers_url":"https://api.github.com/repos/lovesh/rust-openssl/subscribers","subscription_url":"https://api.github.com/repos/lovesh/rust-openssl/subscription","commits_url":"https://api.github.com/repos/lovesh/rust-openssl/commits{/sha}","git_commits_url":"https://api.github.com/repos/lovesh/rust-openssl/git/commits{/sha}","comments_url":"https://api.github.com/repos/lovesh/rust-openssl/comments{/number}","issue_comment_url":"https://api.github.com/repos/lovesh/rust-openssl/issues/comments{/number}","contents_url":"https://api.github.com/repos/lovesh/rust-openssl/contents/{+path}","compare_url":"https://api.github.com/repos/lovesh/rust-openssl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lovesh/rust-openssl/merges","archive_url":"https://api.github.com/repos/lovesh/rust-openssl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lovesh/rust-openssl/downloads","issues_url":"https://api.github.com/repos/lovesh/rust-openssl/issues{/number}","pulls_url":"https://api.github.com/repos/lovesh/rust-openssl/pulls{/number}","milestones_url":"https://api.github.com/repos/lovesh/rust-openssl/milestones{/number}","notifications_url":"https://api.github.com/repos/lovesh/rust-openssl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lovesh/rust-openssl/labels{/name}","releases_url":"https://api.github.com/repos/lovesh/rust-openssl/releases{/id}","deployments_url":"https://api.github.com/repos/lovesh/rust-openssl/deployments","created_at":"2018-03-27T19:55:53Z","updated_at":"2018-03-27T19:55:55Z","pushed_at":"2018-03-27T21:12:50Z","git_url":"git://github.com/lovesh/rust-openssl.git","ssh_url":"git@github.com:lovesh/rust-openssl.git","clone_url":"https://github.com/lovesh/rust-openssl.git","svn_url":"https://github.com/lovesh/rust-openssl","homepage":"","size":9008,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sfackler:master","ref":"master","sha":"812d7a613fd9025d55e876995d1c91fc4b6e25bd","user":{"login":"sfackler","id":1455697,"avatar_url":"https://avatars0.githubusercontent.com/u/1455697?v=4","gravatar_id":"","url":"https://api.github.com/users/sfackler","html_url":"https://github.com/sfackler","followers_url":"https://api.github.com/users/sfackler/followers","following_url":"https://api.github.com/users/sfackler/following{/other_user}","gists_url":"https://api.github.com/users/sfackler/gists{/gist_id}","starred_url":"https://api.github.com/users/sfackler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfackler/subscriptions","organizations_url":"https://api.github.com/users/sfackler/orgs","repos_url":"https://api.github.com/users/sfackler/repos","events_url":"https://api.github.com/users/sfackler/events{/privacy}","received_events_url":"https://api.github.com/users/sfackler/received_events","type":"User","site_admin":false},"repo":{"id":15500883,"name":"rust-openssl","full_name":"sfackler/rust-openssl","owner":{"login":"sfackler","id":1455697,"avatar_url":"https://avatars0.githubusercontent.com/u/1455697?v=4","gravatar_id":"","url":"https://api.github.com/users/sfackler","html_url":"https://github.com/sfackler","followers_url":"https://api.github.com/users/sfackler/followers","following_url":"https://api.github.com/users/sfackler/following{/other_user}","gists_url":"https://api.github.com/users/sfackler/gists{/gist_id}","starred_url":"https://api.github.com/users/sfackler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfackler/subscriptions","organizations_url":"https://api.github.com/users/sfackler/orgs","repos_url":"https://api.github.com/users/sfackler/repos","events_url":"https://api.github.com/users/sfackler/events{/privacy}","received_events_url":"https://api.github.com/users/sfackler/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sfackler/rust-openssl","description":"OpenSSL bindings for Rust","fork":false,"url":"https://api.github.com/repos/sfackler/rust-openssl","forks_url":"https://api.github.com/repos/sfackler/rust-openssl/forks","keys_url":"https://api.github.com/repos/sfackler/rust-openssl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sfackler/rust-openssl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sfackler/rust-openssl/teams","hooks_url":"https://api.github.com/repos/sfackler/rust-openssl/hooks","issue_events_url":"https://api.github.com/repos/sfackler/rust-openssl/issues/events{/number}","events_url":"https://api.github.com/repos/sfackler/rust-openssl/events","assignees_url":"https://api.github.com/repos/sfackler/rust-openssl/assignees{/user}","branches_url":"https://api.github.com/repos/sfackler/rust-openssl/branches{/branch}","tags_url":"https://api.github.com/repos/sfackler/rust-openssl/tags","blobs_url":"https://api.github.com/repos/sfackler/rust-openssl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sfackler/rust-openssl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sfackler/rust-openssl/git/refs{/sha}","trees_url":"https://api.github.com/repos/sfackler/rust-openssl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sfackler/rust-openssl/statuses/{sha}","languages_url":"https://api.github.com/repos/sfackler/rust-openssl/languages","stargazers_url":"https://api.github.com/repos/sfackler/rust-openssl/stargazers","contributors_url":"https://api.github.com/repos/sfackler/rust-openssl/contributors","subscribers_url":"https://api.github.com/repos/sfackler/rust-openssl/subscribers","subscription_url":"https://api.github.com/repos/sfackler/rust-openssl/subscription","commits_url":"https://api.github.com/repos/sfackler/rust-openssl/commits{/sha}","git_commits_url":"https://api.github.com/repos/sfackler/rust-openssl/git/commits{/sha}","comments_url":"https://api.github.com/repos/sfackler/rust-openssl/comments{/number}","issue_comment_url":"https://api.github.com/repos/sfackler/rust-openssl/issues/comments{/number}","contents_url":"https://api.github.com/repos/sfackler/rust-openssl/contents/{+path}","compare_url":"https://api.github.com/repos/sfackler/rust-openssl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sfackler/rust-openssl/merges","archive_url":"https://api.github.com/repos/sfackler/rust-openssl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sfackler/rust-openssl/downloads","issues_url":"https://api.github.com/repos/sfackler/rust-openssl/issues{/number}","pulls_url":"https://api.github.com/repos/sfackler/rust-openssl/pulls{/number}","milestones_url":"https://api.github.com/repos/sfackler/rust-openssl/milestones{/number}","notifications_url":"https://api.github.com/repos/sfackler/rust-openssl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sfackler/rust-openssl/labels{/name}","releases_url":"https://api.github.com/repos/sfackler/rust-openssl/releases{/id}","deployments_url":"https://api.github.com/repos/sfackler/rust-openssl/deployments","created_at":"2013-12-28T23:56:50Z","updated_at":"2018-03-28T19:13:54Z","pushed_at":"2018-03-28T19:13:55Z","git_url":"git://github.com/sfackler/rust-openssl.git","ssh_url":"git@github.com:sfackler/rust-openssl.git","clone_url":"https://github.com/sfackler/rust-openssl.git","svn_url":"https://github.com/sfackler/rust-openssl","homepage":"","size":9015,"stargazers_count":354,"watchers_count":354,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":251,"mirror_url":null,"archived":false,"open_issues_count":37,"license":null,"forks":251,"open_issues":37,"watchers":354,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sfackler/rust-openssl/pulls/885"},"html":{"href":"https://github.com/sfackler/rust-openssl/pull/885"},"issue":{"href":"https://api.github.com/repos/sfackler/rust-openssl/issues/885"},"comments":{"href":"https://api.github.com/repos/sfackler/rust-openssl/issues/885/comments"},"review_comments":{"href":"https://api.github.com/repos/sfackler/rust-openssl/pulls/885/comments"},"review_comment":{"href":"https://api.github.com/repos/sfackler/rust-openssl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sfackler/rust-openssl/pulls/885/commits"},"statuses":{"href":"https://api.github.com/repos/sfackler/rust-openssl/statuses/f157c9605fbf27e6218f477430c8bfb130ff82ac"}},"author_association":"NONE"}}
{"actor":{"display_login":"sfackler"}}