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 #1725 from Artemkaaas/revert-taa
Browse files Browse the repository at this point in the history
Revert TAA time discarding
  • Loading branch information
jovfer authored Jul 15, 2019
2 parents dbabaa4 + 49d8e48 commit 0718ac0
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 46 deletions.
4 changes: 2 additions & 2 deletions ci/indy-pool.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ 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.9.0~dev836
ARG indy_node_ver=1.9.0~dev1025
ARG indy_plenum_ver=1.9.0~dev808
ARG indy_node_ver=1.9.0~dev987
ARG python3_indy_crypto_ver=0.4.5
ARG indy_crypto_ver=0.4.5

Expand Down
3 changes: 1 addition & 2 deletions libindy/include/indy_ledger.h
Original file line number Diff line number Diff line change
Expand Up @@ -1212,8 +1212,7 @@ extern "C" {
/// These parameters are required if taa_digest parameter is omitted.
/// taa_digest - (optional) hash on text and version. This parameter is required if text and version parameters are omitted.
/// mechanism - mechanism how user has accepted the TAA
/// time - UTC timestamp when user has accepted the TAA. Note that the time portion will be discarded to avoid a privacy risk.
///
/// time - UTC timestamp when user has accepted the TAA
/// cb: Callback that takes command result as parameter.
///
/// #Returns
Expand Down
2 changes: 1 addition & 1 deletion libindy/src/api/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2322,7 +2322,7 @@ pub extern fn indy_build_get_acceptance_mechanisms_request(command_handle: Comma
/// These parameters are required if taa_digest parameter is omitted.
/// taa_digest - (optional) digest on text and version. This parameter is required if text and version parameters are omitted.
/// mechanism - mechanism how user has accepted the TAA
/// time - UTC timestamp when user has accepted the TAA. Note that the time portion will be discarded to avoid a privacy risk.
/// time - UTC timestamp when user has accepted the TAA
/// cb: Callback that takes command result as parameter.
///
/// #Returns
Expand Down
16 changes: 1 addition & 15 deletions libindy/src/services/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,17 +519,12 @@ impl LedgerService {
let acceptance_data = TxnAuthrAgrmtAcceptanceData {
mechanism: mechanism.to_string(),
taa_digest,
time: LedgerService::datetime_to_date_timestamp(time),
time,
};

Ok(acceptance_data)
}

fn datetime_to_date_timestamp(time: u64) -> u64{
const SEC_IN_DAY: u64 = 86400;
time / SEC_IN_DAY * SEC_IN_DAY
}

fn _calculate_hash(&self, text: &str, version: &str) -> IndyResult<Vec<u8>> {
let content: String = version.to_string() + text;
openssl_hash(content.as_bytes())
Expand Down Expand Up @@ -1240,15 +1235,6 @@ mod tests {
}
}

#[test]
fn datetime_to_date(){
assert_eq!(0, LedgerService::datetime_to_date_timestamp(0));
assert_eq!(0, LedgerService::datetime_to_date_timestamp(20));
assert_eq!(1562284800, LedgerService::datetime_to_date_timestamp(1562367600));
assert_eq!(1562284800, LedgerService::datetime_to_date_timestamp(1562319963));
assert_eq!(1562284800, LedgerService::datetime_to_date_timestamp(1562284800));
}

fn check_request(request: &str, expected_result: serde_json::Value) {
let request: serde_json::Value = serde_json::from_str(request).unwrap();
assert_eq!(request["operation"], expected_result);
Expand Down
7 changes: 1 addition & 6 deletions libindy/tests/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2635,18 +2635,13 @@ mod high_cases {
const ACCEPTANCE_MECH_TYPE: &str = "acceptance type 1";
const TIME_OF_ACCEPTANCE: u64 = 123456789;

fn _datetime_to_date_timestamp(time: u64) -> u64{
const SEC_IN_DAY: u64 = 86400;
time / SEC_IN_DAY * SEC_IN_DAY
}

fn _check_request_meta(request: &str) {
let request: serde_json::Value = serde_json::from_str(&request).unwrap();

let expected_meta = json!({
"mechanism": ACCEPTANCE_MECH_TYPE,
"taaDigest": HASH,
"time": _datetime_to_date_timestamp(TIME_OF_ACCEPTANCE)
"time": TIME_OF_ACCEPTANCE
});

assert_eq!(request["taaAcceptance"], expected_meta);
Expand Down
2 changes: 1 addition & 1 deletion libindy/tests/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ mod high_cases {
const VERSION: &str = "1.0.0";
const HASH: &str = "050e52a57837fff904d3d059c8a123e3a04177042bf467db2b2c27abd8045d5e";
const ACCEPTANCE_MECH_TYPE: &str = "acceptance type 1";
const TIME_OF_ACCEPTANCE: u64 = 123379200;
const TIME_OF_ACCEPTANCE: u64 = 123456789;

fn _check_request_meta(extra: &str) {
let extra: serde_json::Value = serde_json::from_str(&extra).unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -883,13 +883,13 @@ - (void)testAppendTxnAuthorAgreementAcceptanceToRequestWorks {
version:@"1.0.0"
taaDigest:@"050e52a57837fff904d3d059c8a123e3a04177042bf467db2b2c27abd8045d5e"
accMechType:@"acceptance type 1"
timeOfAcceptance:@(123379200)
timeOfAcceptance:@(123456789)
outRequest:&requestJson];
XCTAssertEqual(ret.code, Success, @"LedgerUtils::buildTxnAuthorAgreementRequestWithSubmitterDid() failed!");
NSDictionary *expectedMeta = @{
@"mechanism": @"acceptance type 1",
@"taaDigest": @"050e52a57837fff904d3d059c8a123e3a04177042bf467db2b2c27abd8045d5e",
@"time": @(123379200),
@"time": @(123456789),
};

request = [NSDictionary fromString:requestJson];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ - (void)testPreparePaymentExtraWithAcceptanceDataWorks {
version:@"1.0.0"
taaDigest:@"050e52a57837fff904d3d059c8a123e3a04177042bf467db2b2c27abd8045d5e"
accMechType:@"acceptance type 1"
timeOfAcceptance:@(123379200)
timeOfAcceptance:@(123456789)
extraWithAcceptance:&extraWithAcceptance];
XCTAssertEqual(ret.code, Success, @"PaymentUtils::preparePaymentExtraWithAcceptanceData() failed!");
NSDictionary *expectedExtra = @{
@"data": @"some extra data",
@"taaAcceptance": @{
@"mechanism": @"acceptance type 1",
@"taaDigest": @"050e52a57837fff904d3d059c8a123e3a04177042bf467db2b2c27abd8045d5e",
@"time": @(123379200),
@"time": @(123456789),
}
};

Expand Down
2 changes: 1 addition & 1 deletion wrappers/ios/libindy-pod/Indy/Wrapper/IndyLedger.h
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@
text and version are required if taaDigest parameter is omitted.
@param taaDigest (Optional) hash on text and version. This parameter is required if text and version parameters are omitted.
@param accMechType mechanism how user has accepted the TAA
@param timeOfAcceptance UTC timestamp when user has accepted the TAA. Note that the time portion will be discarded to avoid a privacy risk.
@param timeOfAcceptance UTC timestamp when user has accepted the TAA
Returns Updated request result as json.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ public static CompletableFuture<String> buildGetAcceptanceMechanismsRequest(
* `text` and `version` parameters are required if taaDigest parameter is omitted.
* @param taaDigest - (Optional) digest on text and version. This parameter is required if text and version parameters are omitted.
* @param mechanism - mechanism how user has accepted the TAA
* @param time - UTC timestamp when user has accepted the TAA. Note that the time portion will be discarded to avoid a privacy risk.
* @param time - UTC timestamp when user has accepted the TAA
*
* @return A future resolving to an updated request result as json.
* @throws IndyException Thrown if an error occurs when calling the underlying SDK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.json.JSONObject;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;


Expand All @@ -15,7 +16,7 @@ public class AppendAuthorAgreementAcceptanceToRequestTest extends IndyIntegratio
private String version = "1.0.0";
private String acceptanceMechanismType = "acceptance type 1";
private String hash = "050e52a57837fff904d3d059c8a123e3a04177042bf467db2b2c27abd8045d5e";
private int timeOfAcceptance = 123379200;
private int timeOfAcceptance = 123456789;
private String request = "{ \n" +
" \"reqId\": 1496822211362017764, \n" +
" \"identifier\": \"GJ1SzoWzavQYfNL9XkaJdrQejfztN4XqdsiV4ct3LXKL\", \n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class PreparePaymentExtraWithAcceptanceDataTest extends IndyIntegrationTe
private String version = "1.0.0";
private String acceptanceMechanismType = "acceptance type 1";
private String hash = "050e52a57837fff904d3d059c8a123e3a04177042bf467db2b2c27abd8045d5e";
private int timeOfAcceptance = 123379200;
private int timeOfAcceptance = 123456789;
private JSONObject taaAcceptance = new JSONObject()
.put("mechanism", acceptanceMechanismType)
.put("taaDigest", hash)
Expand Down
2 changes: 1 addition & 1 deletion wrappers/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,7 @@ If all text, version and taaDigest parameters are specified, a check integrity o
* `text` and `version` parameters are required if taaDigest parameter is omitted.
* `taaDigest`: String - \(Optional\) hash on text and version. This parameter is required if text and version parameters are omitted.
* `accMechType`: String - mechanism how user has accepted the TAA.
* `timeOfAcceptance`: Timestamp (Number) - UTC timestamp when user has accepted the TAA. Note that the time portion will be discarded to avoid a privacy risk.
* `timeOfAcceptance`: Timestamp (Number) - UTC timestamp when user has accepted the TAA.

* __->__ `request`: Json

Expand Down
8 changes: 4 additions & 4 deletions wrappers/nodejs/test/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ test('ledger', async function (t) {
req = await indy.buildAcceptanceMechanismsRequest(trusteeDid, aml, '1.0.0', null)
t.deepEqual(req['operation'], { 'type': '5', 'aml': aml, 'version': '1.0.0' })

req = await indy.buildGetAcceptanceMechanismsRequest(null, 123379200, null)
t.deepEqual(req['operation'], { 'type': '7', 'timestamp': 123379200 })
req = await indy.buildGetAcceptanceMechanismsRequest(null, 123456789, null)
t.deepEqual(req['operation'], { 'type': '7', 'timestamp': 123456789 })

// author agreement acceptance data
req = await indy.appendTxnAuthorAgreementAcceptanceToRequest(req, 'indy agreement', '1.0.0', null, 'acceptance mechanism label 1', 123379200)
req = await indy.appendTxnAuthorAgreementAcceptanceToRequest(req, 'indy agreement', '1.0.0', null, 'acceptance mechanism label 1', 123456789)
var expectedMeta = {
'mechanism': 'acceptance mechanism label 1',
'taaDigest': '7213b9aabf8677edf6b17d20a9fbfaddb059ea4cb122d163bdf658ea67196120',
'time': 123379200
'time': 123456789
}
t.deepEqual(req['taaAcceptance'], expectedMeta)

Expand Down
4 changes: 2 additions & 2 deletions wrappers/nodejs/test/payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ test('payments', async function (t) {
err = await t.throwsAsync(indy.parsePaymentResponse(paymentMethod, {}))
t.is(err.indyName, 'PaymentUnknownMethodError')

var extra = await indy.preparePaymentExtraWithAcceptanceData(null, 'indy agreement', '1.0.0', null, 'acceptance mechanism label 1', 123379200)
var extra = await indy.preparePaymentExtraWithAcceptanceData(null, 'indy agreement', '1.0.0', null, 'acceptance mechanism label 1', 123456789)
var expectedExtra = {
'mechanism': 'acceptance mechanism label 1',
'taaDigest': '7213b9aabf8677edf6b17d20a9fbfaddb059ea4cb122d163bdf658ea67196120',
'time': 123379200
'time': 123456789
}
t.deepEqual(extra['taaAcceptance'], expectedExtra)

Expand Down
2 changes: 1 addition & 1 deletion wrappers/python/indy/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ async def append_txn_author_agreement_acceptance_to_request(request_json: str,
These parameters are required if taa_digest parameter is omitted.
:param taa_digest: (Optional) hash on text and version. This parameter is required if text and version parameters are omitted.
:param mechanism: mechanism how user has accepted the TAA
:param time: UTC timestamp when user has accepted the TAA. Note that the time portion will be discarded to avoid a privacy risk.
:param time: UTC timestamp when user has accepted the TAA
:return: Updated request result as json.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
VERSION = '1.0.0'
ACCEPTANCE_MECH_TYPE = 'acceptance type 1'
TAA_DIGEST = '050e52a57837fff904d3d059c8a123e3a04177042bf467db2b2c27abd8045d5e'
TIME_OF_ACCEPTANCE = 123379200
TIME_OF_ACCEPTANCE = 123456789
REQUEST = json.dumps({
"reqId": 1496822211362017764,
"identifier": "GJ1SzoWzavQYfNL9XkaJdrQejfztN4XqdsiV4ct3LXKL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
VERSION = '1.0.0'
ACCEPTANCE_MECH_TYPE = 'acceptance type 1'
TAA_DIGEST = '050e52a57837fff904d3d059c8a123e3a04177042bf467db2b2c27abd8045d5e'
TIME_OF_ACCEPTANCE = 123379200
TIME_OF_ACCEPTANCE = 123456789
EXTRA = {
"data": "some extra",
}
Expand Down
2 changes: 1 addition & 1 deletion wrappers/rust/src/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ fn _build_get_acceptance_mechanisms_request(command_handle: CommandHandle,
/// These parameters are required if taa_digest parameter is omitted.
/// * `taa_digest`: (optional) digest on text and version. This parameter is required if text and version parameters are omitted.
/// * `mechanism`: mechanism how user has accepted the TAA
/// * `time`: UTC timestamp when user has accepted the TAA. Note that the time portion will be discarded to avoid a privacy risk.
/// * `time`: UTC timestamp when user has accepted the TAA
///
/// # Returns
/// Updated request result as json.
Expand Down

0 comments on commit 0718ac0

Please sign in to comment.