Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed May 16, 2024
1 parent cb91627 commit 2995be8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 31 deletions.
49 changes: 28 additions & 21 deletions Sources/TorusUtils/Helpers/NodeUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,29 +238,36 @@ internal class NodeUtils {

if isImport {
do {
let importShare = importedShares![i]

let shareRequestItem = ShareRequestParams.ShareRequestItem(
verifieridentifier: verifier,
verifier_id: verifierParams.verifier_id,
extended_verifier_id: verifierParams.extended_verifier_id,
idtoken: idToken,
nodesignatures: nodeSigs,
pub_key_x: importShare.pubKeyX,
pub_key_y: importShare.pubKeyY,
encrypted_share: importShare.encryptedShare,
encrypted_share_metadata: importShare.encryptedShareMetadata,
node_index: importShare.nodeIndex,
key_type: importShare.keyType,
nonce_data: importShare.nonceData,
nonce_signature: importShare.nonceSignature,
// extra_params: extraData
sub_verifier_ids: verifierParams.sub_verifier_ids,
session_token_exp_second: sessionExpiry,
verify_params: verifierParams.verify_params
)
var importedItems: [ShareRequestParams.ShareRequestItem] = []
for j in 0 ..< endpoints.count {
let importShare = importedShares![j]

let shareRequestItem = ShareRequestParams.ShareRequestItem(
verifieridentifier: verifier,
verifier_id: verifierParams.verifier_id,
extended_verifier_id: verifierParams.extended_verifier_id,
idtoken: idToken,
nodesignatures: nodeSigs,
pub_key_x: importShare.pubKeyX,
pub_key_y: importShare.pubKeyY,
encrypted_share: importShare.encryptedShare,
encrypted_share_metadata: importShare.encryptedShareMetadata,
node_index: importShare.nodeIndex,
key_type: importShare.keyType,
nonce_data: importShare.nonceData,
nonce_signature: importShare.nonceSignature,
// extra_params: extraData
sub_verifier_ids: verifierParams.sub_verifier_ids,
session_token_exp_second: sessionExpiry,
verify_params: verifierParams.verify_params,
sss_endpoint: endpoints[j]
)

importedItems.append(shareRequestItem)
}

let params = ShareRequestParams(encrypted: "yes", item: [shareRequestItem], client_time: String(Int(floor(Date().timeIntervalSince1970 / 1000))))
let params = ShareRequestParams(encrypted: "yes", item: importedItems, client_time: String(Int(floor(Date().timeIntervalSince1970 / 1000))))

let jsonRPCRequest = JRPCRequest(
method: JRPC_METHODS.IMPORT_SHARE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ internal struct ShareRequestParams: Codable {
public var sub_verifier_ids: [String]?
public var session_token_exp_second: Int?
public var verify_params: [VerifyParams?]?
public var sss_endpoint: String?
}
public var encrypted: String = "yes"
public var item: [ShareRequestItem]
Expand Down
8 changes: 3 additions & 5 deletions Tests/TorusUtilsTests/SapphireDevnetTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ final class SapphireDevnetTest: XCTestCase {
XCTAssertEqual(val.metadata?.typeOfUser, .v2)
XCTAssertNotNil(val.nodesData)
}

/*
/*
func test_should_be_able_to_import_key_for_a_new_user() async throws {
let fakeEmail = generateRandomEmail(of: 6)
let jwt = try generateIdToken(email: fakeEmail)
Expand All @@ -59,12 +58,11 @@ final class SapphireDevnetTest: XCTestCase {

let verifierParams = VerifierParams(verifier_id: verifierID)

let val = try await torus.importPrivateKey(endpoints: nodeDetails.getTorusNodeEndpoints(), nodeIndexes: nodeDetails.getTorusIndexes(), nodePubKeys: nodeDetails.getTorusNodePub(), verifier: verifier, verifierParams: verifierParams, idToken: jwt, newPrivateKey: privateKey)
let val = try await torus.importPrivateKey(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), nodeIndexes: nodeDetails.getTorusIndexes(), nodePubKeys: nodeDetails.getTorusNodePub(), verifier: verifier, verifierParams: verifierParams, idToken: jwt, newPrivateKey: privateKey)

XCTAssertEqual(val.finalKeyData.privKey, privateKey)
}
*/

*/
func test_should_be_able_to_key_assign() async throws {
let fakeEmail = generateRandomEmail(of: 6)
let verifier = TORUS_TEST_VERIFIER
Expand Down
8 changes: 3 additions & 5 deletions Tests/TorusUtilsTests/SapphireMainnetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class SapphireMainnetTests: XCTestCase {
XCTAssertEqual(val.metadata?.typeOfUser, .v2)
XCTAssertNotNil(val.nodesData)
}

/*
/*
func test_should_be_able_to_import_key_for_a_new_user() async throws {
let fakeEmail = generateRandomEmail(of: 6)
let jwt = try generateIdToken(email: fakeEmail)
Expand All @@ -62,12 +61,11 @@ class SapphireMainnetTests: XCTestCase {

let verifierParams = VerifierParams(verifier_id: verifierID)

let val = try await torus.importPrivateKey(endpoints: nodeDetails.getTorusNodeEndpoints(), nodeIndexes: nodeDetails.getTorusIndexes(), nodePubKeys: nodeDetails.getTorusNodePub(), verifier: verifier, verifierParams: verifierParams, idToken: jwt, newPrivateKey: privateKey)
let val = try await torus.importPrivateKey(endpoints: nodeDetails.getTorusNodeSSSEndpoints(), nodeIndexes: nodeDetails.getTorusIndexes(), nodePubKeys: nodeDetails.getTorusNodePub(), verifier: verifier, verifierParams: verifierParams, idToken: jwt, newPrivateKey: privateKey)

XCTAssertEqual(val.finalKeyData.privKey, privateKey)
}
*/

*/
func test_should_be_able_to_key_assign() async throws {
let fakeEmail = generateRandomEmail(of: 6)
let verifier = "tkey-google-sapphire-mainnet"
Expand Down

0 comments on commit 2995be8

Please sign in to comment.