From ea00da69e1a00910d7f0eb3e1f5ab13b96b03fb7 Mon Sep 17 00:00:00 2001 From: Evgeniy Razinkov Date: Fri, 24 Mar 2017 17:16:03 +0300 Subject: [PATCH 01/10] added api for anoncreds --- src/lib.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index d8201e5030..90cb43dc71 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,6 +21,49 @@ impl SovrinClient { pub fn set_did(&self, did: String, cb: Box>) + Send>) { self.command_executor.send(Command::SetDidCommand(did, cb)); } + + pub fn create_master_secret() { + + } + + pub fn create_keys(schema: String) { + + } + + pub fn create_context_attribute(i_a: String, user_id: String) { + + } + + pub fn issue_accumulator(schema: String, i_a: String, l: String, + public_key_revocation: String) { + + } + + pub fn issue_claim(attributes: String, accumulator: String,i_a: String, i: String, + claim_request: String, context_attribute: String, public_key: String, + secret_key: String, public_key_revocation: String, + secret_key_revocation: String, tails: String, + secret_key_accumulator: String) { + + } + + pub fn create_claim_request(master_secret: String, public_key: String, + public_key_revocation: String, request_non_revocation: String) { + + } + + pub fn create_proof(proof_input: String, nonce: String, claims: String, + public_key_revocation: String, accum: String, public_key: String, + master_secret: String) { + + } + + pub fn verify_proof(proof_input: String, proof: String, revealed_attributes: String, + nonce: String, public_key_revocation: String, + public_key_accumulator: String, accumulator: String, + public_key: String, attributes: String) { + + } } #[cfg(test)] From 849177d6af64fe1038fc34a4ce90e418ff771496 Mon Sep 17 00:00:00 2001 From: Evgeniy Razinkov Date: Fri, 24 Mar 2017 17:49:53 +0300 Subject: [PATCH 02/10] added callback --- src/lib.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 90cb43dc71..3360fc1e1d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,20 +22,26 @@ impl SovrinClient { self.command_executor.send(Command::SetDidCommand(did, cb)); } - pub fn create_master_secret() { + pub fn create_master_secret(cb: Box>) + Send>) { } - pub fn create_keys(schema: String) { + pub fn create_keys(schema: String, + cb: Box>) + Send>) { } - pub fn create_context_attribute(i_a: String, user_id: String) { + pub fn create_context_attribute(i_a: String, user_id: String, + cb: Box>) + Send>) { } pub fn issue_accumulator(schema: String, i_a: String, l: String, - public_key_revocation: String) { + public_key_revocation: String, + cb: Box> + ) + Send>) { } @@ -43,25 +49,29 @@ impl SovrinClient { claim_request: String, context_attribute: String, public_key: String, secret_key: String, public_key_revocation: String, secret_key_revocation: String, tails: String, - secret_key_accumulator: String) { + secret_key_accumulator: String, + cb: Box>) + Send>) { } pub fn create_claim_request(master_secret: String, public_key: String, - public_key_revocation: String, request_non_revocation: String) { + public_key_revocation: String, request_non_revocation: String, + cb: Box>) + Send>) { } pub fn create_proof(proof_input: String, nonce: String, claims: String, public_key_revocation: String, accum: String, public_key: String, - master_secret: String) { + master_secret: String, + cb: Box>) + Send>) { } pub fn verify_proof(proof_input: String, proof: String, revealed_attributes: String, nonce: String, public_key_revocation: String, public_key_accumulator: String, accumulator: String, - public_key: String, attributes: String) { + public_key: String, attributes: String, + cb: Box>) + Send>) { } } From a6a72ade24cd0238416866e49ffa77da9467823e Mon Sep 17 00:00:00 2001 From: Evgeniy Razinkov Date: Fri, 24 Mar 2017 17:52:35 +0300 Subject: [PATCH 03/10] minor refactoring --- src/lib.rs | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 549ab11620..3345de7c6e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,24 +17,6 @@ impl AnoncredsAPI { AnoncredsAPI { command_executor: command_executor } } - fn dummy() {} -} - -struct SovrinAPI { - command_executor: Arc, -} - -impl SovrinAPI { - pub fn new(command_executor: Arc) -> SovrinAPI { - SovrinAPI { - command_executor: command_executor - } - } - - pub fn set_did(&self, did: String, cb: Box>) + Send>) { - self.command_executor.send(Command::SetDidCommand(did, cb)); - } - pub fn create_master_secret(cb: Box>) + Send>) { } @@ -53,7 +35,7 @@ impl SovrinAPI { public_key_revocation: String, cb: Box> + Box> ) + Send>) { } @@ -89,6 +71,22 @@ impl SovrinAPI { } } +struct SovrinAPI { + command_executor: Arc, +} + +impl SovrinAPI { + pub fn new(command_executor: Arc) -> SovrinAPI { + SovrinAPI { + command_executor: command_executor + } + } + + pub fn set_did(&self, did: String, cb: Box>) + Send>) { + self.command_executor.send(Command::SetDidCommand(did, cb)); + } +} + pub struct SovrinClient { sovrin: SovrinAPI, From e4f959e3f88ad84d9bd5a6b1c2c7cc26b5198857 Mon Sep 17 00:00:00 2001 From: Evgeniy Razinkov Date: Mon, 27 Mar 2017 12:06:56 +0300 Subject: [PATCH 04/10] changed errors --- src/api/anoncreds.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/api/anoncreds.rs b/src/api/anoncreds.rs index 5a309b69db..83dfaa97e5 100644 --- a/src/api/anoncreds.rs +++ b/src/api/anoncreds.rs @@ -1,6 +1,7 @@ use commands::{Command, CommandExecutor}; use std::error; use std::sync::Arc; +use errors::anoncreds::AnoncredsError; pub struct AnoncredsAPI { command_executor: Arc, @@ -11,17 +12,17 @@ impl AnoncredsAPI { AnoncredsAPI { command_executor: command_executor } } - pub fn create_master_secret(cb: Box>) + Send>) { + pub fn create_master_secret(cb: Box) + Send>) { } pub fn create_keys(schema: String, - cb: Box>) + Send>) { + cb: Box) + Send>) { } pub fn create_context_attribute(i_a: String, user_id: String, - cb: Box>) + Send>) { + cb: Box) + Send>) { } @@ -29,7 +30,7 @@ impl AnoncredsAPI { public_key_revocation: String, cb: Box> + AnoncredsError> ) + Send>) { } @@ -39,20 +40,20 @@ impl AnoncredsAPI { secret_key: String, public_key_revocation: String, secret_key_revocation: String, tails: String, secret_key_accumulator: String, - cb: Box>) + Send>) { + cb: Box) + Send>) { } pub fn create_claim_request(master_secret: String, public_key: String, public_key_revocation: String, request_non_revocation: String, - cb: Box>) + Send>) { + cb: Box) + Send>) { } pub fn create_proof(proof_input: String, nonce: String, claims: String, public_key_revocation: String, accum: String, public_key: String, master_secret: String, - cb: Box>) + Send>) { + cb: Box) + Send>) { } @@ -60,7 +61,7 @@ impl AnoncredsAPI { nonce: String, public_key_revocation: String, public_key_accumulator: String, accumulator: String, public_key: String, attributes: String, - cb: Box>) + Send>) { + cb: Box) + Send>) { } } From 45f3e3283abcd7f7d3c12a7dc4e8d6509f1146b0 Mon Sep 17 00:00:00 2001 From: Evgeniy Razinkov Date: Mon, 27 Mar 2017 15:03:23 +0300 Subject: [PATCH 05/10] Added documentation --- src/api/anoncreds.rs | 77 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 10 deletions(-) diff --git a/src/api/anoncreds.rs b/src/api/anoncreds.rs index 83dfaa97e5..ffe6fbfd29 100644 --- a/src/api/anoncreds.rs +++ b/src/api/anoncreds.rs @@ -12,27 +12,69 @@ impl AnoncredsAPI { AnoncredsAPI { command_executor: command_executor } } + /// Creates master secret key for prover. + /// + /// #Params + /// cb: Callback that takes command result as a parameter. + /// + /// #Returns + /// Master secret key as a String. + /// + /// #Errors + /// No method specific errors. + /// See `AnoncredsError` docs for common errors description. pub fn create_master_secret(cb: Box) + Send>) { - + unimplemented!(); } - pub fn create_keys(schema: String, - cb: Box) + Send>) { - + /// Creates public/private keys pair for issuer. + /// + /// #Params + /// schema: claim definition schema as a byte array. + /// cb: Callback that takes command result as a parameter. + /// + /// #Returns + /// Tuple of + /// (Public primary key, Secret Key, Public non-revocation key, Secret non-revocation key) + /// as a String. + /// + /// #Errors + /// No method specific errors. + /// See `AnoncredsError` docs for common errors description. + pub fn create_key_pair(schema: &[&u8], + cb: Box) + Send>) { + unimplemented!(); } + pub fn create_context_attribute(i_a: String, user_id: String, cb: Box) + Send>) { } - pub fn issue_accumulator(schema: String, i_a: String, l: String, - public_key_revocation: String, + /// Issues accumulator. + /// + /// #Params + /// schema: claim definition schema as a byte array. + /// accumulator_id: accumulator id as a byte array. + /// max_claims: maximum number of claims within accumulator as a byte array. + /// public_key_non_revocation: non-revocation public key as a byte array. + /// cb: Callback that takes command result as a parameter. + /// + /// #Returns + /// Tuple of (Accumulator, Tails, Accumulator public key, Accumulator secret key) as a String. + /// + /// #Errors + /// No method specific errors. + /// See `AnoncredsError` docs for common errors description. + pub fn issue_accumulator(schema: &[&u8], accumulator_id: &[&u8], max_claims: &[&u8], + public_key_non_revocation: &[&u8], cb: Box ) + Send>) { - + unimplemented!(); } pub fn issue_claim(attributes: String, accumulator: String,i_a: String, i: String, @@ -44,10 +86,25 @@ impl AnoncredsAPI { } - pub fn create_claim_request(master_secret: String, public_key: String, - public_key_revocation: String, request_non_revocation: String, + /// Creates claim request. + /// + /// #Params + /// master_secret: prover master secret as a byte array. + /// public_key: issuer public_key as a byte array. + /// public_key_non_revocation: issuer non-revocation public key as a byte array. + /// request_non_revocation: whether to request non-revocation claim as a byte array. + /// cb: Callback that takes command result as a parameter. + /// + /// #Returns + /// Claim request as a String. + /// + /// #Errors + /// No method specific errors. + /// See `AnoncredsError` docs for common errors description. + pub fn create_claim_request(master_secret: &[&u8], public_key: &[&u8], + public_key_non_revocation: &[&u8], request_non_revocation: &[&u8], cb: Box) + Send>) { - + unimplemented!(); } pub fn create_proof(proof_input: String, nonce: String, claims: String, From 32a20ed9924f895262ffa5a10f658c23c4817c64 Mon Sep 17 00:00:00 2001 From: Evgeniy Razinkov Date: Mon, 27 Mar 2017 15:24:44 +0300 Subject: [PATCH 06/10] Added documentation --- src/api/anoncreds.rs | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/src/api/anoncreds.rs b/src/api/anoncreds.rs index ffe6fbfd29..2847a5fb58 100644 --- a/src/api/anoncreds.rs +++ b/src/api/anoncreds.rs @@ -59,7 +59,7 @@ impl AnoncredsAPI { /// schema: claim definition schema as a byte array. /// accumulator_id: accumulator id as a byte array. /// max_claims: maximum number of claims within accumulator as a byte array. - /// public_key_non_revocation: non-revocation public key as a byte array. + /// public_key_non_revocation: issuer's non-revocation public key as a byte array. /// cb: Callback that takes command result as a parameter. /// /// #Returns @@ -89,9 +89,9 @@ impl AnoncredsAPI { /// Creates claim request. /// /// #Params - /// master_secret: prover master secret as a byte array. - /// public_key: issuer public_key as a byte array. - /// public_key_non_revocation: issuer non-revocation public key as a byte array. + /// master_secret: prover's master secret as a byte array. + /// public_key: issuer's public_key as a byte array. + /// public_key_non_revocation: issuer's non-revocation public key as a byte array. /// request_non_revocation: whether to request non-revocation claim as a byte array. /// cb: Callback that takes command result as a parameter. /// @@ -107,11 +107,34 @@ impl AnoncredsAPI { unimplemented!(); } - pub fn create_proof(proof_input: String, nonce: String, claims: String, - public_key_revocation: String, accum: String, public_key: String, - master_secret: String, - cb: Box) + Send>) { + /// Creates proof. + /// + /// #Params + /// proof_input: description of a proof to be presented + /// (revealed attributes, predicates, timestamps for non-revocation) as a byte array. + /// nonce: verifier's nonce as a byte array. + /// claims: necessary claims for proof as a byte array. + /// master_secret: prover's master secret key as a byte array. + /// public_key: issuer's public key as a byte array. + /// public_key_non_revocation: issuer's non-revocation public key as a byte array. + /// accumulator: accumulator as a byte array. + /// cb: Callback that takes command result as a parameter. + /// + /// #Returns + /// Typle of ( + /// Proof (both primary and non-revocation), + /// Revealed attributes (initial non-encoded values) + /// ) as a String. + /// + /// #Errors + /// No method specific errors. + /// See `AnoncredsError` docs for common errors description. + pub fn create_proof(proof_input: &[&u8], nonce: &[&u8], claims: &[&u8], + public_key_non_revocation: &[&u8], accumulator: &[&u8], public_key: &[&u8], + master_secret: &[&u8], + cb: Box) + Send>) { + unimplemented!(); } pub fn verify_proof(proof_input: String, proof: String, revealed_attributes: String, @@ -121,6 +144,10 @@ impl AnoncredsAPI { cb: Box) + Send>) { } + + pub fn create_nonce() { + + } } #[cfg(test)] From 627faaf1e01845bab5d8ce76feed74dfccf8e70d Mon Sep 17 00:00:00 2001 From: Evgeniy Razinkov Date: Mon, 27 Mar 2017 15:26:49 +0300 Subject: [PATCH 07/10] Added documentation --- src/api/anoncreds.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/api/anoncreds.rs b/src/api/anoncreds.rs index 2847a5fb58..9b6ef60441 100644 --- a/src/api/anoncreds.rs +++ b/src/api/anoncreds.rs @@ -145,8 +145,19 @@ impl AnoncredsAPI { } - pub fn create_nonce() { - + /// Creates verifier's nonce. + /// + /// #Params + /// cb: Callback that takes command result as a parameter. + /// + /// #Returns + /// Nonce as a String. + /// + /// #Errors + /// No method specific errors. + /// See `AnoncredsError` docs for common errors description. + pub fn create_nonce(cb: Box) + Send>) { + unimplemented!(); } } From 6eac5d315c716df14198b4f128a145731960705a Mon Sep 17 00:00:00 2001 From: Evgeniy Razinkov Date: Mon, 27 Mar 2017 15:38:02 +0300 Subject: [PATCH 08/10] Added documentation --- src/api/anoncreds.rs | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/api/anoncreds.rs b/src/api/anoncreds.rs index 9b6ef60441..8207258828 100644 --- a/src/api/anoncreds.rs +++ b/src/api/anoncreds.rs @@ -137,12 +137,34 @@ impl AnoncredsAPI { unimplemented!(); } - pub fn verify_proof(proof_input: String, proof: String, revealed_attributes: String, - nonce: String, public_key_revocation: String, - public_key_accumulator: String, accumulator: String, - public_key: String, attributes: String, + /// Verifies proof. + /// + /// #Params + /// proof_input: description of a proof to be presented + /// (revealed attributes, predicates, timestamps for non-revocation) as a byte array. + /// proof: a proof as a byte array. + /// revealed_attributes: + /// values of revealed attributes (initial values, non-encoded) as a byte array. + /// nonce: verifier's nonce as a byte array. + /// public_key_non_revocation: issuer's non-revocation public key as a byte array. + /// accumulator: accumulator as a byte array. + /// public_key_accumulator: accumulator's public key as a byte array. + /// public_key: issuer's public key as a byte array. + /// attributes: all names of attributes as a byte array. + /// cb: Callback that takes command result as a parameter. + /// + /// #Returns + /// True if verified successfully and false otherwise as a String. + /// + /// #Errors + /// No method specific errors. + /// See `AnoncredsError` docs for common errors description. + pub fn verify_proof(proof_input: &[&u8], proof: &[&u8], revealed_attributes: &[&u8], + nonce: &[&u8], public_key_non_revocation: &[&u8], + accumulator: &[&u8], public_key_accumulator: &[&u8], + public_key: &[&u8], attributes: &[&u8], cb: Box) + Send>) { - + unimplemented!(); } /// Creates verifier's nonce. From 647ecf3ffe30c3389409089548f201c3f70db39d Mon Sep 17 00:00:00 2001 From: Evgeniy Razinkov Date: Mon, 27 Mar 2017 15:53:38 +0300 Subject: [PATCH 09/10] Added documentation --- src/api/anoncreds.rs | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/src/api/anoncreds.rs b/src/api/anoncreds.rs index 8207258828..bb1c081439 100644 --- a/src/api/anoncreds.rs +++ b/src/api/anoncreds.rs @@ -47,12 +47,6 @@ impl AnoncredsAPI { unimplemented!(); } - - pub fn create_context_attribute(i_a: String, user_id: String, - cb: Box) + Send>) { - - } - /// Issues accumulator. /// /// #Params @@ -77,13 +71,36 @@ impl AnoncredsAPI { unimplemented!(); } - pub fn issue_claim(attributes: String, accumulator: String,i_a: String, i: String, - claim_request: String, context_attribute: String, public_key: String, - secret_key: String, public_key_revocation: String, - secret_key_revocation: String, tails: String, - secret_key_accumulator: String, - cb: Box) + Send>) { + /// Issues claim. + /// + /// #Params + /// attributes: all names of attributes as a byte array. + /// accumulator: accumulator as a byte array. + /// sequence_number: claim's sequence number within accumulator as a byte array. + /// claim_request: + /// A claim request containing prover ID and prover-generated values as a byte array. + /// public_key: issuer's public_key as a byte array. + /// secret_key: issuer's secret_key as a byte array. + /// public_key_non_revocation: issuer's non-revocation public key as a byte array. + /// secret_key_non_revocation: issuer's non-revocation secret key as a byte array. + /// tails: tails as a byte array. + /// secret_key_accumulator: accumulator's secret key as a byte array. + /// cb: Callback that takes command result as a parameter. + /// + /// #Returns + /// The claim (both primary and non-revocation) as a String. + /// + /// #Errors + /// No method specific errors. + /// See `AnoncredsError` docs for common errors description. + pub fn issue_claim(attributes: &[&u8], accumulator: &[&u8], sequence_number: &[&u8], + claim_request: &[&u8], public_key: &[&u8], + secret_key: &[&u8], public_key_non_revocation: &[&u8], + secret_key_non_revocation: &[&u8], tails: &[&u8], + secret_key_accumulator: &[&u8], + cb: Box) + Send>) { + unimplemented!(); } /// Creates claim request. From 54617f32dedfcfa929567dc9f9b246ed5e5b674d Mon Sep 17 00:00:00 2001 From: Evgeniy Razinkov Date: Mon, 27 Mar 2017 16:15:51 +0300 Subject: [PATCH 10/10] minor changes --- src/api/anoncreds.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/anoncreds.rs b/src/api/anoncreds.rs index bb1c081439..fc06b51a06 100644 --- a/src/api/anoncreds.rs +++ b/src/api/anoncreds.rs @@ -23,7 +23,7 @@ impl AnoncredsAPI { /// #Errors /// No method specific errors. /// See `AnoncredsError` docs for common errors description. - pub fn create_master_secret(cb: Box) + Send>) { + pub fn create_master_secret(cb: Box) + Send>) { unimplemented!(); } @@ -99,7 +99,7 @@ impl AnoncredsAPI { secret_key: &[&u8], public_key_non_revocation: &[&u8], secret_key_non_revocation: &[&u8], tails: &[&u8], secret_key_accumulator: &[&u8], - cb: Box) + Send>) { + cb: Box) + Send>) { unimplemented!(); } @@ -120,7 +120,7 @@ impl AnoncredsAPI { /// See `AnoncredsError` docs for common errors description. pub fn create_claim_request(master_secret: &[&u8], public_key: &[&u8], public_key_non_revocation: &[&u8], request_non_revocation: &[&u8], - cb: Box) + Send>) { + cb: Box) + Send>) { unimplemented!(); } @@ -180,7 +180,7 @@ impl AnoncredsAPI { nonce: &[&u8], public_key_non_revocation: &[&u8], accumulator: &[&u8], public_key_accumulator: &[&u8], public_key: &[&u8], attributes: &[&u8], - cb: Box) + Send>) { + cb: Box) + Send>) { unimplemented!(); } @@ -195,7 +195,7 @@ impl AnoncredsAPI { /// #Errors /// No method specific errors. /// See `AnoncredsError` docs for common errors description. - pub fn create_nonce(cb: Box) + Send>) { + pub fn create_nonce(cb: Box) + Send>) { unimplemented!(); } }