Veriscope Coalitions

Coalitions on the network are a group of Trust Anchors that agree to follow a set of rules within the coalition. Coalitions can be defined by jurisdiction and are managed by a set of administrators. These administrators can add and manage Trust Anchors in the coalition. Coalitions are meant to be self managed by the members of the coalition.

The following are the steps to creating a coalition, adding administrators and Trust Anchors to the coalition.

Step 1: Setting the jurisdiction of your TA Account

Prior to creating a coalition, each Trust Anchor must have their jurisdiction set in advance. Only onboarded and verified Trust Anchors can set their jurisdiction (see Step 1 VASP Onboarding).

Below is the function call to set the jurisdiction of a Trust Anchor account.

// node -e 'require("./coalitions").setupTrustAnchorJurisdiction(jurisdiction, trustAnchorAddress)'
module.exports.setupTrustAnchorJurisdiction = function (jurisdiction, trustAnchorAddress) {
setupTrustAnchorJurisdiction(jurisdiction, trustAnchorAddress);
};

The function call setupTrustAnchorJurisdiction executes the following code:

function setupTrustAnchorJurisdiction(jurisdiction, trustAnchorAddress) {
(async () => {
var tam = await TrustAnchorManager.deployed();
result = await tam.setupTrustAnchorJurisdiction.call(jurisdiction, {from: trustAnchorAddress});
console.log('setupTrustAnchorJurisdiction result');
console.log(result);
hash = await tam.setupTrustAnchorJurisdiction(jurisdiction, {from: trustAnchorAddress});
console.log('setupTrustAnchorJurisdiction hash');
console.log(hash);
})();
}

The expected response from the network should be "2 - trust anchor jurisdiction has been set up first time" like so:

BN { negative: 0, words: [ 2, <1 empty item> ], length: 1, red: null }

To query the jurisdiction of a Trust Anchor, the following function can be used:

// node -e 'require("./coalitions").getTrustAnchorJurisdiction(trustAnchorAddress)'
module.exports.getTrustAnchorJurisdiction = function (trustAnchorAddress) {
getTrustAnchorJurisdiction(trustAnchorAddress);
};

The above function call of getTrustAnchorJurisdiction executes the following code:

function getTrustAnchorJurisdiction(trustAnchorAddress) {
(async () => {
var tam = await TrustAnchorManager.deployed();
result = await tam.getTrustAnchorJurisdiction.call(trustAnchorAddress);
console.log('getTrustAnchorJurisdiction result');
console.log(result);
})();
}

The expected response from the network should be the jurisdiction number; e.g. 12:

BN { negative: 0, words: [ 12, <1 empty item> ], length: 1, red: null }

Step 2: Requesting a new coalition account and setting the primary administer

Next step is for a Trust Anchor account to request a new coalition address. A coalition address is a shyft account on the network similar to Trust Anchor accounts.

The request for a new coalition account can be done as follows:

// node -e 'require("./coalitions").trustAnchorCreateNewCoalitionAddress()'
module.exports.trustAnchorCreateNewCoalitionAddress = function () {
trustAnchorCreateNewCoalitionAddress();
};

The function trustAnchorCreateNewCoalitionAddress executes the following code:

function trustAnchorCreateNewCoalitionAddress() {
var result = web3.eth.accounts.create();
console.log(result);
}

The expected response from the network will include the new account and private key, for example:

{
address: '0x276264A872BeaC03C796dd192cb24120139Eba24',
privateKey: '0x611c7c6ea0299ae1626c0e7876df99a3b1158bc123b849299c4fcc28f88ecc44',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
}

The address: 0x276264A872BeaC03C796dd192cb24120139Eba24 is the new coalition account address. In order to register this account as a coalition, the account must be shared with Shyft Key Signers so that they may verify the coalition account and assign the primary Trust Anchor to the coalition.

Note: Assigning the primary Trust Anchor can only be done by the administrators of the Trust Channel contract.

Once the coalition has been set with a primary Trust Anchor account, this can be confirmed with the following:

// node -e 'require("./coalitions").getNumActiveTrustChannelAdministratorsForTrustChannel(trustChannelAddress, fromAddress)'
module.exports.getNumActiveTrustChannelAdministratorsForTrustChannel = function (trustChannelAddress, fromAddress) {
getNumActiveTrustChannelAdministratorsForTrustChannel(trustChannelAddress, fromAddress);
};

The function getNumActiveTrustChannelAdministratorsForTrustChannel executes the following code:

function getNumActiveTrustChannelAdministratorsForTrustChannel(trustChannelAddress, fromAddress) {
(async () => {
var tcm = await TrustChannelManager.deployed();
result = await tcm.getNumActiveTrustChannelAdministratorsForTrustChannel.call(trustChannelAddress, {from: fromAddress});
console.log('getNumActiveTrustChannelAdministratorsForTrustChannel result');
console.log(result);
console.log(result.toNumber());
})();
}

The expected response from the network should be the number of administrators of the coalition, in this case 1:

BN { negative: 0, words: [ 1, <1 empty item> ], length: 1, red: null }

To query the coalition for the adminstrator account, the following function can be used:

// node -e 'require("./coalitions").getTrustChannelAdministratorForTrustChannelByIndex(trustChannelAddress, index, fromAddress)'
module.exports.getTrustChannelAdministratorForTrustChannelByIndex = function (trustChannelAddress, index, fromAddress) {
getTrustChannelAdministratorForTrustChannelByIndex(trustChannelAddress, index, fromAddress);
};

The function getTrustChannelAdministratorForTrustChannelByIndex executes the following code:

function getTrustChannelAdministratorForTrustChannelByIndex(trustChannelAddress, index, fromAddress) {
(async () => {
var tcm = await TrustChannelManager.deployed();
result = await tcm.getTrustChannelAdministratorForTrustChannelByIndex.call(trustChannelAddress, index, {from: fromAddress});
console.log('getTrustChannelAdministratorForTrustChannelByIndex result');
console.log(result);
})();
}

In order for this coalition to be co-managed by another administrator, the primary Trust Anchor of the coalition can add another Trust Anchor as an administrator. This can be done with the following:

// node -e 'require("./coalitions").trustChannelAdministratorAddTrustChannelAdministrator(trustAnchorAddress, trustChannelAddress, fromAddress)'
module.exports.trustChannelAdministratorAddTrustChannelAdministrator = function (trustAnchorAddress, trustChannelAddress, fromAddress) {
trustChannelAdministratorAddTrustChannelAdministrator(trustAnchorAddress, trustChannelAddress, fromAddress);
};

The function trustChannelAdministratorAddTrustChannelAdministrator executes the following code:

function trustChannelAdministratorAddTrustChannelAdministrator(trustAnchorAddress, trustChannelAddress, fromAddress) {
(async () => {
var tcm = await TrustChannelManager.deployed();
result = await tcm.trustChannelAdministratorAddTrustChannelAdministrator.call(trustAnchorAddress, trustChannelAddress, {from: fromAddress});
console.log('trustChannelAdministratorAddTrustChannelAdministrator result');
console.log(result);
hash = await tcm.trustChannelAdministratorAddTrustChannelAdministrator(trustAnchorAddress, trustChannelAddress, {from: fromAddress});
console.log('trustChannelAdministratorAddTrustChannelAdministrator hash');
console.log(hash);
})();
}

With two administrators of the coalition, adding Trust Anchors to the coalition will require a request by both administrators.

Step 3: Adding Trust Anchors to a coalition

Here is how to add Trust Anchors to the coalition.

Note: Trust Anchors need to be onboarded and verified, and need their jurisdiction to be set before they can be added to a coalition.

// node -e 'require("./coalitions").trustChannelAdministratorAddTrustAnchorToTrustChannel(newTrustAnchorAddress, trustChannelAddress, fromAddress)'
module.exports.trustChannelAdministratorAddTrustAnchorToTrustChannel = function (newTrustAnchorAddress, trustChannelAddress, fromAddress) {
trustChannelAdministratorAddTrustAnchorToTrustChannel(newTrustAnchorAddress, trustChannelAddress, fromAddress);
};

The function trustChannelAdministratorAddTrustChannelAdministrator executes the following code:

function trustChannelAdministratorAddTrustAnchorToTrustChannel(newTrustAnchorAddress, trustChannelAddress, fromAddress) {
(async () => {
var tcm = await TrustChannelManager.deployed();
result = await tcm.trustChannelAdministratorAddTrustAnchorToTrustChannel.call(newTrustAnchorAddress, trustChannelAddress, {from: fromAddress});
console.log('trustChannelAdministratorAddTrustAnchorToTrustChannel result');
console.log(result);
hash = await tcm.trustChannelAdministratorAddTrustAnchorToTrustChannel(newTrustAnchorAddress, trustChannelAddress, {from: fromAddress});
console.log('trustChannelAdministratorAddTrustAnchorToTrustChannel hash');
console.log(hash);
})();
}

Below are the available responses from the function:

0 = not trust channel administrator
1 = requires more administrator votes
2 = trust channel not active
3 = trust anchor already within mapping
4 = could not set up trust anchor (trust anchor has not been onboarded + verified and then has set their jurisdiction)
5 = trust anchor added to trust channel

Note: trustChannelAdministratorAddTrustAnchorToTrustChannel must be executed by each administrator of the coalition. Desired response is "5 = trust anchor added to trust channel".

Now that the Trust Anchor has been added to the coalition, queries can be made against the Trust Channel contract, to determine if a Trust Anchor belongs to a coalition.

// node -e 'require("./coalitions").getAllTrustChannelAddressesForTrustAnchor(trustAnchorAddress, fromAddress)'
module.exports.getAllTrustChannelAddressesForTrustAnchor = function (trustAnchorAddress, fromAddress) {
getAllTrustChannelAddressesForTrustAnchor(trustAnchorAddress, fromAddress);
};

The function getAllTrustChannelAddressesForTrustAnchor executes the following code:

function getAllTrustChannelAddressesForTrustAnchor(trustAnchorAddress, fromAddress) {
(async () => {
var tcm = await TrustChannelManager.deployed();
result = await tcm.getAllTrustChannelAddressesForTrustAnchor(trustAnchorAddress, {from: fromAddress});
console.log('getAllTrustChannelAddressesForTrustAnchor result');
console.log(result);
})();
}

The response will return a list of all coalition addresses that the Trust Anchor belongs to.

Note: Trust Anchors can belong to many coalitions.