Start to Use (Example)
If you've not launched your own Intu dEOA before, your first step would be just that!
The following examples are in JavaScript, please let us know if you have questions or problems using it in another language.
Please note we do use 'user' and 'participant' interchangably.
- 1.For this first step we are going to create a new Intu dEOA and then retrieve it. We are assuming that Intu Contract has already been determined with the previous step.
- 2.Before creating the dEOA, you'll need to generate a message for all participants to sign, and then you'll need to call the getencryptionkey endpoint, so you can store both of these pieces of information with your initial smart contract creation. Every user will need to call the getencryptionkey endpoint to 'register' with the dEOA smart contract. The purpose of this key is to encrypt the keyshares that each user will get.
Then, Create a smart contract so that Intu knows who can interact with your MPC. The next step will be registration from the participants, and then finally completing the Intu MPC.
--------------------------------------------------------------------------------------------------
- 3.Then we can retrieve our vault data with 2 steps. First, getting all of the vault ids that an a user has access to, then, you can loop through the array of IDs to get vault details.
Attached is a general workflow that needs to take place from initial proposal of a Intu dEOA. (Thank you to our friend Joseph for the image!)
1. One user proposes a vault, they create a random encryption message for all other users, they include all of the other user addresses involved with the vault, and the thresholds.
2. Other participants sign the encryption message, and store the result of that to confirm they 'register' with the vault.
3. Once everyone has registered, you can then run the keygen operation and then Intu dEOA vault creation is complete and ready for use!
Returns vaults that a user is associated with
Output | Type of Output |
---|---|
vault ids | Array<Number> |
1
INTUContract.getUserVaults();
Then, take that result, loop through it, and store the result of each getVaultInfo to get all the user's vaults and vault details.
Returns vault information given a vaultID
Input | Type of Input | Description |
---|---|---|
vaultId | Number | The id of the vault |
Output | Type of Output | Description |
---|---|---|
vaultName | String | The name of the vault |
arrayOfUsersInVault | Array | An array of users in the vault |
createdTime | Number | The time when the vault was created |
masterPublicKey | String | The master public key of the vault |
transactionThreshold | Number | The transaction threshold of the vault |
administrativeThreshold | Number | The administrative threshold of the vault |
registeredUsers | Number | The number of registered users in the vault |
vaultMessage | String | The vaults public message for users to sign against. |
1
INTUContract.getVaultInfo(vaultId);
Next, after each user confirms the Intu proposal looks good, they will need to register with the vault. They do that by signing that vaults random message.
(assuming signer is connected via ethers)\
//get message
INTUContract.getVaultInfo(vaultId);
// sign message
let signature = await signer.signMessage(signmessage);
//prep data to send to API
let datatoSend = JSON.stringify({ signature: signature });
// send data to api, take result and store it in vault
fetch("http://localhost:8080/getencryptionkey", {
headers: {
"Content-Type": "text/plain",
},
mode: "cors",
referrerPolicy: "no-referrer",
cache: "no-cache",
method: "POST",
body: datatoSend,
});
// take the response and store it in the vault
INTUContract.register(vaultId, encryptionPublicKey);
Once each user performs this action, the Intu MPC will be officially ready to be launched.
First, hit our keygen endpoint with the appropriate info, then push that data to userCompleteVault.
And hang tight, keygen take a few seconds to run!\
1
let n = vault.vaultUsers;
2
let t = Math.ceil((vaultUsers.length * vault.transactionThreshold) / 100);
3
if (n.length === t) {
4
t = n.length - 1;
5
}
6
let encryptionkeys = [];
7
for (let i = 0; i < vault.vaultUsers.length; i++) {
8
await INTUContract.userPublicKeyForEncryption(vaultId, userAddress).then((res) => {
9
encryptionkeys.push(res);
10
});
11
}
12
let dataToSend = JSON.stringify({ participants: n, threshold: t, encryptionkeys: encryptionkeys });
13
fetch("http://localhost:8080/keygen", {
14
headers: {
15
"Content-Type": "text/plain",
16
},
17
mode: "cors",
18
referrerPolicy: "no-referrer",
19
cache: "no-cache",
20
method: "POST",
21
body: dataToSend,
22
})
23
.then((res) => res.json())
24
.then((res) => {
25
let encryptedShares = res.keys.replace("[", "");
26
encryptedShares = encryptedShares.replace("]", "");
27
encryptedShares = encryptedShares.split(" ");
28
masterPublicKey = res.eoa;
29
INTUContract.userCompleteVault(vaultId, encryptedShares, masterPublicKey);
30
});
Whew, that was a lot, but now you have an Intu MPC live!
Last modified 5d ago