Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from ashcherbakov/master
Browse files Browse the repository at this point in the history
use claim_def instead of public_key
  • Loading branch information
Vyacheslav committed Apr 17, 2017
2 parents 9537e36 + 682f245 commit 4a7b15f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 47 deletions.
12 changes: 6 additions & 6 deletions doc/libsovrin-anoncreds.puml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ endnote



I -> IW: <b>1. sovrin_issuer_create_and_store_keys
I -> IW: <b>1. sovrin_issuer_create_and_store_claim_def
IW -[#green]> IW: store keys
IW -[#black]> I: <public_key>
IW -[#black]> I: <claim_def>

I-[#blue]>L: store public key in Ledger
I-[#blue]>L: store claim definition in Ledger

I -> IW: <b>2. sovrin_wallet_set_seq_no_for_value
IW -[#green]> IW: update key seq_no
Expand Down Expand Up @@ -59,7 +59,7 @@ PW -[#green]> PW: store master secret

P -> P: <b>7.sovrin_prover_get_claim_offers
L -[#blue]-> P: get schema
L -[#blue]-> P: get public key
L -[#blue]-> P: get claim definition

P -> PW: <b>8.sovrin_prover_create_and_store_claim_req
PW -[#green]> PW: get master secret
Expand Down Expand Up @@ -89,8 +89,8 @@ V -[#black]> P: send proof request
P -> PW: <b>11.sovrin_prover_parse_proof_request
PW -[#black]> P: <parsed proof request>
L -[#blue]-> P: get schema
L -[#blue]-> P: get public key
L -[#blue]-> P: get revoc_reg
L -[#blue]-> P: get claim definition
L -[#blue]-> P: get revoc_registry
P -> PW: <b>12.sovrin_prover_create_proof
P -[#green]> PW: get claim
PW -[#black]> P: <proof>
Expand Down
77 changes: 36 additions & 41 deletions src/api/anoncreds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,47 @@ use api::ErrorCode;

use self::libc::c_char;

/// Create keys (both primary and revocation) for the given schema and stores the keys
/// in a secure wallet. The public key in the wallet is identifying by a returned unique key.
/// A signing type can be set (currently only CL signature type is supported).
/// Create keys (both primary and revocation) for the given schema and signature type (currently only CL signature type is supported).
/// Store the keys together with signature type and schema in a secure wallet as a claim definition.
/// The claim definition in the wallet is identifying by a returned unique key.
///
/// #Params
/// wallet_handle: wallet handler (created by open_wallet).
/// command_handle: command handle to map callback to user context.
/// issuer_did: a DID of the issuer signing public_key transaction to the Ledger
/// issuer_did: a DID of the issuer signing claim_def transaction to the Ledger
/// schema_json: schema as a json
/// signature_type: signature type (optional). Currently only 'CL' is supported.
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// public key json
/// claim definition json containing information about signature type, schema and issuer's public key.
/// Unique number identifying the public key in the wallet
///
/// #Errors
/// Common*
/// Wallet*
/// Anoncreds*
#[no_mangle]
pub extern fn sovrin_issuer_create_and_store_keys(command_handle: i32,
pub extern fn sovrin_issuer_create_and_store_claim_def(command_handle: i32,
wallet_handle: i32,
issuer_did: *const c_char,
schema_json: *const c_char,
signature_type: *const c_char,
cb: extern fn(xcommand_handle: i32, err: ErrorCode,
public_key_json: *const c_char,
public_key_wallet_key: i32
claim_def_json: *const c_char,
claim_def_wallet_key: i32
)) -> ErrorCode {
unimplemented!();
}

/// Create a new revocation registry for the given public key.
/// Create a new revocation registry for the given claim definition.
/// Stores it in a secure wallet identifying by the returned key.
///
/// #Params
/// wallet_handle: wallet handler (created by open_wallet).
/// command_handle: command handle to map callback to user context.
/// issuer_did: a DID of the issuer signing revoc_reg transaction to the Ledger
/// public_key_seq_no: seq no of a public key transaction in Ledger
/// claim_def_seq_no: seq no of a public key transaction in Ledger
/// max_claim_num: maximum number of claims the new registry can process.
/// cb: Callback that takes command result as parameter.
///
Expand All @@ -60,7 +60,7 @@ pub extern fn sovrin_issuer_create_and_store_keys(command_handle: i32,
pub extern fn sovrin_issuer_create_and_store_revoc_reg(command_handle: i32,
wallet_handle: i32,
issuer_did: *const c_char,
public_key_seq_no: i32,
claim_def_seq_no: i32,
max_claim_num: i32,
cb: extern fn(xcommand_handle: i32, err: ErrorCode,
revoc_reg_json: *const c_char,
Expand All @@ -69,8 +69,8 @@ pub extern fn sovrin_issuer_create_and_store_revoc_reg(command_handle: i32,
unimplemented!();
}

/// Signs a given claim for the given user by a given key.
/// The corresponding keys and revocation registry must be already created
/// Signs a given claim for the given user by a given key (claim ef).
/// The corresponding claim definition and revocation registry must be already created
/// an stored into the wallet.
///
/// #Params
Expand All @@ -85,19 +85,18 @@ pub extern fn sovrin_issuer_create_and_store_revoc_reg(command_handle: i32,
/// "attr1" : "value1",
/// "attr2" : "value2"
/// }
/// public_key_seq_no: seq no of a public key transaction in Ledger
/// claim_def_seq_no: seq no of a claim definition transaction in Ledger
/// revoc_reg_seq_no: seq no of a revocation registry transaction in Ledger
/// user_revoc_index: index of a new user in the revocation registry (optional; default one is used if not provided)
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// Revocation registry update json with a newly issued claim
/// Claim json containing issued claim, and public_key_seq_no and revoc_reg_seq_no
/// Claim json containing issued claim, and claim_def_seq_no and revoc_reg_seq_no
/// used for issuance
/// {
/// "claim": string,
/// "schema_seq_no": string,
/// "public_key_seq_no", string,
/// "claim_def_seq_no": string,
/// "revoc_reg_seq_no", string
/// }
///
Expand All @@ -111,7 +110,7 @@ pub extern fn sovrin_issuer_create_claim(command_handle: i32,
claim_req_json: *const c_char,
claim_json: *const c_char,
issuer_did: *const c_char,
public_key_seq_no: i32,
claim_def_seq_no: i32,
revoc_reg_seq_no: i32,
user_revoc_index: i32,
cb: extern fn(xcommand_handle: i32, err: ErrorCode,
Expand All @@ -122,13 +121,14 @@ pub extern fn sovrin_issuer_create_claim(command_handle: i32,
}

/// Revokes a user identified by a revoc_id in a given revoc-registry.
/// The corresponding keys and revocation registry must be already
/// The corresponding claim definition and revocation registry must be already
/// created an stored into the wallet.
///
/// #Params
/// wallet_handle: wallet handler (created by open_wallet).
/// command_handle: command handle to map callback to user context.
/// issuer_did: a DID of the issuer signing transactions to the Ledger
/// claim_def_seq_no: seq no of a claim definition transaction in Ledger
/// revoc_reg_seq_no: seq no of a revocation registry transaction in Ledger
/// user_revoc_index: index of the user in the revocation registry
/// cb: Callback that takes command result as parameter.
Expand All @@ -144,6 +144,7 @@ pub extern fn sovrin_issuer_create_claim(command_handle: i32,
pub extern fn sovrin_issuer_revoke_claim(command_handle: i32,
wallet_handle: i32,
issuer_did: *const c_char,
claim_def_seq_no: i32,
revoc_reg_seq_no: *const c_char,
user_revoc_index: *const c_char,
cb: extern fn(xcommand_handle: i32, err: ErrorCode,
Expand All @@ -160,8 +161,7 @@ pub extern fn sovrin_issuer_revoke_claim(command_handle: i32,
/// claim_offer_json: claim offer as a json containing information about the issuer and a claim:
/// {
/// "issuer_did": string,
/// "schema_seq_no": string,
/// "public_key_seq_no": string
/// "claim_def_seq_no": string
/// }
///
/// #Returns
Expand Down Expand Up @@ -228,7 +228,7 @@ pub extern fn sovrin_prover_create_master_secret(command_handle: i32,
}

/// Creates a clam request json for the given claim offer and stores it in a secure wallet.
/// The claim offer contains the information about Issuer (DID, public_key_seq_no),
/// The claim offer contains the information about Issuer (DID, claim_def_seq_no),
/// and the schema (schema_seq_no).
/// The method gets public key and schema from the ledger, stores them in a wallet,
/// and creates a blinded master secret for a master secret identified by a provided name.
Expand All @@ -241,11 +241,10 @@ pub extern fn sovrin_prover_create_master_secret(command_handle: i32,
/// claim_offer_json: claim offer as a json containing information about the issuer and a claim:
/// {
/// "issuer_did": string,
/// "schema_seq_no": string,
/// "public_key_seq_no": string
/// "claim_def_seq_no": string
/// }
/// schema_json: schema json associated with a schema_seq_no in the claim_offer
/// public_key_json: public key json associated with a schema_seq_no in the claim_offer
/// claim_def_json: claim definition json associated with a schema_seq_no in the claim_offer
/// master_secret_name: the name of the master secret stored in the wallet
/// cb: Callback that takes command result as parameter.
///
Expand All @@ -261,7 +260,7 @@ pub extern fn sovrin_prover_create_and_store_claim_req(command_handle: i32,
wallet_handle: i32,
claim_offer_json: *const c_char,
schema_json: *const c_char,
public_key_json: *const c_char,
claim_def_json: *const c_char,
master_secret_name: *const c_char,
cb: extern fn(xcommand_handle: i32, err: ErrorCode,
claim_req_json: *const c_char
Expand All @@ -270,8 +269,8 @@ pub extern fn sovrin_prover_create_and_store_claim_req(command_handle: i32,
}

/// Updates the claim by a master secret and stores in a secure wallet.
/// The claim contains the information about schema_seq_no,
/// public_key_seq_no revoc_reg_seq_no (see issuer_create_claim).
/// The claim contains the information about
/// claim_def_seq_no revoc_reg_seq_no (see issuer_create_claim).
/// Seq_no is a sequence number of the corresponding transaction in the ledger.
/// The method loads a blinded secret for this key from the wallet,
/// updates the claim and stores it in a wallet.
Expand All @@ -282,8 +281,7 @@ pub extern fn sovrin_prover_create_and_store_claim_req(command_handle: i32,
/// claims_json: claim json:
/// {
/// "claim": string,
/// "schema_seq_no": string,
/// "public_key_seq_no", string,
/// "claim_def_seq_no", string,
/// "revoc_reg_seq_no", string
/// }
/// cb: Callback that takes command result as parameter.
Expand Down Expand Up @@ -322,8 +320,7 @@ pub extern fn sovrin_prover_store_claim(command_handle: i32,
/// "claims":[
/// {
/// "claim_wallet_key": string,
/// "schema_seq_no": string,
/// "public_key_seq_no": string,
/// "claim_def_seq_no": string,
/// "revoc_reg_seq_no": string,
/// "revealed_attrs": string,
/// "predicates": string
Expand All @@ -348,14 +345,14 @@ pub extern fn sovrin_prover_parse_proof_request(command_handle: i32,
/// A proof request may request multiple claims from different schemas and different issuers.
/// All required schemas, public keys and revocation registries must be provided.
/// The proof request also contains nonce.
/// The proof contains proofs for each schema with corresponding seq_no of public_key and revoc_reg transactions in Ledger.
/// The proof contains proofs for each schema with corresponding seq_no of claim_def and revoc_reg transactions in Ledger.
///
/// #Params
/// wallet_handle: wallet handler (created by open_wallet).
/// command_handle: command handle to map callback to user context.
/// proof_request_json: proof request as a json
/// schemas_jsons: all schema jsons participating in the proof request
/// public_keys_jsons: all issuer public key jsons participating in the proof request
/// claim_def_jsons: all claim definition jsons participating in the proof request
/// revoc_regs_jsons: all revocation registry jsons participating in the proof request
/// cb: Callback that takes command result as parameter.
///
Expand All @@ -365,8 +362,7 @@ pub extern fn sovrin_prover_parse_proof_request(command_handle: i32,
/// "proofs":[
/// {
/// "proof": string,
/// "schema_seq_no": string,
/// "public_key_seq_no": string,
/// "claim_def_seq_no": string,
/// "revoc_reg_seq_no": string,
/// "revealed_attr_values": array,
/// }],
Expand All @@ -382,7 +378,7 @@ pub extern fn sovrin_prover_create_proof(command_handle: i32,
wallet_handle: i32,
parsed_proof_request_json: *const c_char,
schemas_json: *const c_char,
public_keys_json: *const c_char,
claim_defs_json: *const c_char,
revoc_regs_json: *const c_char,
cb: extern fn(xcommand_handle: i32, err: ErrorCode,
proof_json: *const c_char)) -> ErrorCode {
Expand All @@ -404,15 +400,14 @@ pub extern fn sovrin_prover_create_proof(command_handle: i32,
/// "proofs":[
/// {
/// "proof": string,
/// "schema_seq_no": string,
/// "public_key_seq_no": string,
/// "claim_def_seq_no": string,
/// "revoc_reg_seq_no": string,
/// "revealed_attr_values": array,
/// }],
/// "aggregated_proof": object
/// }
/// schemas_jsons: all schema jsons participating in the proof
/// public_keys_jsons: all issuer public key jsons participating in the proof
/// claim_defs_jsons: all claim definition jsons participating in the proof
/// revoc_regs_jsons: all revocation registry jsons participating in the proof
/// cb: Callback that takes command result as parameter.
///
Expand All @@ -430,7 +425,7 @@ pub extern fn sovrin_verifier_verify_proof(command_handle: i32,
proof_request_disclosed_json: *const c_char,
proof_json: *const c_char,
schemas_json: *const c_char,
public_keys_json: *const c_char,
claim_defs_jsons: *const c_char,
revoc_regs_json: *const c_char,
cb: extern fn(xcommand_handle: i32, err: ErrorCode,
valid: bool)) -> ErrorCode {
Expand Down

0 comments on commit 4a7b15f

Please sign in to comment.