{"action":"created","comment":{"url":"https://api.github.com/repos/holochain/holochain-rust/pulls/comments/233939098","pull_request_review_id":175469510,"id":233939098,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMzkzOTA5OA==","diff_hunk":"@@ -1,43 +1,104 @@\n-use cas::content::{AddressableContent, Content};\n+use cas::content::{Address, AddressableContent, Content};\n use entry::{Entry, ToEntry};\n use entry_type::EntryType;\n use json::JsonString;\n \n-/// Object holding an Agent's identity.\n-#[derive(Clone, Debug, PartialEq)]\n-pub struct Identity(Content);\n+use std::convert::TryFrom;\n+\n+use super::super::error::HolochainError;\n+use reed_solomon::{Decoder, Encoder};\n+\n+const PARITY_LEN: usize = 2;\n+\n+pub type Identity = String;\n+\n+#[derive(Clone)]\n+pub struct IdentityBuffer([u8; 64]);\n+\n+impl IdentityBuffer {\n+    pub fn parse(s: &str) -> Result<IdentityBuffer, HolochainError> {\n+        let s = s.replace(\"-\", \"+\").replace(\"_\", \"/\");\n+        let s = base64::decode(&s)?;\n+        let dec = Decoder::new(PARITY_LEN);\n+        let dec = *dec.correct(s.as_slice(), None)?;\n+        Ok(IdentityBuffer(array_ref![dec, 0, 64].clone()))\n+    }\n+\n+    pub fn get_sig(&self) -> &[u8; 32] {\n+        array_ref![self.0, 0, 32]\n+    }\n \n-impl From<Identity> for JsonString {\n-    fn from(identity: Identity) -> JsonString {\n-        identity.0\n+    pub fn get_enc(&self) -> &[u8; 32] {\n+        array_ref![self.0, 32, 32]\n     }\n }\n \n-impl From<JsonString> for Identity {\n-    fn from(json_string: JsonString) -> Identity {\n-        Identity(json_string)\n+#[derive(Clone, Debug, PartialEq)]\n+pub struct Agent(Identity);\n+\n+impl Agent {\n+    pub fn generate_fake(s: &str) -> Self {\n+        let mut s = s.to_string();\n+        while s.len() < 85 {\n+            s.push_str(\"+\");\n+        }\n+        s.push_str(\"A==\");\n+        let s = base64::decode(&s)\n+            .expect(\"could not decode the generated fake base64 string - use the base64 alphabet\");\n+        let s = IdentityBuffer(array_ref![s, 0, 64].clone());\n+        Agent::render(&s)\n+    }\n+\n+    pub fn render(b: &IdentityBuffer) -> Self {\n+        let enc = Encoder::new(PARITY_LEN);\n+        let enc = *enc.encode(&b.0);\n+        Agent(base64::encode(&enc[..]).replace(\"+\", \"-\").replace(\"/\", \"_\"))","path":"core_types/src/entry/agent.rs","position":null,"original_position":65,"commit_id":"e2e56365e0165b03b56151bc1c6bfff94792387a","original_commit_id":"a17914e6e341dd71f6d994778ad006465e87e717","user":{"login":"neonphog","id":796339,"node_id":"MDQ6VXNlcjc5NjMzOQ==","avatar_url":"https://avatars0.githubusercontent.com/u/796339?v=4","gravatar_id":"","url":"https://api.github.com/users/neonphog","html_url":"https://github.com/neonphog","followers_url":"https://api.github.com/users/neonphog/followers","following_url":"https://api.github.com/users/neonphog/following{/other_user}","gists_url":"https://api.github.com/users/neonphog/gists{/gist_id}","starred_url":"https://api.github.com/users/neonphog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neonphog/subscriptions","organizations_url":"https://api.github.com/users/neonphog/orgs","repos_url":"https://api.github.com/users/neonphog/repos","events_url":"https://api.github.com/users/neonphog/events{/privacy}","received_events_url":"https://api.github.com/users/neonphog/received_events","type":"User","site_admin":false},"body":"Yep, we need users to be able to copy / paste these ids around, and we add some parity bits that can act as a checksum as well as doing up to one byte of reed-solomon error correction. Added some comments.","created_at":"2018-11-15T17:29:55Z","updated_at":"2018-11-15T17:29:55Z","html_url":"https://github.com/holochain/holochain-rust/pull/623#discussion_r233939098","pull_request_url":"https://api.github.com/repos/holochain/holochain-rust/pulls/623","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/holochain/holochain-rust/pulls/comments/233939098"},"html":{"href":"https://github.com/holochain/holochain-rust/pull/623#discussion_r233939098"},"pull_request":{"href":"https://api.github.com/repos/holochain/holochain-rust/pulls/623"}},"in_reply_to_id":233842213},"pull_request":{"url":"https://api.github.com/repos/holochain/holochain-rust/pulls/623","id":230677625,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMwNjc3NjI1","html_url":"https://github.com/holochain/holochain-rust/pull/623","diff_url":"https://github.com/holochain/holochain-rust/pull/623.diff","patch_url":"https://github.com/holochain/holochain-rust/pull/623.patch","issue_url":"https://api.github.com/repos/holochain/holochain-rust/issues/623","number":623,"state":"open","locked":false,"title":"AgentId core_type","user":{"login":"neonphog","id":796339,"node_id":"MDQ6VXNlcjc5NjMzOQ==","avatar_url":"https://avatars0.githubusercontent.com/u/796339?v=4","gravatar_id":"","url":"https://api.github.com/users/neonphog","html_url":"https://github.com/neonphog","followers_url":"https://api.github.com/users/neonphog/followers","following_url":"https://api.github.com/users/neonphog/following{/other_user}","gists_url":"https://api.github.com/users/neonphog/gists{/gist_id}","starred_url":"https://api.github.com/users/neonphog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neonphog/subscriptions","organizations_url":"https://api.github.com/users/neonphog/orgs","repos_url":"https://api.github.com/users/neonphog/repos","events_url":"https://api.github.com/users/neonphog/events{/privacy}","received_events_url":"https://api.github.com/users/neonphog/received_events","type":"User","site_admin":false},"body":"Provides a type for agent identifiers per https://docs.google.com/document/d/1qoAk2NpML_WTZtNE44ZZ33WNIuHnrrPd-ojj93SZMck/edit#heading=h.3a4cbeqn4a2 including the reed-solomon parity bytes in the base64url string representation.\r\n\r\nNote that this doesn't provide any utilities for generating the IDs, that'll be part of the dpki effort... we can just fill them with random data for testing until then.","created_at":"2018-11-14T01:05:27Z","updated_at":"2018-11-15T17:29:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f85a10b67723e1019b1fd2caafa10982b5d5315d","assignee":null,"assignees":[],"requested_reviewers":[{"login":"thedavidmeister","id":629710,"node_id":"MDQ6VXNlcjYyOTcxMA==","avatar_url":"https://avatars2.githubusercontent.com/u/629710?v=4","gravatar_id":"","url":"https://api.github.com/users/thedavidmeister","html_url":"https://github.com/thedavidmeister","followers_url":"https://api.github.com/users/thedavidmeister/followers","following_url":"https://api.github.com/users/thedavidmeister/following{/other_user}","gists_url":"https://api.github.com/users/thedavidmeister/gists{/gist_id}","starred_url":"https://api.github.com/users/thedavidmeister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thedavidmeister/subscriptions","organizations_url":"https://api.github.com/users/thedavidmeister/orgs","repos_url":"https://api.github.com/users/thedavidmeister/repos","events_url":"https://api.github.com/users/thedavidmeister/events{/privacy}","received_events_url":"https://api.github.com/users/thedavidmeister/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":937673517,"node_id":"MDU6TGFiZWw5Mzc2NzM1MTc=","url":"https://api.github.com/repos/holochain/holochain-rust/labels/review","name":"review","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/holochain/holochain-rust/pulls/623/commits","review_comments_url":"https://api.github.com/repos/holochain/holochain-rust/pulls/623/comments","review_comment_url":"https://api.github.com/repos/holochain/holochain-rust/pulls/comments{/number}","comments_url":"https://api.github.com/repos/holochain/holochain-rust/issues/623/comments","statuses_url":"https://api.github.com/repos/holochain/holochain-rust/statuses/e2e56365e0165b03b56151bc1c6bfff94792387a","head":{"label":"holochain:agent-id","ref":"agent-id","sha":"e2e56365e0165b03b56151bc1c6bfff94792387a","user":{"login":"holochain","id":29492745,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5NDkyNzQ1","avatar_url":"https://avatars2.githubusercontent.com/u/29492745?v=4","gravatar_id":"","url":"https://api.github.com/users/holochain","html_url":"https://github.com/holochain","followers_url":"https://api.github.com/users/holochain/followers","following_url":"https://api.github.com/users/holochain/following{/other_user}","gists_url":"https://api.github.com/users/holochain/gists{/gist_id}","starred_url":"https://api.github.com/users/holochain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holochain/subscriptions","organizations_url":"https://api.github.com/users/holochain/orgs","repos_url":"https://api.github.com/users/holochain/repos","events_url":"https://api.github.com/users/holochain/events{/privacy}","received_events_url":"https://api.github.com/users/holochain/received_events","type":"Organization","site_admin":false},"repo":{"id":133449383,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM0NDkzODM=","name":"holochain-rust","full_name":"holochain/holochain-rust","private":false,"owner":{"login":"holochain","id":29492745,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5NDkyNzQ1","avatar_url":"https://avatars2.githubusercontent.com/u/29492745?v=4","gravatar_id":"","url":"https://api.github.com/users/holochain","html_url":"https://github.com/holochain","followers_url":"https://api.github.com/users/holochain/followers","following_url":"https://api.github.com/users/holochain/following{/other_user}","gists_url":"https://api.github.com/users/holochain/gists{/gist_id}","starred_url":"https://api.github.com/users/holochain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holochain/subscriptions","organizations_url":"https://api.github.com/users/holochain/orgs","repos_url":"https://api.github.com/users/holochain/repos","events_url":"https://api.github.com/users/holochain/events{/privacy}","received_events_url":"https://api.github.com/users/holochain/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/holochain/holochain-rust","description":"The core Holochain framework written in Rust, a container API for that, and hdk-rust library for Zomes","fork":false,"url":"https://api.github.com/repos/holochain/holochain-rust","forks_url":"https://api.github.com/repos/holochain/holochain-rust/forks","keys_url":"https://api.github.com/repos/holochain/holochain-rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/holochain/holochain-rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/holochain/holochain-rust/teams","hooks_url":"https://api.github.com/repos/holochain/holochain-rust/hooks","issue_events_url":"https://api.github.com/repos/holochain/holochain-rust/issues/events{/number}","events_url":"https://api.github.com/repos/holochain/holochain-rust/events","assignees_url":"https://api.github.com/repos/holochain/holochain-rust/assignees{/user}","branches_url":"https://api.github.com/repos/holochain/holochain-rust/branches{/branch}","tags_url":"https://api.github.com/repos/holochain/holochain-rust/tags","blobs_url":"https://api.github.com/repos/holochain/holochain-rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/holochain/holochain-rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/holochain/holochain-rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/holochain/holochain-rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/holochain/holochain-rust/statuses/{sha}","languages_url":"https://api.github.com/repos/holochain/holochain-rust/languages","stargazers_url":"https://api.github.com/repos/holochain/holochain-rust/stargazers","contributors_url":"https://api.github.com/repos/holochain/holochain-rust/contributors","subscribers_url":"https://api.github.com/repos/holochain/holochain-rust/subscribers","subscription_url":"https://api.github.com/repos/holochain/holochain-rust/subscription","commits_url":"https://api.github.com/repos/holochain/holochain-rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/holochain/holochain-rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/holochain/holochain-rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/holochain/holochain-rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/holochain/holochain-rust/contents/{+path}","compare_url":"https://api.github.com/repos/holochain/holochain-rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/holochain/holochain-rust/merges","archive_url":"https://api.github.com/repos/holochain/holochain-rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/holochain/holochain-rust/downloads","issues_url":"https://api.github.com/repos/holochain/holochain-rust/issues{/number}","pulls_url":"https://api.github.com/repos/holochain/holochain-rust/pulls{/number}","milestones_url":"https://api.github.com/repos/holochain/holochain-rust/milestones{/number}","notifications_url":"https://api.github.com/repos/holochain/holochain-rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/holochain/holochain-rust/labels{/name}","releases_url":"https://api.github.com/repos/holochain/holochain-rust/releases{/id}","deployments_url":"https://api.github.com/repos/holochain/holochain-rust/deployments","created_at":"2018-05-15T02:42:12Z","updated_at":"2018-11-15T10:49:00Z","pushed_at":"2018-11-15T17:26:36Z","git_url":"git://github.com/holochain/holochain-rust.git","ssh_url":"git@github.com:holochain/holochain-rust.git","clone_url":"https://github.com/holochain/holochain-rust.git","svn_url":"https://github.com/holochain/holochain-rust","homepage":"","size":150998,"stargazers_count":196,"watchers_count":196,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":39,"mirror_url":null,"archived":false,"open_issues_count":189,"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","node_id":"MDc6TGljZW5zZTk="},"forks":39,"open_issues":189,"watchers":196,"default_branch":"develop"}},"base":{"label":"holochain:develop","ref":"develop","sha":"8c6915ab78cfcfd8e9cf982e18374f612d91ef62","user":{"login":"holochain","id":29492745,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5NDkyNzQ1","avatar_url":"https://avatars2.githubusercontent.com/u/29492745?v=4","gravatar_id":"","url":"https://api.github.com/users/holochain","html_url":"https://github.com/holochain","followers_url":"https://api.github.com/users/holochain/followers","following_url":"https://api.github.com/users/holochain/following{/other_user}","gists_url":"https://api.github.com/users/holochain/gists{/gist_id}","starred_url":"https://api.github.com/users/holochain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holochain/subscriptions","organizations_url":"https://api.github.com/users/holochain/orgs","repos_url":"https://api.github.com/users/holochain/repos","events_url":"https://api.github.com/users/holochain/events{/privacy}","received_events_url":"https://api.github.com/users/holochain/received_events","type":"Organization","site_admin":false},"repo":{"id":133449383,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM0NDkzODM=","name":"holochain-rust","full_name":"holochain/holochain-rust","private":false,"owner":{"login":"holochain","id":29492745,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5NDkyNzQ1","avatar_url":"https://avatars2.githubusercontent.com/u/29492745?v=4","gravatar_id":"","url":"https://api.github.com/users/holochain","html_url":"https://github.com/holochain","followers_url":"https://api.github.com/users/holochain/followers","following_url":"https://api.github.com/users/holochain/following{/other_user}","gists_url":"https://api.github.com/users/holochain/gists{/gist_id}","starred_url":"https://api.github.com/users/holochain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holochain/subscriptions","organizations_url":"https://api.github.com/users/holochain/orgs","repos_url":"https://api.github.com/users/holochain/repos","events_url":"https://api.github.com/users/holochain/events{/privacy}","received_events_url":"https://api.github.com/users/holochain/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/holochain/holochain-rust","description":"The core Holochain framework written in Rust, a container API for that, and hdk-rust library for Zomes","fork":false,"url":"https://api.github.com/repos/holochain/holochain-rust","forks_url":"https://api.github.com/repos/holochain/holochain-rust/forks","keys_url":"https://api.github.com/repos/holochain/holochain-rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/holochain/holochain-rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/holochain/holochain-rust/teams","hooks_url":"https://api.github.com/repos/holochain/holochain-rust/hooks","issue_events_url":"https://api.github.com/repos/holochain/holochain-rust/issues/events{/number}","events_url":"https://api.github.com/repos/holochain/holochain-rust/events","assignees_url":"https://api.github.com/repos/holochain/holochain-rust/assignees{/user}","branches_url":"https://api.github.com/repos/holochain/holochain-rust/branches{/branch}","tags_url":"https://api.github.com/repos/holochain/holochain-rust/tags","blobs_url":"https://api.github.com/repos/holochain/holochain-rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/holochain/holochain-rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/holochain/holochain-rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/holochain/holochain-rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/holochain/holochain-rust/statuses/{sha}","languages_url":"https://api.github.com/repos/holochain/holochain-rust/languages","stargazers_url":"https://api.github.com/repos/holochain/holochain-rust/stargazers","contributors_url":"https://api.github.com/repos/holochain/holochain-rust/contributors","subscribers_url":"https://api.github.com/repos/holochain/holochain-rust/subscribers","subscription_url":"https://api.github.com/repos/holochain/holochain-rust/subscription","commits_url":"https://api.github.com/repos/holochain/holochain-rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/holochain/holochain-rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/holochain/holochain-rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/holochain/holochain-rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/holochain/holochain-rust/contents/{+path}","compare_url":"https://api.github.com/repos/holochain/holochain-rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/holochain/holochain-rust/merges","archive_url":"https://api.github.com/repos/holochain/holochain-rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/holochain/holochain-rust/downloads","issues_url":"https://api.github.com/repos/holochain/holochain-rust/issues{/number}","pulls_url":"https://api.github.com/repos/holochain/holochain-rust/pulls{/number}","milestones_url":"https://api.github.com/repos/holochain/holochain-rust/milestones{/number}","notifications_url":"https://api.github.com/repos/holochain/holochain-rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/holochain/holochain-rust/labels{/name}","releases_url":"https://api.github.com/repos/holochain/holochain-rust/releases{/id}","deployments_url":"https://api.github.com/repos/holochain/holochain-rust/deployments","created_at":"2018-05-15T02:42:12Z","updated_at":"2018-11-15T10:49:00Z","pushed_at":"2018-11-15T17:26:36Z","git_url":"git://github.com/holochain/holochain-rust.git","ssh_url":"git@github.com:holochain/holochain-rust.git","clone_url":"https://github.com/holochain/holochain-rust.git","svn_url":"https://github.com/holochain/holochain-rust","homepage":"","size":150998,"stargazers_count":196,"watchers_count":196,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":39,"mirror_url":null,"archived":false,"open_issues_count":189,"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","node_id":"MDc6TGljZW5zZTk="},"forks":39,"open_issues":189,"watchers":196,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/holochain/holochain-rust/pulls/623"},"html":{"href":"https://github.com/holochain/holochain-rust/pull/623"},"issue":{"href":"https://api.github.com/repos/holochain/holochain-rust/issues/623"},"comments":{"href":"https://api.github.com/repos/holochain/holochain-rust/issues/623/comments"},"review_comments":{"href":"https://api.github.com/repos/holochain/holochain-rust/pulls/623/comments"},"review_comment":{"href":"https://api.github.com/repos/holochain/holochain-rust/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/holochain/holochain-rust/pulls/623/commits"},"statuses":{"href":"https://api.github.com/repos/holochain/holochain-rust/statuses/e2e56365e0165b03b56151bc1c6bfff94792387a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"neonphog"}}