Class Gateway
Package: io.keychain.core
public class Gateway extends java.lang.Object
Description
Gateway
performs application-level cryptographic operations encrypt, decrypt, sign, and verify.
Through the Gateway
users create personas and contacts, and execute the cryptographic operations with respect to those entities.
In the Java wrapper, the Gateway
takes on the role of blockchain monitor as well, so the only reader and writer to the Keychain database is the single Gateway
instance.
Since: v2.0
Public Constructors
Constructor |
---|
Constructs a |
Public Member Functions
Return type | Method and Description |
---|---|
|
Pause the monitor thread |
|
Run/resume the monitor thread |
|
Create the monitor thread if it did not exist |
|
Stop and destroy the monitor thread if it exists |
|
Deprecated |
|
Update the local blockchain state |
|
Seeds the private key pool and generates a mnemonic recovery string. |
Creates a persona in the |
|
|
Sets the active persona to the provided |
Returns the current active persona, if any |
|
|
Returns |
|
Returns a list of personas in the |
|
Revokes and replaces existing current certificate for given persona on the blockchain |
Creates a contact for the current active persona with the given identity information |
|
|
Returns a list of contacts for the current active persona |
|
Deletes the provided persona |
|
Deletes the provided contact for this persona |
|
Renames the persona with the new provided name and subname |
|
Renames the contact with the new provided name and subname |
|
Signs a clear text string with the current active persona’s signature |
|
Adds the current persona’s signature to a signed message |
|
Encrypts a clear text byte array so it can be decrypted by the provided contacts |
|
Signs a clear text string with the current active persona’s signature, then encrypts for the provided contact list |
|
Decrypts the cipher text into a byte array with information about how the text was originally encoded |
|
Decrypts the cipher text into a byte array that has also had signatures verified. Use |
|
Decrypts the cipher text into a String representation |
Verifies the signed text |
|
|
Change the monitor thread’s |
Static Member Functions
Return type | Method and Description |
---|---|
Creates a Keychain |
Public Member Functions Detail
onPause
|
|
Pause the monitor thread. Block the monitor thread if it was unblocked and running. The thread will remain blocked until |
onResume
|
|
Run/resume the monitor thread. This method starts/unblocks the monitor thread if it was blocked or not running. If the thread does not exist upon calling |
onStart
|
|
Create the monitor thread if it did not exist. Note that this does not start the thread. Use |
onStop
|
|
Stop and destroy the monitor thread if it exists. If the thread is running upon entry in this method, this method will (safely) cause the thread to stop execution before destroying it. |
updateBlokchainState
|
|
Update the local blockchain state. Fetches the relevant blockchain state from the network and updates the local cache for certificates and UTXOs. |
seed
|
|
Seeds the private key pool and generates a mnemonic recovery string. Should be run once a |
createPersona
|
|
Creates a new persona in the |
|
Parameters: |
|
|
|
|
|
|
|
Returns: |
|
The newly created persona |
setActivePersona
|
|
Sets the active persona in the |
|
Parameters: |
|
|
getActivePersona
|
|
Returns the current active persona in the |
|
Returns: |
|
The current active persona |
|
Raises: |
|
|
maturePersonaExists
|
|
Checks to see if the |
|
Returns: |
|
|
getPersonas
|
|
Returns all personas in the |
|
Returns: |
|
an |
replaceCertificate
|
|
Revoke and replace existing current certificate for given persona on the blockchain. This method creates a new set of public/private key pairs that will, over time, be used for encryption/decryption and signing/verifying. It is good practice to replace certificates periodically in order to provide forward security for subsequently encrypted/signed data. Note that the certificate replacement happens asyncronous to this call, however when it happens, it will be reflected locally atomically. That is, suppose you call this method while encrypting a stream of data. Then at some point in the future, the new certificate will be confirmed on the blockchain, and with respect to the data stream encryption, there will be a point at which the old certificate will stop being used and the new will begin to be used. This happens transparently to the developer’s code in the sense that there is otherwise no programmatic differentiation that the developer make in order to start using the new certificate; it happens automatically subject to confirmation on the blockchain. Note: this method blocks on network operations, so should not be called on the main/UI thread. Call this method in, for example, an AsyncTask. |
createContact
|
|
Creates a new contact for the current active persona with the given identity information. The contact |
|
Parameters: |
|
|
|
|
|
|
|
Returns: |
|
The created contact |
getContacts
|
|
Returns all contacts for the current active persona. |
|
Returns: |
|
an |
deletePersona
|
|
Deletes a |
|
Parameters: |
|
|
deleteContact
|
|
Deletes a |
|
Parameters: |
|
|
renamePersona
|
|
Renames the |
|
Parameters: |
|
|
|
|
|
|
renameContact
|
|
Renames the |
|
Parameters: |
|
|
|
|
|
|
sign
|
|
Signs the clear text data |
|
Parameters: |
|
|
|
|
|
|
|
Returns: |
|
A signed message |
addSignature
|
|
Adds the current persona’s signature to an existing signed data. Unlike |
|
Parameters: |
|
|
|
|
|
Returns: |
|
An updated signed message |
encrypt
|
|
Encrypts the cleartext for the provided contacts, returning an XML string representation. |
|
Parameters: |
|
|
|
|
|
Returns: |
|
A String representation of the encrypted text. This is an XML serialization format used by Keychain. |
signThenEncrypt
|
|
Signs the clear text and then encrypts it for the provided contacts |
|
Parameters: |
|
|
|
|
|
Returns: |
|
A String representation of the signed and encrypted text. This is an XML serialization format used by Keychain. |
decrypt
|
|
Decrypts the cipher text into a |
|
Parameters: |
|
|
|
Returns: |
|
The plaintext as a |
decryptThenVerify
|
|
Decrypts the cipher text into a |
|
Parameters: |
|
|
|
Returns: |
|
A |
decryptThenVerifyString
|
|
This method does exactly what |
|
Parameters: |
|
|
|
Returns: |
|
The decrypted text as a UTF-8 |
Static Member Functions Detail
initializeDb
|
|
Creates a Keychain |
|
Parameters: |
|
|
|
|
|
|
|
|
|
Returns: |
|
A |