{"action":"created","comment":{"url":"https://api.github.com/repos/paritytech/parity/pulls/comments/165623285","pull_request_review_id":93594418,"id":165623285,"diff_hunk":"@@ -0,0 +1,300 @@\n+// Copyright 2015-2017 Parity Technologies (UK) Ltd.\n+// This file is part of Parity.\n+\n+// Parity is free software: you can redistribute it and/or modify\n+// it under the terms of the GNU General Public License as published by\n+// the Free Software Foundation, either version 3 of the License, or\n+// (at your option) any later version.\n+\n+// Parity is distributed in the hope that it will be useful,\n+// but WITHOUT ANY WARRANTY; without even the implied warranty of\n+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+// GNU General Public License for more details.\n+\n+// You should have received a copy of the GNU General Public License\n+// along with Parity.  If not, see <http://www.gnu.org/licenses/>.\n+\n+//! Encryption providers.\n+\n+use std::sync::Arc;\n+use std::io::Read;\n+use std::iter::repeat;\n+use std::time::{Instant, Duration};\n+use std::collections::HashMap;\n+use std::collections::hash_map::Entry;\n+use parking_lot::Mutex;\n+use account_provider::AccountProvider;\n+use ethereum_types::{H128, Address};\n+use ethjson;\n+use ethkey::{Signature, Public};\n+use ethcrypto;\n+use futures::Future;\n+use fetch::{Fetch, Method as FetchMethod, Client as FetchClient};\n+use bytes::{Bytes, ToPretty};\n+use error::{Error as EthcoreError, PrivateTransactionError};\n+\n+/// Initialization vector length.\n+const INIT_VEC_LEN: usize = 16;\n+\n+/// Duration of storing retrieved keys (in ms)\n+const ENCRYPTION_SESSION_DURATION: u64 = 30 * 1000;\n+\n+/// Trait for encryption/decryption operations.\n+pub trait Encryptor: Send + Sync + 'static {\n+\t/// Generate unique contract key && encrypt passed data. Encryption can only be performed once.\n+\tfn encrypt(\n+\t\t&self,\n+\t\tcontract_address: &Address,\n+\t\tcontract_address_signature: &Signature,\n+\t\trequester: &Address,\n+\t\tunlocked_accounts: Arc<AccountProvider>,\n+\t\tinitialisation_vector: &H128,\n+\t\tplain_data: &[u8]\n+\t) -> Result<Bytes, EthcoreError>;\n+\n+\t/// Decrypt data using previously generated contract key.\n+\tfn decrypt(\n+\t\t&self,\n+\t\tcontract_address: &Address,\n+\t\tcontract_address_signature: &Signature,\n+\t\trequester: &Address,\n+\t\tunlocked_accounts: Arc<AccountProvider>,\n+\t\tcypher: &[u8]\n+\t) -> Result<Bytes, EthcoreError>;\n+}\n+\n+struct EncryptionSession {\n+\tkey: Bytes,\n+\tend_time: Instant,\n+}\n+\n+/// SecretStore-based encryption/decryption operations.\n+pub struct SecretStoreEncryptor {\n+\tclient: FetchClient,\n+\tbase_url: Option<String>,\n+\tthreshold: u32,\n+\tsessions: Mutex<HashMap<Address, EncryptionSession>>,\n+}\n+\n+impl SecretStoreEncryptor {\n+\t/// Create new encryptor with empty parameters.\n+\tpub fn empty() -> Result<Self, EthcoreError> {\n+\t\tOk(SecretStoreEncryptor {\n+\t\t\tclient: FetchClient::new()","path":"ethcore/src/private_transactions/encryptor.rs","position":83,"original_position":83,"commit_id":"f69e49e4095e7c2c5ca506eb46c9f8bfb30868ee","original_commit_id":"f69e49e4095e7c2c5ca506eb46c9f8bfb30868ee","user":{"login":"svyatonik","id":985319,"avatar_url":"https://avatars0.githubusercontent.com/u/985319?v=4","gravatar_id":"","url":"https://api.github.com/users/svyatonik","html_url":"https://github.com/svyatonik","followers_url":"https://api.github.com/users/svyatonik/followers","following_url":"https://api.github.com/users/svyatonik/following{/other_user}","gists_url":"https://api.github.com/users/svyatonik/gists{/gist_id}","starred_url":"https://api.github.com/users/svyatonik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svyatonik/subscriptions","organizations_url":"https://api.github.com/users/svyatonik/orgs","repos_url":"https://api.github.com/users/svyatonik/repos","events_url":"https://api.github.com/users/svyatonik/events{/privacy}","received_events_url":"https://api.github.com/users/svyatonik/received_events","type":"User","site_admin":false},"body":"The owner of `SecretStoreEncryptor` instance (`PrivateTransactionsProvider`) is reused (encryptor is only created when `set_config` is called here: https://github.com/paritytech/parity/pull/6422/files#diff-471e80c21627e94e8648551d9c5364f2R286 and `set_config` is only called once). So looks like it isn't a problem","created_at":"2018-02-02T11:35:40Z","updated_at":"2018-02-02T11:35:40Z","html_url":"https://github.com/paritytech/parity/pull/6422#discussion_r165623285","pull_request_url":"https://api.github.com/repos/paritytech/parity/pulls/6422","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/paritytech/parity/pulls/comments/165623285"},"html":{"href":"https://github.com/paritytech/parity/pull/6422#discussion_r165623285"},"pull_request":{"href":"https://api.github.com/repos/paritytech/parity/pulls/6422"}},"in_reply_to_id":165338814},"pull_request":{"url":"https://api.github.com/repos/paritytech/parity/pulls/6422","id":138462406,"html_url":"https://github.com/paritytech/parity/pull/6422","diff_url":"https://github.com/paritytech/parity/pull/6422.diff","patch_url":"https://github.com/paritytech/parity/pull/6422.patch","issue_url":"https://api.github.com/repos/paritytech/parity/issues/6422","number":6422,"state":"open","locked":false,"title":"Private transactions integration pr","user":{"login":"grbIzl","id":5435439,"avatar_url":"https://avatars2.githubusercontent.com/u/5435439?v=4","gravatar_id":"","url":"https://api.github.com/users/grbIzl","html_url":"https://github.com/grbIzl","followers_url":"https://api.github.com/users/grbIzl/followers","following_url":"https://api.github.com/users/grbIzl/following{/other_user}","gists_url":"https://api.github.com/users/grbIzl/gists{/gist_id}","starred_url":"https://api.github.com/users/grbIzl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grbIzl/subscriptions","organizations_url":"https://api.github.com/users/grbIzl/orgs","repos_url":"https://api.github.com/users/grbIzl/repos","events_url":"https://api.github.com/users/grbIzl/events{/privacy}","received_events_url":"https://api.github.com/users/grbIzl/received_events","type":"User","site_admin":false},"body":"This pr is used for integrating all the changes in terms of building private transactions system.\r\nWe tried to review changes made on every step, but didn't request the merge into the main brunch till the functionality was ready and tested\r\nSo it's ready now. The documentation with detailed description of the solution is available on wiki: https://paritytech.github.io/wiki/Private-Transactions.html ","created_at":"2017-08-30T15:47:18Z","updated_at":"2018-02-02T11:35:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f0a73ac28231b3b14719a23d1106a4a04961d9a","assignee":null,"assignees":[],"requested_reviewers":[{"login":"arkpar","id":9008569,"avatar_url":"https://avatars0.githubusercontent.com/u/9008569?v=4","gravatar_id":"","url":"https://api.github.com/users/arkpar","html_url":"https://github.com/arkpar","followers_url":"https://api.github.com/users/arkpar/followers","following_url":"https://api.github.com/users/arkpar/following{/other_user}","gists_url":"https://api.github.com/users/arkpar/gists{/gist_id}","starred_url":"https://api.github.com/users/arkpar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arkpar/subscriptions","organizations_url":"https://api.github.com/users/arkpar/orgs","repos_url":"https://api.github.com/users/arkpar/repos","events_url":"https://api.github.com/users/arkpar/events{/privacy}","received_events_url":"https://api.github.com/users/arkpar/received_events","type":"User","site_admin":false}],"requested_teams":[],"milestone":{"url":"https://api.github.com/repos/paritytech/parity/milestones/17","html_url":"https://github.com/paritytech/parity/milestone/17","labels_url":"https://api.github.com/repos/paritytech/parity/milestones/17/labels","id":2267408,"number":17,"title":"1.10","description":"","creator":{"login":"gavofyork","id":138296,"avatar_url":"https://avatars0.githubusercontent.com/u/138296?v=4","gravatar_id":"","url":"https://api.github.com/users/gavofyork","html_url":"https://github.com/gavofyork","followers_url":"https://api.github.com/users/gavofyork/followers","following_url":"https://api.github.com/users/gavofyork/following{/other_user}","gists_url":"https://api.github.com/users/gavofyork/gists{/gist_id}","starred_url":"https://api.github.com/users/gavofyork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gavofyork/subscriptions","organizations_url":"https://api.github.com/users/gavofyork/orgs","repos_url":"https://api.github.com/users/gavofyork/repos","events_url":"https://api.github.com/users/gavofyork/events{/privacy}","received_events_url":"https://api.github.com/users/gavofyork/received_events","type":"User","site_admin":false},"open_issues":114,"closed_issues":182,"state":"open","created_at":"2017-01-20T16:25:47Z","updated_at":"2018-02-02T11:31:58Z","due_on":"2018-03-05T08:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/paritytech/parity/pulls/6422/commits","review_comments_url":"https://api.github.com/repos/paritytech/parity/pulls/6422/comments","review_comment_url":"https://api.github.com/repos/paritytech/parity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/paritytech/parity/issues/6422/comments","statuses_url":"https://api.github.com/repos/paritytech/parity/statuses/f69e49e4095e7c2c5ca506eb46c9f8bfb30868ee","head":{"label":"paritytech:PrivateTransactionsNetwork","ref":"PrivateTransactionsNetwork","sha":"f69e49e4095e7c2c5ca506eb46c9f8bfb30868ee","user":{"login":"paritytech","id":14176906,"avatar_url":"https://avatars2.githubusercontent.com/u/14176906?v=4","gravatar_id":"","url":"https://api.github.com/users/paritytech","html_url":"https://github.com/paritytech","followers_url":"https://api.github.com/users/paritytech/followers","following_url":"https://api.github.com/users/paritytech/following{/other_user}","gists_url":"https://api.github.com/users/paritytech/gists{/gist_id}","starred_url":"https://api.github.com/users/paritytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paritytech/subscriptions","organizations_url":"https://api.github.com/users/paritytech/orgs","repos_url":"https://api.github.com/users/paritytech/repos","events_url":"https://api.github.com/users/paritytech/events{/privacy}","received_events_url":"https://api.github.com/users/paritytech/received_events","type":"Organization","site_admin":false},"repo":{"id":46714939,"name":"parity","full_name":"paritytech/parity","owner":{"login":"paritytech","id":14176906,"avatar_url":"https://avatars2.githubusercontent.com/u/14176906?v=4","gravatar_id":"","url":"https://api.github.com/users/paritytech","html_url":"https://github.com/paritytech","followers_url":"https://api.github.com/users/paritytech/followers","following_url":"https://api.github.com/users/paritytech/following{/other_user}","gists_url":"https://api.github.com/users/paritytech/gists{/gist_id}","starred_url":"https://api.github.com/users/paritytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paritytech/subscriptions","organizations_url":"https://api.github.com/users/paritytech/orgs","repos_url":"https://api.github.com/users/paritytech/repos","events_url":"https://api.github.com/users/paritytech/events{/privacy}","received_events_url":"https://api.github.com/users/paritytech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/paritytech/parity","description":"Fast, light, robust Ethereum implementation.","fork":false,"url":"https://api.github.com/repos/paritytech/parity","forks_url":"https://api.github.com/repos/paritytech/parity/forks","keys_url":"https://api.github.com/repos/paritytech/parity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paritytech/parity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paritytech/parity/teams","hooks_url":"https://api.github.com/repos/paritytech/parity/hooks","issue_events_url":"https://api.github.com/repos/paritytech/parity/issues/events{/number}","events_url":"https://api.github.com/repos/paritytech/parity/events","assignees_url":"https://api.github.com/repos/paritytech/parity/assignees{/user}","branches_url":"https://api.github.com/repos/paritytech/parity/branches{/branch}","tags_url":"https://api.github.com/repos/paritytech/parity/tags","blobs_url":"https://api.github.com/repos/paritytech/parity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paritytech/parity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paritytech/parity/git/refs{/sha}","trees_url":"https://api.github.com/repos/paritytech/parity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paritytech/parity/statuses/{sha}","languages_url":"https://api.github.com/repos/paritytech/parity/languages","stargazers_url":"https://api.github.com/repos/paritytech/parity/stargazers","contributors_url":"https://api.github.com/repos/paritytech/parity/contributors","subscribers_url":"https://api.github.com/repos/paritytech/parity/subscribers","subscription_url":"https://api.github.com/repos/paritytech/parity/subscription","commits_url":"https://api.github.com/repos/paritytech/parity/commits{/sha}","git_commits_url":"https://api.github.com/repos/paritytech/parity/git/commits{/sha}","comments_url":"https://api.github.com/repos/paritytech/parity/comments{/number}","issue_comment_url":"https://api.github.com/repos/paritytech/parity/issues/comments{/number}","contents_url":"https://api.github.com/repos/paritytech/parity/contents/{+path}","compare_url":"https://api.github.com/repos/paritytech/parity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paritytech/parity/merges","archive_url":"https://api.github.com/repos/paritytech/parity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paritytech/parity/downloads","issues_url":"https://api.github.com/repos/paritytech/parity/issues{/number}","pulls_url":"https://api.github.com/repos/paritytech/parity/pulls{/number}","milestones_url":"https://api.github.com/repos/paritytech/parity/milestones{/number}","notifications_url":"https://api.github.com/repos/paritytech/parity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paritytech/parity/labels{/name}","releases_url":"https://api.github.com/repos/paritytech/parity/releases{/id}","deployments_url":"https://api.github.com/repos/paritytech/parity/deployments","created_at":"2015-11-23T11:07:32Z","updated_at":"2018-02-02T11:25:46Z","pushed_at":"2018-02-02T11:03:17Z","git_url":"git://github.com/paritytech/parity.git","ssh_url":"git@github.com:paritytech/parity.git","clone_url":"https://github.com/paritytech/parity.git","svn_url":"https://github.com/paritytech/parity","homepage":"https://parity.io","size":93959,"stargazers_count":3459,"watchers_count":3459,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":663,"mirror_url":null,"archived":false,"open_issues_count":326,"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":663,"open_issues":326,"watchers":3459,"default_branch":"master"}},"base":{"label":"paritytech:master","ref":"master","sha":"99dbc68276439c79036d959b04a39b18e841512a","user":{"login":"paritytech","id":14176906,"avatar_url":"https://avatars2.githubusercontent.com/u/14176906?v=4","gravatar_id":"","url":"https://api.github.com/users/paritytech","html_url":"https://github.com/paritytech","followers_url":"https://api.github.com/users/paritytech/followers","following_url":"https://api.github.com/users/paritytech/following{/other_user}","gists_url":"https://api.github.com/users/paritytech/gists{/gist_id}","starred_url":"https://api.github.com/users/paritytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paritytech/subscriptions","organizations_url":"https://api.github.com/users/paritytech/orgs","repos_url":"https://api.github.com/users/paritytech/repos","events_url":"https://api.github.com/users/paritytech/events{/privacy}","received_events_url":"https://api.github.com/users/paritytech/received_events","type":"Organization","site_admin":false},"repo":{"id":46714939,"name":"parity","full_name":"paritytech/parity","owner":{"login":"paritytech","id":14176906,"avatar_url":"https://avatars2.githubusercontent.com/u/14176906?v=4","gravatar_id":"","url":"https://api.github.com/users/paritytech","html_url":"https://github.com/paritytech","followers_url":"https://api.github.com/users/paritytech/followers","following_url":"https://api.github.com/users/paritytech/following{/other_user}","gists_url":"https://api.github.com/users/paritytech/gists{/gist_id}","starred_url":"https://api.github.com/users/paritytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paritytech/subscriptions","organizations_url":"https://api.github.com/users/paritytech/orgs","repos_url":"https://api.github.com/users/paritytech/repos","events_url":"https://api.github.com/users/paritytech/events{/privacy}","received_events_url":"https://api.github.com/users/paritytech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/paritytech/parity","description":"Fast, light, robust Ethereum implementation.","fork":false,"url":"https://api.github.com/repos/paritytech/parity","forks_url":"https://api.github.com/repos/paritytech/parity/forks","keys_url":"https://api.github.com/repos/paritytech/parity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paritytech/parity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paritytech/parity/teams","hooks_url":"https://api.github.com/repos/paritytech/parity/hooks","issue_events_url":"https://api.github.com/repos/paritytech/parity/issues/events{/number}","events_url":"https://api.github.com/repos/paritytech/parity/events","assignees_url":"https://api.github.com/repos/paritytech/parity/assignees{/user}","branches_url":"https://api.github.com/repos/paritytech/parity/branches{/branch}","tags_url":"https://api.github.com/repos/paritytech/parity/tags","blobs_url":"https://api.github.com/repos/paritytech/parity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paritytech/parity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paritytech/parity/git/refs{/sha}","trees_url":"https://api.github.com/repos/paritytech/parity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paritytech/parity/statuses/{sha}","languages_url":"https://api.github.com/repos/paritytech/parity/languages","stargazers_url":"https://api.github.com/repos/paritytech/parity/stargazers","contributors_url":"https://api.github.com/repos/paritytech/parity/contributors","subscribers_url":"https://api.github.com/repos/paritytech/parity/subscribers","subscription_url":"https://api.github.com/repos/paritytech/parity/subscription","commits_url":"https://api.github.com/repos/paritytech/parity/commits{/sha}","git_commits_url":"https://api.github.com/repos/paritytech/parity/git/commits{/sha}","comments_url":"https://api.github.com/repos/paritytech/parity/comments{/number}","issue_comment_url":"https://api.github.com/repos/paritytech/parity/issues/comments{/number}","contents_url":"https://api.github.com/repos/paritytech/parity/contents/{+path}","compare_url":"https://api.github.com/repos/paritytech/parity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paritytech/parity/merges","archive_url":"https://api.github.com/repos/paritytech/parity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paritytech/parity/downloads","issues_url":"https://api.github.com/repos/paritytech/parity/issues{/number}","pulls_url":"https://api.github.com/repos/paritytech/parity/pulls{/number}","milestones_url":"https://api.github.com/repos/paritytech/parity/milestones{/number}","notifications_url":"https://api.github.com/repos/paritytech/parity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paritytech/parity/labels{/name}","releases_url":"https://api.github.com/repos/paritytech/parity/releases{/id}","deployments_url":"https://api.github.com/repos/paritytech/parity/deployments","created_at":"2015-11-23T11:07:32Z","updated_at":"2018-02-02T11:25:46Z","pushed_at":"2018-02-02T11:03:17Z","git_url":"git://github.com/paritytech/parity.git","ssh_url":"git@github.com:paritytech/parity.git","clone_url":"https://github.com/paritytech/parity.git","svn_url":"https://github.com/paritytech/parity","homepage":"https://parity.io","size":93959,"stargazers_count":3459,"watchers_count":3459,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":663,"mirror_url":null,"archived":false,"open_issues_count":326,"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":663,"open_issues":326,"watchers":3459,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/paritytech/parity/pulls/6422"},"html":{"href":"https://github.com/paritytech/parity/pull/6422"},"issue":{"href":"https://api.github.com/repos/paritytech/parity/issues/6422"},"comments":{"href":"https://api.github.com/repos/paritytech/parity/issues/6422/comments"},"review_comments":{"href":"https://api.github.com/repos/paritytech/parity/pulls/6422/comments"},"review_comment":{"href":"https://api.github.com/repos/paritytech/parity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/paritytech/parity/pulls/6422/commits"},"statuses":{"href":"https://api.github.com/repos/paritytech/parity/statuses/f69e49e4095e7c2c5ca506eb46c9f8bfb30868ee"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"svyatonik"}}