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 #464 from jovfer/feature/rc_1_2_0
Browse files Browse the repository at this point in the history
RC 1.2.0
  • Loading branch information
Vyacheslav authored Jan 10, 2018
2 parents 2de9987 + f8dd4c8 commit d77d5ee
Show file tree
Hide file tree
Showing 52 changed files with 855 additions and 193 deletions.
23 changes: 23 additions & 0 deletions Specs/libindy-objc/1.2.0/libindy-objc.podspec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "libindy-objc",
"version": "1.2.0",
"summary": "Summary TODO.",
"homepage": "TODO",
"license": {
"type": "Apache License 2.0",
"file": "LICENSE"
},
"authors": {
"Daniel Hardman": "[email protected]"
},
"source": {
"http": "https://repo.sovrin.org/ios/libindy/stable/indy-objc/1.2.0/libindy-objc.zip"
},
"platforms": {
"ios": "10.0"
},
"ios": {
"vendored_frameworks": "libindy-objc/Indy.framework"
},
"module_name": "Indy"
}
23 changes: 23 additions & 0 deletions Specs/libindy/1.2.0/libindy.podspec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "libindy",
"version": "1.2.0",
"summary": "Summary TODO.",
"description": "Description TODO.",
"homepage": "TODO",
"license": {
"type": "Apache License 2.0",
"file": "LICENSE"
},
"authors": {
"Daniel Hardman": "[email protected]"
},
"platforms": {
"ios": "10.0"
},
"source": {
"http": "https://repo.sovrin.org/ios/libindy/stable/libindy-core/1.2.0/libindy.tar.gz"
},
"source_files": "*.h",
"vendored_libraries": "*.a",
"requires_arc": false
}
23 changes: 12 additions & 11 deletions ci/indy-pool.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ RUN echo "deb https://repo.sovrin.org/deb xenial $indy_stream" >> /etc/apt/sourc

RUN useradd -ms /bin/bash -u $uid indy

ARG indy_plenum_ver=1.1.27
ARG indy_anoncreds_ver=1.0.10
ARG indy_node_ver=1.1.43
ARG indy_plenum_ver=1.2.29
ARG indy_anoncreds_ver=1.0.11
ARG indy_node_ver=1.2.50
ARG python3_indy_crypto_ver=0.1.6
ARG indy_crypto_ver=0.1.6

RUN apt-get update -y && apt-get install -y \
indy-plenum=${indy_plenum_ver} \
indy-anoncreds=${indy_anoncreds_ver} \
indy-node=${indy_node_ver} \
python3-indy-crypto=${python3_indy_crypto_ver} \
libindy-crypto=${indy_crypto_ver} \
vim

RUN echo '[supervisord]\n\
Expand All @@ -52,28 +56,28 @@ childlogdir = /tmp\n\
strip_ansi = false\n\
\n\
[program:node1]\n\
command=start_sovrin_node Node1 9701 9702\n\
command=start_indy_node Node1 9701 9702\n\
directory=/home/indy\n\
stdout_logfile=/tmp/node1.log\n\
stderr_logfile=/tmp/node1.log\n\
loglevel=trace\n\
\n\
[program:node2]\n\
command=start_sovrin_node Node2 9703 9704\n\
command=start_indy_node Node2 9703 9704\n\
directory=/home/indy\n\
stdout_logfile=/tmp/node2.log\n\
stderr_logfile=/tmp/node2.log\n\
loglevel=trace\n\
\n\
[program:node3]\n\
command=start_sovrin_node Node3 9705 9706\n\
command=start_indy_node Node3 9705 9706\n\
directory=/home/indy\n\
stdout_logfile=/tmp/node3.log\n\
stderr_logfile=/tmp/node3.log\n\
loglevel=trace\n\
\n\
[program:node4]\n\
command=start_sovrin_node Node4 9707 9708\n\
command=start_indy_node Node4 9707 9708\n\
directory=/home/indy\n\
stdout_logfile=/tmp/node4.log\n\
stderr_logfile=/tmp/node4.log\n\
Expand All @@ -84,10 +88,7 @@ USER indy

ARG pool_ip=127.0.0.1

RUN generate_sovrin_pool_transactions --nodes 4 --clients 5 --nodeNum 1 --ips="$pool_ip,$pool_ip,$pool_ip,$pool_ip"
RUN generate_sovrin_pool_transactions --nodes 4 --clients 5 --nodeNum 2 --ips="$pool_ip,$pool_ip,$pool_ip,$pool_ip"
RUN generate_sovrin_pool_transactions --nodes 4 --clients 5 --nodeNum 3 --ips="$pool_ip,$pool_ip,$pool_ip,$pool_ip"
RUN generate_sovrin_pool_transactions --nodes 4 --clients 5 --nodeNum 4 --ips="$pool_ip,$pool_ip,$pool_ip,$pool_ip"
RUN generate_indy_pool_transactions --nodes 4 --clients 5 --nodeNum 1 2 3 4 --ips="$pool_ip,$pool_ip,$pool_ip,$pool_ip"

EXPOSE 9701 9702 9703 9704 9705 9706 9707 9708

Expand Down
2 changes: 1 addition & 1 deletion libindy/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libindy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "indy"
version = "1.1.1"
version = "1.2.0"
authors = [
"Sergej Pupykin <[email protected]>",
"Vyacheslav Gudkov <[email protected]>",
Expand Down
6 changes: 2 additions & 4 deletions libindy/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
libindy (1.1.1) unstable; urgency=medium
libindy (1.2.0) unstable; urgency=medium

[ Hyperledger ]
* Replaced Agent2Agent API
* New Crypto API
* Updated Signus API
* indy_key_for_local_did added
67 changes: 67 additions & 0 deletions libindy/include/indy_signus.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,37 @@ extern "C" {
indy_error_t err)
);

/// Returns ver key (key id) for the given DID.
///
/// "indy_key_for_did" call follow the idea that we resolve information about their DID from
/// the ledger with cache in the local wallet. The "indy_open_wallet" call has freshness parameter
/// that is used for checking the freshness of cached pool value.
///
/// Note if you don't want to resolve their DID info from the ledger you can use
/// "indy_key_for_local_did" call instead that will look only to local wallet and skip
/// freshness checking
///
/// Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key.
/// As result we can use returned ver key in all generic crypto and messaging functions.
///
/// #Params
/// command_handle: Command handle to map callback to caller context.
/// pool_handle: Pool handle to resolve information from the ledger.
/// wallet_handle: Wallet handle (created by open_wallet).
/// did - The DID to resolve key.
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// Error Code
/// cb:
/// - xcommand_handle: Command handle to map callback to caller context.
/// - err: Error code.
/// - key - The DIDs ver key (key id).
///
/// #Errors
/// Common*
/// Wallet*
/// Crypto*
extern indy_error_t indy_key_for_did(indy_handle_t command_handle,
indy_handle_t pool_handle,
indy_handle_t wallet_handle,
Expand All @@ -134,6 +165,42 @@ extern "C" {
const char *const key)
);

//// Returns ver key (key id) for the given DID.
///
/// "indy_key_for_local_did" call looks data stored in the local wallet only and skips freshness checking.
///
/// Note if you want to get fresh data from the ledger you can use "indy_key_for_did" call
/// instead.
///
/// Note that "indy_create_and_store_my_did" makes similar wallet record as "indy_create_key".
/// As result we can use returned ver key in all generic crypto and messaging functions.
///
/// #Params
/// command_handle: Command handle to map callback to caller context.
/// wallet_handle: Wallet handle (created by open_wallet).
/// did - The DID to resolve key.
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// Error Code
/// cb:
/// - xcommand_handle: Command handle to map callback to caller context.
/// - err: Error code.
/// - key - The DIDs ver key (key id).
///
/// #Errors
/// Common*
/// Wallet*
/// Crypto*
extern indy_error_t indy_key_for_local_did(indy_handle_t command_handle,
indy_handle_t wallet_handle,
const char *const did,

void (*cb)(indy_handle_t command_handle,
indy_error_t err,
const char *const key)
);

extern indy_error_t indy_set_endpoint_for_did(indy_handle_t command_handle,
indy_handle_t wallet_handle,
const char *const did,
Expand Down
64 changes: 62 additions & 2 deletions libindy/src/api/signus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,17 @@ pub extern fn indy_store_their_did(command_handle: i32,
}

/// Returns ver key (key id) for the given DID.
/// Note that indy_create_and_store_my_did makes similar wallet record as indy_create_key.
///
/// "indy_key_for_did" call follow the idea that we resolve information about their DID from
/// the ledger with cache in the local wallet. The "indy_open_wallet" call has freshness parameter
/// that is used for checking the freshness of cached pool value.
///
/// Note if you don't want to resolve their DID info from the ledger you can use
/// "indy_key_for_local_did" call instead that will look only to the local wallet and skip
/// freshness checking.
///
/// Note that "indy_create_and_store_my_did" makes similar wallet record as "indy_create_key".
/// As result we can use returned ver key in all generic crypto and messaging functions.
/// Note that this function looks to wallet and if no wallet record can lookup ledger.
///
/// #Params
/// command_handle: Command handle to map callback to caller context.
Expand Down Expand Up @@ -234,6 +242,58 @@ pub extern fn indy_key_for_did(command_handle: i32,
result_to_err_code!(result)
}

/// Returns ver key (key id) for the given DID.
///
/// "indy_key_for_local_did" call looks data stored in the local wallet only and skips freshness
/// checking.
///
/// Note if you want to get fresh data from the ledger you can use "indy_key_for_did" call
/// instead.
///
/// Note that "indy_create_and_store_my_did" makes similar wallet record as "indy_create_key".
/// As result we can use returned ver key in all generic crypto and messaging functions.
///
/// #Params
/// command_handle: Command handle to map callback to caller context.
/// wallet_handle: Wallet handle (created by open_wallet).
/// did - The DID to resolve key.
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// Error Code
/// cb:
/// - xcommand_handle: Command handle to map callback to caller context.
/// - err: Error code.
/// - key - The DIDs ver key (key id).
///
/// #Errors
/// Common*
/// Wallet*
/// Crypto*
#[no_mangle]
pub extern fn indy_key_for_local_did(command_handle: i32,
wallet_handle: i32,
did: *const c_char,
cb: Option<extern fn(xcommand_handle: i32,
err: ErrorCode,
key: *const c_char)>) -> ErrorCode {
check_useful_c_str!(did, ErrorCode::CommonInvalidParam3);
check_useful_c_callback!(cb, ErrorCode::CommonInvalidParam4);

let result = CommandExecutor::instance()
.send(Command::Signus(SignusCommand::KeyForLocalDid(
wallet_handle,
did,
Box::new(move |result| {
let (err, key) = result_to_err_code_1!(result, String::new());
let key = CStringUtils::string_to_cstring(key);
cb(command_handle, err, key.as_ptr())
})
)));

result_to_err_code!(result)
}

/// Returns endpoint information for the given DID.
///
/// #Params
Expand Down
38 changes: 38 additions & 0 deletions libindy/src/commands/signus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ pub enum SignusCommand {
i32, // wallet handle
String, // did (my or their)
Box<Fn(Result<String/*key*/, IndyError>) + Send>),
KeyForLocalDid(
i32, // wallet handle
String, // did (my or their)
Box<Fn(Result<String/*key*/, IndyError>) + Send>),
SetEndpointForDid(
i32, // wallet handle
String, // did
Expand Down Expand Up @@ -199,6 +203,10 @@ impl SignusCommandExecutor {
info!("KeyForDid command received");
self.key_for_did(pool_handle, wallet_handle, did, cb);
}
SignusCommand::KeyForLocalDid(wallet_handle, did, cb) => {
info!("KeyForLocalDid command received");
cb(self.key_for_local_did(wallet_handle, did));
}
SignusCommand::SetEndpointForDid(wallet_handle, did, address, transport_key, cb) => {
info!("SetEndpointForDid command received");
cb(self.set_endpoint_for_did(wallet_handle, did, address, transport_key));
Expand Down Expand Up @@ -460,6 +468,25 @@ impl SignusCommandExecutor {
cb(Ok(res))
}

fn key_for_local_did(&self,
wallet_handle: i32,
did: String) -> Result<String, IndyError> {
self.signus_service.validate_did(&did)?;

// Look to my did
match self._wallet_get_my_did(wallet_handle, &did) {
Ok(my_did) => return Ok(my_did.verkey),
Err(IndyError::WalletError(WalletError::NotFound(_))) => {}
Err(err) => return Err(err)
};

// look to their did
let their_did = self._wallet_get_local_their_did(wallet_handle, &did)?;

let res = their_did.verkey;
Ok(res)
}

fn set_endpoint_for_did(&self,
wallet_handle: i32,
did: String,
Expand Down Expand Up @@ -735,6 +762,17 @@ impl SignusCommandExecutor {
Ok(res)
}

fn _wallet_get_local_their_did(&self, wallet_handle: i32, their_did: &str) -> Result<Did, IndyError> {
let their_did_json = self.wallet_service.get(wallet_handle, &format!("their_did::{}", their_did))?;

let res = Did::from_json(&their_did_json)
.map_err(map_err_trace!())
.map_err(|err|
CommonError::InvalidState(
format!("Can't deserialize their Did: {}", err.description())))?;
Ok(res)
}

fn _wallet_set_my_temporary_did(&self, wallet_handle: i32, my_temporary_did: &Did) -> Result<(), IndyError> {
let my_temporary_did_json = Did::to_json(my_temporary_did)
.map_err(map_err_trace!())
Expand Down
14 changes: 2 additions & 12 deletions libindy/src/services/ledger/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,16 @@ use services::ledger::constants::{
GET_TXN
};

#[cfg(not(test))]
#[derive(Serialize, PartialEq, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Request<T: serde::Serialize> {
pub req_id: u64,
pub identifier: String,
pub operation: T,
#[cfg(not(test))]
#[serde(skip_serializing)]
pub protocol_version: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub signature: Option<String>
}

#[cfg(test)]
#[derive(Serialize, PartialEq, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Request<T: serde::Serialize> {
pub req_id: u64,
pub identifier: String,
pub operation: T,
#[cfg(test)]
pub protocol_version: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub signature: Option<String>
Expand Down
Loading

0 comments on commit d77d5ee

Please sign in to comment.