{"action":"created","comment":{"url":"https://api.github.com/repos/dedis/cothority/pulls/comments/242836131","pull_request_review_id":186442684,"id":242836131,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MjgzNjEzMQ==","diff_hunk":"@@ -0,0 +1,521 @@\n+package ch.epfl.dedis.lib.crypto.bn256;\n+\n+import java.math.BigInteger;\n+import java.util.Arrays;\n+import java.util.Random;\n+\n+public class BN {\n+    /**\n+     * The pair of a G1 point and a scalar that is used to generate it.\n+     */\n+    public static class PairG1 {\n+        public BigInteger k;\n+        public G1 p;\n+\n+        public PairG1(BigInteger k, G1 p) {\n+            this.k = k;\n+            this.p = p;\n+        }\n+    }\n+\n+    /**\n+     * The pair of a G2 point and a scalar that is used to generate it.\n+     */\n+    public static class PairG2 {\n+        public BigInteger k;\n+        public G2 p;\n+\n+        public PairG2(BigInteger k, G2 p) {\n+            this.k = k;\n+            this.p = p;\n+        }\n+    }\n+\n+    /**\n+     * A point in G1. This object is <em>not</em> thread-safe.\n+     */\n+    public static class G1 {\n+        CurvePoint p;\n+\n+        /**\n+         * Construct a G1 point. There is no guarantee on its value, please set it later.\n+         */\n+        public G1() {\n+            this.p = new CurvePoint();\n+        }\n+\n+        /**\n+         * Construct a G1 point using a given curve point.\n+         *\n+         * @param p is the curve point.\n+         */\n+        public G1(CurvePoint p) {\n+            this.p = p;\n+        }\n+\n+        /**\n+         * Copy constructor for G1.\n+         *\n+         * @param p point to copy.\n+         */\n+        public G1(G1 p) {\n+            this.p = new CurvePoint(p.p);\n+        }\n+\n+        /**\n+         * Construct a point for a scalar.\n+         *\n+         * @param k is the scalar that is multiplied to the generator point to create the object.\n+         */\n+        public G1(BigInteger k) {\n+            this.p = new CurvePoint().mul(CurvePoint.curveGen, k);\n+        }\n+\n+        /**\n+         * Generate a random pair of a point and a scalar that is used to create the point.\n+         *\n+         * @param rnd is the random source.\n+         * @return a pair of a point and a scalar.\n+         */\n+        public static PairG1 rand(Random rnd) {\n+            BigInteger k = randPosBigInt(rnd, Constants.order);\n+            G1 p = new G1().scalarBaseMul(k);\n+            return new PairG1(k, p);\n+        }\n+\n+        public String toString() {","path":"external/java/src/main/java/ch/epfl/dedis/lib/crypto/bn256/BN.java","position":86,"original_position":86,"commit_id":"2db4ca187d55e3e9583c56543b18c7a1c8f692e6","original_commit_id":"2db4ca187d55e3e9583c56543b18c7a1c8f692e6","user":{"login":"Gilthoniel","id":3636503,"node_id":"MDQ6VXNlcjM2MzY1MDM=","avatar_url":"https://avatars0.githubusercontent.com/u/3636503?v=4","gravatar_id":"","url":"https://api.github.com/users/Gilthoniel","html_url":"https://github.com/Gilthoniel","followers_url":"https://api.github.com/users/Gilthoniel/followers","following_url":"https://api.github.com/users/Gilthoniel/following{/other_user}","gists_url":"https://api.github.com/users/Gilthoniel/gists{/gist_id}","starred_url":"https://api.github.com/users/Gilthoniel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gilthoniel/subscriptions","organizations_url":"https://api.github.com/users/Gilthoniel/orgs","repos_url":"https://api.github.com/users/Gilthoniel/repos","events_url":"https://api.github.com/users/Gilthoniel/events{/privacy}","received_events_url":"https://api.github.com/users/Gilthoniel/received_events","type":"User","site_admin":false},"body":"Override (cannot add the @ without pinging someone..)","created_at":"2018-12-19T09:02:35Z","updated_at":"2018-12-19T09:19:29Z","html_url":"https://github.com/dedis/cothority/pull/1636#discussion_r242836131","pull_request_url":"https://api.github.com/repos/dedis/cothority/pulls/1636","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/dedis/cothority/pulls/comments/242836131"},"html":{"href":"https://github.com/dedis/cothority/pull/1636#discussion_r242836131"},"pull_request":{"href":"https://api.github.com/repos/dedis/cothority/pulls/1636"}}},"pull_request":{"url":"https://api.github.com/repos/dedis/cothority/pulls/1636","id":239241721,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM5MjQxNzIx","html_url":"https://github.com/dedis/cothority/pull/1636","diff_url":"https://github.com/dedis/cothority/pull/1636.diff","patch_url":"https://github.com/dedis/cothority/pull/1636.patch","issue_url":"https://api.github.com/repos/dedis/cothority/issues/1636","number":1636,"state":"open","locked":false,"title":"Implement bn256 in Java","user":{"login":"kc1212","id":1093806,"node_id":"MDQ6VXNlcjEwOTM4MDY=","avatar_url":"https://avatars0.githubusercontent.com/u/1093806?v=4","gravatar_id":"","url":"https://api.github.com/users/kc1212","html_url":"https://github.com/kc1212","followers_url":"https://api.github.com/users/kc1212/followers","following_url":"https://api.github.com/users/kc1212/following{/other_user}","gists_url":"https://api.github.com/users/kc1212/gists{/gist_id}","starred_url":"https://api.github.com/users/kc1212/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kc1212/subscriptions","organizations_url":"https://api.github.com/users/kc1212/orgs","repos_url":"https://api.github.com/users/kc1212/repos","events_url":"https://api.github.com/users/kc1212/events{/privacy}","received_events_url":"https://api.github.com/users/kc1212/received_events","type":"User","site_admin":false},"body":"This is an implementation ported directly from https://github.com/golang/crypto/tree/505ab145d0a99da450461ae2c1a9f6cd10d1f447/bn256 (note the revision number). The goal is to keep it as close to the golang implementation as possible so that we can easily compare and keep it up-to-date. Which means some parts might not be idiomatic in Java, which is the intention. \r\n\r\nOf course, there are differences that are impossible to avoid. The main one is that we do not use `bnPool` because the Java `BigInteger` is immutable, so there is no reason to keep the pool to save allocation. Further, the random point/field generation is also a bit different due to differences in standard libraries.\r\n\r\nThis PR is intended to be the first step in a series of PRs that will add pairing based crypto to Java. The next step will be to add a wrapper class, e.g., `ch.epfl.dedis.crypto.lib.crypto.{G1Scalar,G1Point,...}` that uses the `bn256` package (this one) but wraps it in a kyber-like way. Following that, the skipblock verification.\r\n\r\nFinally, some bench testing confirmed that there is no different in the byte representation between this implementation, the golang standard library one and the kyber/pairing one, even when the two are doing the the marshalling/unmarshalling in very different ways.\r\n\r\nCloses #1626","created_at":"2018-12-17T18:28:34Z","updated_at":"2018-12-19T09:19:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"82ec4cc42348c8ae0ae44ddd597b08f1da5868b7","assignee":{"login":"kc1212","id":1093806,"node_id":"MDQ6VXNlcjEwOTM4MDY=","avatar_url":"https://avatars0.githubusercontent.com/u/1093806?v=4","gravatar_id":"","url":"https://api.github.com/users/kc1212","html_url":"https://github.com/kc1212","followers_url":"https://api.github.com/users/kc1212/followers","following_url":"https://api.github.com/users/kc1212/following{/other_user}","gists_url":"https://api.github.com/users/kc1212/gists{/gist_id}","starred_url":"https://api.github.com/users/kc1212/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kc1212/subscriptions","organizations_url":"https://api.github.com/users/kc1212/orgs","repos_url":"https://api.github.com/users/kc1212/repos","events_url":"https://api.github.com/users/kc1212/events{/privacy}","received_events_url":"https://api.github.com/users/kc1212/received_events","type":"User","site_admin":false},"assignees":[{"login":"kc1212","id":1093806,"node_id":"MDQ6VXNlcjEwOTM4MDY=","avatar_url":"https://avatars0.githubusercontent.com/u/1093806?v=4","gravatar_id":"","url":"https://api.github.com/users/kc1212","html_url":"https://github.com/kc1212","followers_url":"https://api.github.com/users/kc1212/followers","following_url":"https://api.github.com/users/kc1212/following{/other_user}","gists_url":"https://api.github.com/users/kc1212/gists{/gist_id}","starred_url":"https://api.github.com/users/kc1212/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kc1212/subscriptions","organizations_url":"https://api.github.com/users/kc1212/orgs","repos_url":"https://api.github.com/users/kc1212/repos","events_url":"https://api.github.com/users/kc1212/events{/privacy}","received_events_url":"https://api.github.com/users/kc1212/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dedis/cothority/pulls/1636/commits","review_comments_url":"https://api.github.com/repos/dedis/cothority/pulls/1636/comments","review_comment_url":"https://api.github.com/repos/dedis/cothority/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dedis/cothority/issues/1636/comments","statuses_url":"https://api.github.com/repos/dedis/cothority/statuses/2db4ca187d55e3e9583c56543b18c7a1c8f692e6","head":{"label":"dedis:bn256_java","ref":"bn256_java","sha":"2db4ca187d55e3e9583c56543b18c7a1c8f692e6","user":{"login":"dedis","id":3638331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2MzgzMzE=","avatar_url":"https://avatars2.githubusercontent.com/u/3638331?v=4","gravatar_id":"","url":"https://api.github.com/users/dedis","html_url":"https://github.com/dedis","followers_url":"https://api.github.com/users/dedis/followers","following_url":"https://api.github.com/users/dedis/following{/other_user}","gists_url":"https://api.github.com/users/dedis/gists{/gist_id}","starred_url":"https://api.github.com/users/dedis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dedis/subscriptions","organizations_url":"https://api.github.com/users/dedis/orgs","repos_url":"https://api.github.com/users/dedis/repos","events_url":"https://api.github.com/users/dedis/events{/privacy}","received_events_url":"https://api.github.com/users/dedis/received_events","type":"Organization","site_admin":false},"repo":{"id":41791684,"node_id":"MDEwOlJlcG9zaXRvcnk0MTc5MTY4NA==","name":"cothority","full_name":"dedis/cothority","private":false,"owner":{"login":"dedis","id":3638331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2MzgzMzE=","avatar_url":"https://avatars2.githubusercontent.com/u/3638331?v=4","gravatar_id":"","url":"https://api.github.com/users/dedis","html_url":"https://github.com/dedis","followers_url":"https://api.github.com/users/dedis/followers","following_url":"https://api.github.com/users/dedis/following{/other_user}","gists_url":"https://api.github.com/users/dedis/gists{/gist_id}","starred_url":"https://api.github.com/users/dedis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dedis/subscriptions","organizations_url":"https://api.github.com/users/dedis/orgs","repos_url":"https://api.github.com/users/dedis/repos","events_url":"https://api.github.com/users/dedis/events{/privacy}","received_events_url":"https://api.github.com/users/dedis/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/dedis/cothority","description":"Scalable collective authority","fork":false,"url":"https://api.github.com/repos/dedis/cothority","forks_url":"https://api.github.com/repos/dedis/cothority/forks","keys_url":"https://api.github.com/repos/dedis/cothority/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dedis/cothority/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dedis/cothority/teams","hooks_url":"https://api.github.com/repos/dedis/cothority/hooks","issue_events_url":"https://api.github.com/repos/dedis/cothority/issues/events{/number}","events_url":"https://api.github.com/repos/dedis/cothority/events","assignees_url":"https://api.github.com/repos/dedis/cothority/assignees{/user}","branches_url":"https://api.github.com/repos/dedis/cothority/branches{/branch}","tags_url":"https://api.github.com/repos/dedis/cothority/tags","blobs_url":"https://api.github.com/repos/dedis/cothority/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dedis/cothority/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dedis/cothority/git/refs{/sha}","trees_url":"https://api.github.com/repos/dedis/cothority/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dedis/cothority/statuses/{sha}","languages_url":"https://api.github.com/repos/dedis/cothority/languages","stargazers_url":"https://api.github.com/repos/dedis/cothority/stargazers","contributors_url":"https://api.github.com/repos/dedis/cothority/contributors","subscribers_url":"https://api.github.com/repos/dedis/cothority/subscribers","subscription_url":"https://api.github.com/repos/dedis/cothority/subscription","commits_url":"https://api.github.com/repos/dedis/cothority/commits{/sha}","git_commits_url":"https://api.github.com/repos/dedis/cothority/git/commits{/sha}","comments_url":"https://api.github.com/repos/dedis/cothority/comments{/number}","issue_comment_url":"https://api.github.com/repos/dedis/cothority/issues/comments{/number}","contents_url":"https://api.github.com/repos/dedis/cothority/contents/{+path}","compare_url":"https://api.github.com/repos/dedis/cothority/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dedis/cothority/merges","archive_url":"https://api.github.com/repos/dedis/cothority/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dedis/cothority/downloads","issues_url":"https://api.github.com/repos/dedis/cothority/issues{/number}","pulls_url":"https://api.github.com/repos/dedis/cothority/pulls{/number}","milestones_url":"https://api.github.com/repos/dedis/cothority/milestones{/number}","notifications_url":"https://api.github.com/repos/dedis/cothority/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dedis/cothority/labels{/name}","releases_url":"https://api.github.com/repos/dedis/cothority/releases{/id}","deployments_url":"https://api.github.com/repos/dedis/cothority/deployments","created_at":"2015-09-02T09:13:57Z","updated_at":"2018-12-19T03:40:11Z","pushed_at":"2018-12-19T08:45:41Z","git_url":"git://github.com/dedis/cothority.git","ssh_url":"git@github.com:dedis/cothority.git","clone_url":"https://github.com/dedis/cothority.git","svn_url":"https://github.com/dedis/cothority","homepage":"","size":105586,"stargazers_count":272,"watchers_count":272,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":67,"mirror_url":null,"archived":false,"open_issues_count":107,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":67,"open_issues":107,"watchers":272,"default_branch":"master"}},"base":{"label":"dedis:master","ref":"master","sha":"4bca969b1dcd9c516ca2777bd93ba871884ddb6d","user":{"login":"dedis","id":3638331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2MzgzMzE=","avatar_url":"https://avatars2.githubusercontent.com/u/3638331?v=4","gravatar_id":"","url":"https://api.github.com/users/dedis","html_url":"https://github.com/dedis","followers_url":"https://api.github.com/users/dedis/followers","following_url":"https://api.github.com/users/dedis/following{/other_user}","gists_url":"https://api.github.com/users/dedis/gists{/gist_id}","starred_url":"https://api.github.com/users/dedis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dedis/subscriptions","organizations_url":"https://api.github.com/users/dedis/orgs","repos_url":"https://api.github.com/users/dedis/repos","events_url":"https://api.github.com/users/dedis/events{/privacy}","received_events_url":"https://api.github.com/users/dedis/received_events","type":"Organization","site_admin":false},"repo":{"id":41791684,"node_id":"MDEwOlJlcG9zaXRvcnk0MTc5MTY4NA==","name":"cothority","full_name":"dedis/cothority","private":false,"owner":{"login":"dedis","id":3638331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2MzgzMzE=","avatar_url":"https://avatars2.githubusercontent.com/u/3638331?v=4","gravatar_id":"","url":"https://api.github.com/users/dedis","html_url":"https://github.com/dedis","followers_url":"https://api.github.com/users/dedis/followers","following_url":"https://api.github.com/users/dedis/following{/other_user}","gists_url":"https://api.github.com/users/dedis/gists{/gist_id}","starred_url":"https://api.github.com/users/dedis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dedis/subscriptions","organizations_url":"https://api.github.com/users/dedis/orgs","repos_url":"https://api.github.com/users/dedis/repos","events_url":"https://api.github.com/users/dedis/events{/privacy}","received_events_url":"https://api.github.com/users/dedis/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/dedis/cothority","description":"Scalable collective authority","fork":false,"url":"https://api.github.com/repos/dedis/cothority","forks_url":"https://api.github.com/repos/dedis/cothority/forks","keys_url":"https://api.github.com/repos/dedis/cothority/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dedis/cothority/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dedis/cothority/teams","hooks_url":"https://api.github.com/repos/dedis/cothority/hooks","issue_events_url":"https://api.github.com/repos/dedis/cothority/issues/events{/number}","events_url":"https://api.github.com/repos/dedis/cothority/events","assignees_url":"https://api.github.com/repos/dedis/cothority/assignees{/user}","branches_url":"https://api.github.com/repos/dedis/cothority/branches{/branch}","tags_url":"https://api.github.com/repos/dedis/cothority/tags","blobs_url":"https://api.github.com/repos/dedis/cothority/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dedis/cothority/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dedis/cothority/git/refs{/sha}","trees_url":"https://api.github.com/repos/dedis/cothority/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dedis/cothority/statuses/{sha}","languages_url":"https://api.github.com/repos/dedis/cothority/languages","stargazers_url":"https://api.github.com/repos/dedis/cothority/stargazers","contributors_url":"https://api.github.com/repos/dedis/cothority/contributors","subscribers_url":"https://api.github.com/repos/dedis/cothority/subscribers","subscription_url":"https://api.github.com/repos/dedis/cothority/subscription","commits_url":"https://api.github.com/repos/dedis/cothority/commits{/sha}","git_commits_url":"https://api.github.com/repos/dedis/cothority/git/commits{/sha}","comments_url":"https://api.github.com/repos/dedis/cothority/comments{/number}","issue_comment_url":"https://api.github.com/repos/dedis/cothority/issues/comments{/number}","contents_url":"https://api.github.com/repos/dedis/cothority/contents/{+path}","compare_url":"https://api.github.com/repos/dedis/cothority/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dedis/cothority/merges","archive_url":"https://api.github.com/repos/dedis/cothority/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dedis/cothority/downloads","issues_url":"https://api.github.com/repos/dedis/cothority/issues{/number}","pulls_url":"https://api.github.com/repos/dedis/cothority/pulls{/number}","milestones_url":"https://api.github.com/repos/dedis/cothority/milestones{/number}","notifications_url":"https://api.github.com/repos/dedis/cothority/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dedis/cothority/labels{/name}","releases_url":"https://api.github.com/repos/dedis/cothority/releases{/id}","deployments_url":"https://api.github.com/repos/dedis/cothority/deployments","created_at":"2015-09-02T09:13:57Z","updated_at":"2018-12-19T03:40:11Z","pushed_at":"2018-12-19T08:45:41Z","git_url":"git://github.com/dedis/cothority.git","ssh_url":"git@github.com:dedis/cothority.git","clone_url":"https://github.com/dedis/cothority.git","svn_url":"https://github.com/dedis/cothority","homepage":"","size":105586,"stargazers_count":272,"watchers_count":272,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":67,"mirror_url":null,"archived":false,"open_issues_count":107,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":67,"open_issues":107,"watchers":272,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dedis/cothority/pulls/1636"},"html":{"href":"https://github.com/dedis/cothority/pull/1636"},"issue":{"href":"https://api.github.com/repos/dedis/cothority/issues/1636"},"comments":{"href":"https://api.github.com/repos/dedis/cothority/issues/1636/comments"},"review_comments":{"href":"https://api.github.com/repos/dedis/cothority/pulls/1636/comments"},"review_comment":{"href":"https://api.github.com/repos/dedis/cothority/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dedis/cothority/pulls/1636/commits"},"statuses":{"href":"https://api.github.com/repos/dedis/cothority/statuses/2db4ca187d55e3e9583c56543b18c7a1c8f692e6"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Gilthoniel"}}