Class Gateway

  • NSObject

    • KeychainCore/Gateway

Gateway

Gateway manages Personas, Contacts, all associated private keys (blockchain and application). This class performs all blockchain network requests, all database interactions, and performs application-level cryptographic operations encrypt, decrypt, sign, and verify.

Constructor Summary

Constructor and Description

public init(_ configPath: String!, _ dbPath: String!, _ force: Bool, _ dropSqlFile: String!, _ createSqlFile: String!) throws

* configPath points to the keychain.cfg file in your resource bundle

* dbPath is the path to a writable folder that your app has access to, where the keychain database will be created

* force should be true if the database is to be recreated if it already exists at dbPath. This parameter should be false under most circumstances. Otherwise, the database will be overridden every time you start your application

* dropSqlFile points to the drop_keychain.sql file in your application resource bundle. This scrip is used to drop the database if force is set to true

* createSQlFile points to the keychain.sql file in your application resource bundle. This script is used to create the keychain database

Instance Methods

Return type Method and Description

Asset

open func createAsset(_ symbol: String!) throws → Asset

Create/issue custom digital asset.

Contact

open func createContact(_ name: String!, _ subName: String!, _ uri: Uri!) throws → Contact

Create a contact.

Persona

open func createPersona(_ name: String!, _ subName: String!, _ secLevel: SecurityLevel) throws → Persona

Create a new persona.

String

open func decrypt(_ cipherText: String!) throws → String

Decrypt to a string (binary or not).

String

open func decryptThenVerify(_ cipherText: String!) throws → String

Decrypt then verify data that has been signed and encrypted as a string.

void

open func delete(_ contact: Contact!) throws

Delete a contact.

void

open func delete(_ persona: Persona!) throws

Delete a persona.

String

open func encrypt(_ clearText: String!, _ contacts: [Contact]!) throws → String

Encrypt a string so that it can be decrypted by the given contacts.

Persona

open func getActivePersona() → Persona!

Get the active persona.

[Contact]

open func getContacts() throws → [Contact]

Get the list of contacts for the current active persona.

[Persona]

open func getPersonas() throws → [Persona]

Get the list of personas.

void

open func renameContact(_ contact: Contact!, _ newName: String!, _ newSubName: String!) throws

Renames a contact.

void

open func renamePersona(_ persona: Persona!, _ newName: String!, _ newSubName: String!) throws

Renames a persona.

BOOL

open func renewCertificate(_ persona: Persona!) throws

Renew the given persona’s certificate.

NSNumber

open func seed(_ address: String!, _ mnemonicList: NSMutableArray!) throws → NSNumber

Seed the private key pool and generate mnemonic recovery string.

BOOL

open func setActivePersona(_ persona: Persona!) throws

Set the active persona.

String

open func sign(_ clearText: String!) throws → String

Sign a string.

String

open func signThenEncrypt(_ contacts: [Contact]!, _ clearText: String!) throws → String

Sign then encrypt a string so that it can be decrypted (and verified) by the given contacts.

LedgerResult

open func transferAsset(_ contact: Contact!, _ approver: Facade!, _ asset: Asset!, _ amount: Int64, _ reason: String!, _ isIssuance: Bool) throws → LedgerResult

Create a transaction to send the asset to the specified receiver.

LedgerResult

open func updateLedger(_ trxnStr: String!, _ approver: Facade!) throws → LedgerResult

Update local ledger with transaction/response from peers.

String

open func verify(_ verifications: NSMutableArray!, _ signedMessage: String!) throws → String

Verify the signature(s) of a signed string. The list of Verifications will be returned in the verifications parameter.