{"action":"created","comment":{"url":"https://api.github.com/repos/str4d/fpe/pulls/comments/202687956","pull_request_review_id":137432505,"id":202687956,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMjY4Nzk1Ng==","diff_hunk":"@@ -90,6 +98,54 @@ impl RadixOps<u16> for u16 {\n     }\n }\n \n+/// A radix 2^i for i in [1..16). It does not use floating-point arithmetic.\n+#[derive(Debug, PartialEq)]\n+pub struct PowerTwoRadix {\n+    radix: u16,\n+    log_radix: u8,\n+}\n+\n+impl PowerTwoRadix {\n+    pub fn from(radix: u16) -> Result<Self, ()> {\n+        let mut tmp = radix;\n+        let mut log_radix = 0;\n+        let mut found = false;\n+        for i in 0..16 {\n+            if tmp & 1 != 0 {\n+                // Only a single bit should be set\n+                if found {\n+                    return Err(());\n+                }\n+                log_radix = i;\n+                found = true;\n+            }\n+            tmp >>= 1;\n+        }\n+        match log_radix {\n+            0 => Err(()),\n+            _ => Ok(PowerTwoRadix { radix, log_radix }),\n+        }\n+    }\n+}\n+\n+impl RadixOps for PowerTwoRadix {\n+    fn check_in_range(&self, n: u32) -> bool {\n+        n >> self.log_radix == 0\n+    }\n+\n+    fn calculate_b(&self, v: usize) -> usize {\n+        ((v * self.log_radix as usize) + 7) / 8\n+    }\n+\n+    fn to_biguint(&self) -> BigUint {\n+        BigUint::from(self.radix)\n+    }\n+\n+    fn to_u32(&self) -> u32 {\n+        self.radix as u32\n+    }","path":"src/ff1.rs","position":118,"original_position":118,"commit_id":"cc83eb7efc3a2adb31cb01946174b11c9cf62798","original_commit_id":"cc83eb7efc3a2adb31cb01946174b11c9cf62798","user":{"login":"str4d","id":4993799,"node_id":"MDQ6VXNlcjQ5OTM3OTk=","avatar_url":"https://avatars0.githubusercontent.com/u/4993799?v=4","gravatar_id":"","url":"https://api.github.com/users/str4d","html_url":"https://github.com/str4d","followers_url":"https://api.github.com/users/str4d/followers","following_url":"https://api.github.com/users/str4d/following{/other_user}","gists_url":"https://api.github.com/users/str4d/gists{/gist_id}","starred_url":"https://api.github.com/users/str4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/str4d/subscriptions","organizations_url":"https://api.github.com/users/str4d/orgs","repos_url":"https://api.github.com/users/str4d/repos","events_url":"https://api.github.com/users/str4d/events{/privacy}","received_events_url":"https://api.github.com/users/str4d/received_events","type":"User","site_admin":false},"body":"Yeah, now that I've done the large refactor I think it's fine to do that, so I'll make those changes in a follow-up PR (along with the then-necessary constraining of the flexible radix to 2^16).","created_at":"2018-07-16T13:47:12Z","updated_at":"2018-07-16T13:47:12Z","html_url":"https://github.com/str4d/fpe/pull/5#discussion_r202687956","pull_request_url":"https://api.github.com/repos/str4d/fpe/pulls/5","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/str4d/fpe/pulls/comments/202687956"},"html":{"href":"https://github.com/str4d/fpe/pull/5#discussion_r202687956"},"pull_request":{"href":"https://api.github.com/repos/str4d/fpe/pulls/5"}},"in_reply_to_id":202681406},"pull_request":{"url":"https://api.github.com/repos/str4d/fpe/pulls/5","id":201444766,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAxNDQ0NzY2","html_url":"https://github.com/str4d/fpe/pull/5","diff_url":"https://github.com/str4d/fpe/pull/5.diff","patch_url":"https://github.com/str4d/fpe/pull/5.patch","issue_url":"https://api.github.com/repos/str4d/fpe/issues/5","number":5,"state":"open","locked":false,"title":"Implement PowerTwoRadix using no floating-point arithmetic","user":{"login":"str4d","id":4993799,"node_id":"MDQ6VXNlcjQ5OTM3OTk=","avatar_url":"https://avatars0.githubusercontent.com/u/4993799?v=4","gravatar_id":"","url":"https://api.github.com/users/str4d","html_url":"https://github.com/str4d","followers_url":"https://api.github.com/users/str4d/followers","following_url":"https://api.github.com/users/str4d/following{/other_user}","gists_url":"https://api.github.com/users/str4d/gists{/gist_id}","starred_url":"https://api.github.com/users/str4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/str4d/subscriptions","organizations_url":"https://api.github.com/users/str4d/orgs","repos_url":"https://api.github.com/users/str4d/repos","events_url":"https://api.github.com/users/str4d/events{/privacy}","received_events_url":"https://api.github.com/users/str4d/received_events","type":"User","site_admin":false},"body":"Also includes trait refactors to check that `NumeralString` is valid for the given `Radix`.\r\n\r\nCloses #2.","created_at":"2018-07-14T09:46:27Z","updated_at":"2018-07-16T13:47:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"690a29e0f841451952e29cbdac8d2c30a625d03c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/str4d/fpe/pulls/5/commits","review_comments_url":"https://api.github.com/repos/str4d/fpe/pulls/5/comments","review_comment_url":"https://api.github.com/repos/str4d/fpe/pulls/comments{/number}","comments_url":"https://api.github.com/repos/str4d/fpe/issues/5/comments","statuses_url":"https://api.github.com/repos/str4d/fpe/statuses/cc83eb7efc3a2adb31cb01946174b11c9cf62798","head":{"label":"str4d:power-two-radix","ref":"power-two-radix","sha":"cc83eb7efc3a2adb31cb01946174b11c9cf62798","user":{"login":"str4d","id":4993799,"node_id":"MDQ6VXNlcjQ5OTM3OTk=","avatar_url":"https://avatars0.githubusercontent.com/u/4993799?v=4","gravatar_id":"","url":"https://api.github.com/users/str4d","html_url":"https://github.com/str4d","followers_url":"https://api.github.com/users/str4d/followers","following_url":"https://api.github.com/users/str4d/following{/other_user}","gists_url":"https://api.github.com/users/str4d/gists{/gist_id}","starred_url":"https://api.github.com/users/str4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/str4d/subscriptions","organizations_url":"https://api.github.com/users/str4d/orgs","repos_url":"https://api.github.com/users/str4d/repos","events_url":"https://api.github.com/users/str4d/events{/privacy}","received_events_url":"https://api.github.com/users/str4d/received_events","type":"User","site_admin":false},"repo":{"id":139571316,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk1NzEzMTY=","name":"fpe","full_name":"str4d/fpe","owner":{"login":"str4d","id":4993799,"node_id":"MDQ6VXNlcjQ5OTM3OTk=","avatar_url":"https://avatars0.githubusercontent.com/u/4993799?v=4","gravatar_id":"","url":"https://api.github.com/users/str4d","html_url":"https://github.com/str4d","followers_url":"https://api.github.com/users/str4d/followers","following_url":"https://api.github.com/users/str4d/following{/other_user}","gists_url":"https://api.github.com/users/str4d/gists{/gist_id}","starred_url":"https://api.github.com/users/str4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/str4d/subscriptions","organizations_url":"https://api.github.com/users/str4d/orgs","repos_url":"https://api.github.com/users/str4d/repos","events_url":"https://api.github.com/users/str4d/events{/privacy}","received_events_url":"https://api.github.com/users/str4d/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/str4d/fpe","description":"Format-preserving encryption in Rust","fork":false,"url":"https://api.github.com/repos/str4d/fpe","forks_url":"https://api.github.com/repos/str4d/fpe/forks","keys_url":"https://api.github.com/repos/str4d/fpe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/str4d/fpe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/str4d/fpe/teams","hooks_url":"https://api.github.com/repos/str4d/fpe/hooks","issue_events_url":"https://api.github.com/repos/str4d/fpe/issues/events{/number}","events_url":"https://api.github.com/repos/str4d/fpe/events","assignees_url":"https://api.github.com/repos/str4d/fpe/assignees{/user}","branches_url":"https://api.github.com/repos/str4d/fpe/branches{/branch}","tags_url":"https://api.github.com/repos/str4d/fpe/tags","blobs_url":"https://api.github.com/repos/str4d/fpe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/str4d/fpe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/str4d/fpe/git/refs{/sha}","trees_url":"https://api.github.com/repos/str4d/fpe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/str4d/fpe/statuses/{sha}","languages_url":"https://api.github.com/repos/str4d/fpe/languages","stargazers_url":"https://api.github.com/repos/str4d/fpe/stargazers","contributors_url":"https://api.github.com/repos/str4d/fpe/contributors","subscribers_url":"https://api.github.com/repos/str4d/fpe/subscribers","subscription_url":"https://api.github.com/repos/str4d/fpe/subscription","commits_url":"https://api.github.com/repos/str4d/fpe/commits{/sha}","git_commits_url":"https://api.github.com/repos/str4d/fpe/git/commits{/sha}","comments_url":"https://api.github.com/repos/str4d/fpe/comments{/number}","issue_comment_url":"https://api.github.com/repos/str4d/fpe/issues/comments{/number}","contents_url":"https://api.github.com/repos/str4d/fpe/contents/{+path}","compare_url":"https://api.github.com/repos/str4d/fpe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/str4d/fpe/merges","archive_url":"https://api.github.com/repos/str4d/fpe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/str4d/fpe/downloads","issues_url":"https://api.github.com/repos/str4d/fpe/issues{/number}","pulls_url":"https://api.github.com/repos/str4d/fpe/pulls{/number}","milestones_url":"https://api.github.com/repos/str4d/fpe/milestones{/number}","notifications_url":"https://api.github.com/repos/str4d/fpe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/str4d/fpe/labels{/name}","releases_url":"https://api.github.com/repos/str4d/fpe/releases{/id}","deployments_url":"https://api.github.com/repos/str4d/fpe/deployments","created_at":"2018-07-03T11:07:10Z","updated_at":"2018-07-12T21:17:08Z","pushed_at":"2018-07-15T20:12:30Z","git_url":"git://github.com/str4d/fpe.git","ssh_url":"git@github.com:str4d/fpe.git","clone_url":"https://github.com/str4d/fpe.git","svn_url":"https://github.com/str4d/fpe","homepage":null,"size":36,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"str4d:master","ref":"master","sha":"c237504f464163445de017232a99e6157b11b026","user":{"login":"str4d","id":4993799,"node_id":"MDQ6VXNlcjQ5OTM3OTk=","avatar_url":"https://avatars0.githubusercontent.com/u/4993799?v=4","gravatar_id":"","url":"https://api.github.com/users/str4d","html_url":"https://github.com/str4d","followers_url":"https://api.github.com/users/str4d/followers","following_url":"https://api.github.com/users/str4d/following{/other_user}","gists_url":"https://api.github.com/users/str4d/gists{/gist_id}","starred_url":"https://api.github.com/users/str4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/str4d/subscriptions","organizations_url":"https://api.github.com/users/str4d/orgs","repos_url":"https://api.github.com/users/str4d/repos","events_url":"https://api.github.com/users/str4d/events{/privacy}","received_events_url":"https://api.github.com/users/str4d/received_events","type":"User","site_admin":false},"repo":{"id":139571316,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk1NzEzMTY=","name":"fpe","full_name":"str4d/fpe","owner":{"login":"str4d","id":4993799,"node_id":"MDQ6VXNlcjQ5OTM3OTk=","avatar_url":"https://avatars0.githubusercontent.com/u/4993799?v=4","gravatar_id":"","url":"https://api.github.com/users/str4d","html_url":"https://github.com/str4d","followers_url":"https://api.github.com/users/str4d/followers","following_url":"https://api.github.com/users/str4d/following{/other_user}","gists_url":"https://api.github.com/users/str4d/gists{/gist_id}","starred_url":"https://api.github.com/users/str4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/str4d/subscriptions","organizations_url":"https://api.github.com/users/str4d/orgs","repos_url":"https://api.github.com/users/str4d/repos","events_url":"https://api.github.com/users/str4d/events{/privacy}","received_events_url":"https://api.github.com/users/str4d/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/str4d/fpe","description":"Format-preserving encryption in Rust","fork":false,"url":"https://api.github.com/repos/str4d/fpe","forks_url":"https://api.github.com/repos/str4d/fpe/forks","keys_url":"https://api.github.com/repos/str4d/fpe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/str4d/fpe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/str4d/fpe/teams","hooks_url":"https://api.github.com/repos/str4d/fpe/hooks","issue_events_url":"https://api.github.com/repos/str4d/fpe/issues/events{/number}","events_url":"https://api.github.com/repos/str4d/fpe/events","assignees_url":"https://api.github.com/repos/str4d/fpe/assignees{/user}","branches_url":"https://api.github.com/repos/str4d/fpe/branches{/branch}","tags_url":"https://api.github.com/repos/str4d/fpe/tags","blobs_url":"https://api.github.com/repos/str4d/fpe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/str4d/fpe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/str4d/fpe/git/refs{/sha}","trees_url":"https://api.github.com/repos/str4d/fpe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/str4d/fpe/statuses/{sha}","languages_url":"https://api.github.com/repos/str4d/fpe/languages","stargazers_url":"https://api.github.com/repos/str4d/fpe/stargazers","contributors_url":"https://api.github.com/repos/str4d/fpe/contributors","subscribers_url":"https://api.github.com/repos/str4d/fpe/subscribers","subscription_url":"https://api.github.com/repos/str4d/fpe/subscription","commits_url":"https://api.github.com/repos/str4d/fpe/commits{/sha}","git_commits_url":"https://api.github.com/repos/str4d/fpe/git/commits{/sha}","comments_url":"https://api.github.com/repos/str4d/fpe/comments{/number}","issue_comment_url":"https://api.github.com/repos/str4d/fpe/issues/comments{/number}","contents_url":"https://api.github.com/repos/str4d/fpe/contents/{+path}","compare_url":"https://api.github.com/repos/str4d/fpe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/str4d/fpe/merges","archive_url":"https://api.github.com/repos/str4d/fpe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/str4d/fpe/downloads","issues_url":"https://api.github.com/repos/str4d/fpe/issues{/number}","pulls_url":"https://api.github.com/repos/str4d/fpe/pulls{/number}","milestones_url":"https://api.github.com/repos/str4d/fpe/milestones{/number}","notifications_url":"https://api.github.com/repos/str4d/fpe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/str4d/fpe/labels{/name}","releases_url":"https://api.github.com/repos/str4d/fpe/releases{/id}","deployments_url":"https://api.github.com/repos/str4d/fpe/deployments","created_at":"2018-07-03T11:07:10Z","updated_at":"2018-07-12T21:17:08Z","pushed_at":"2018-07-15T20:12:30Z","git_url":"git://github.com/str4d/fpe.git","ssh_url":"git@github.com:str4d/fpe.git","clone_url":"https://github.com/str4d/fpe.git","svn_url":"https://github.com/str4d/fpe","homepage":null,"size":36,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/str4d/fpe/pulls/5"},"html":{"href":"https://github.com/str4d/fpe/pull/5"},"issue":{"href":"https://api.github.com/repos/str4d/fpe/issues/5"},"comments":{"href":"https://api.github.com/repos/str4d/fpe/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/str4d/fpe/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/str4d/fpe/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/str4d/fpe/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/str4d/fpe/statuses/cc83eb7efc3a2adb31cb01946174b11c9cf62798"}},"author_association":"OWNER"}}
{"actor":{"display_login":"str4d"}}