Generators supporting confidential inputs
Operations listed below are only relevant for Generators which run enclaves in order to join Markets supporting confidential inputs. General operations relevant to all Generators are listed in the previous subsection.
Ensure that you have setup kalypso-sdk before proceeding further.
Load the enclave configuration
Before the enclave starts, it need to have configuration. The configuration must be loaded into enclave, once the enclave starts.
// existing setup
let supportedMarketData[supportedMarket] = { port: "6000", ivs_url: "http://not_available" };
const result = await kalypso
.Generator()
.GeneratorEnclaveConnector()
.generatorConfigSetup(
[{ address: generatorToListen, data: "Some data", supported_markets: Object.keys(supportedMarketData) }],
ws_url,
rpc_url,
gas_key,
generatorStartBlock,
chainId,
kalypso.MarketPlace().IvsEnclaveConnector().checkInputUrl(),
supportedMarketData
);
console.log(result);
- supportedMarketData: Contains list of all markets that the listener is listening to
- supportedMarket: ID of supported market
- port: Port to forward the decrypted proving request to
- ivs_url: URL against inputs are validated when there are not provable.
- generatorToListenTo: Listen specific genertor's tasks
- ws_url: Websocket URL to be used by listener
- rpc_url: RPC URL to be used by listener
- gas_key: Key to spend gas from
- chainId: Chain ID of the network
Loading the configuration merely doesn't start the prover enclave. Once loaded the prover services have to be started as mentioned in the next steps
Start kalypso-listener inside enclave
By default, the kalypso listener doesn't start automatically. It needs to explicitly started
// existing setup
const data1 = await kalypso.Generator().GeneratorEnclaveConnector().startListener();
console.log(JSON.stringify(data1, null, 4));
Start the prover program inside enclave
// existing setup
const data2 = await kalypso.Generator().GeneratorEnclaveConnector().startProgram(programName);
console.log(JSON.stringify(data2, null, 4));
- programName: The name of the prover service/executable that exists inside the enclave. refer this section where program name is mentioned in the supervisor.conf file
Stop kalypso-listener inside enclave
Stop kalypso listener inside the enclave
// existing setup
const data1 = await kalypso.Generator().GeneratorEnclaveConnector().stopListener();
console.log(JSON.stringify(data1, null, 4));
Stop the prover program inside enclave
// existing setup
const data2 = await kalypso.Generator().GeneratorEnclaveConnector().stopProgram(programName);
console.log(JSON.stringify(data2, null, 4));
- programName: The name of the prover service/executable that exists inside the enclave. refer this section where program name is mentioned in the supervisor.conf file
Restart kalypso-listener inside enclave
Restart kalypso listener inside the enclave
// existing setup
const data1 = await kalypso.Generator().GeneratorEnclaveConnector().restartListener();
console.log(JSON.stringify(data1, null, 4));
Restart the prover program inside enclave
// existing setup
const data2 = await kalypso.Generator().GeneratorEnclaveConnector().restartProgram(programName);
console.log(JSON.stringify(data2, null, 4));
- programName: The name of the prover service/executable that exists inside the enclave. refer this section where program name is mentioned in the supervisor.conf file
Update the ECIES encryption key
let attestation = await kalypso.Generator().GeneratorEnclaveConnector().getAttestation();
const public_key = PublicKey.fromHex(attestation.secp_key.toString());
console.log("compressed publickey", public_key.compressed.toString("hex"));
const enclaveSignature = await kalypso
.Generator()
.GeneratorEnclaveConnector()
.getAttestationSignature(attestation.attestation_document.toString(), await wallet.getAddress());
const tx = await kalypso.Generator().updateEcisKey(marketId, attestation.attestation_document, enclaveSignature);
const receipt = await tx.wait();
console.log("Added Generator ECIES key: ", receipt?.hash);
return "Done";
Steps
-
Retrieve Attestation:
- Use the
getAttestation
method fromGeneratorEnclaveConnector
to obtain the attestation.
- Use the
-
Extract Public Key:
- Extract the
secp_key
from the attestation and convert it to a compressed public key. - Log the compressed public key to the console.
- Extract the
-
Generate Attestation Signature:
- Use the
getAttestationSignature
method to generate a signature for the attestation document. - This involves passing the attestation document and the generator’s wallet address to the method.
- Use the
-
Update ECIES Key:
- Call the
updateEcisKey
method with the market ID, attestation document, and the attestation signature. - This updates the generator’s ECIES key in the marketplace.
- Call the