Skip to main content

Step 3: Interact verifiably using a program

Step 3.1: Interact with llama2 on Oyster

You can interact with the llama2 enclave using HTTP and specifying a prompt. Here is an example using curl:

curl http://<ip>:5000/api/generate -d '{"model":"llama2","prompt":"What is Ethereum?"}'

The response should look something like

{"model":"llama2","created_at":"...","response":"Ethereum is an open-source blockchain platform that enables the creation of decentralized applications (dApps) and smart contracts. It was launched in 2015 by Vitalik Buterin, a Canadian-Russian programmer, and has since become one of the most popular and widely-used blockchain platforms in the world.\n\nEthereum's primary use case is as a platform for building decentralized applications (dApps) that can be programmed to perform a variety of tasks, such as:\n\n1. Decentralized finance (DeFi): Ethereum has enabled the creation of decentralized exchanges, lending platforms, and other financial services that are not controlled by any single entity.\n2. Non-fungible tokens (NFTs): Ethereum allows for the creation of unique digital assets, such as art, collectibles, and other unique items, which can be bought, sold, and traded on decentralized marketplaces.\n3. Decentralized data storage: Ethereum's blockchain can be used to store data in a decentralized manner, providing a secure and transparent way to store and access data.\n4. Decentralized identity verification: Ethereum's blockchain can be used to create digital identities that are secure and decentralized, allowing individuals to control their own personal information.\n5. Decentralized gaming: Ethereum's blockchain can be used to create decentralized gaming platforms that are fair, transparent, and secure.\n\nEthereum's smart contract functionality allows developers to build decentralized applications (dApps) that can execute automated tasks without the need for intermediaries. This enables a wide range of use cases, such as:\n\n1. Decentralized autonomous organizations (DAOs): Ethereum allows for the creation of decentralized organizations that are run by their members through smart contracts.\n2. Decentralized supply chain management: Ethereum's blockchain can be used to track and verify the movement of goods throughout a supply chain, providing transparency and security.\n3. Decentralized voting systems: Ethereum's blockchain can be used to create decentralized voting systems that are secure, transparent, and tamper-proof.\n4. Decentralized prediction markets: Ethereum's blockchain can be used to create decentralized prediction markets that allow individuals to bet on the outcome of events in a secure and transparent manner.\n\nOverall, Ethereum provides a powerful platform for building decentralized applications and smart contracts, enabling a wide range of use cases that are not possible with traditional centralized systems.","done":true,"context":[518,25580,29962,3532,14816,29903,29958,5299,829,14816,29903,6778,13,13,5618,338,382,12711,398,29973,518,29914,25580,29962,13,29923,12711,398,338,385,1722,29899,4993,2908,14153,7481,393,28936,278,11265,310,27189,1705,1891,8324,313,29881,2052,29879,29897,322,15040,8078,29879,29889,739,471,15241,297,29871,29906,29900,29896,29945,491,478,2410,638,1205,261,262,29892,263,11443,29899,23002,713,27922,29892,322,756,1951,4953,697,310,278,1556,5972,322,17644,29899,3880,2908,14153,21796,297,278,3186,29889,13,13,29923,12711,398,29915,29879,7601,671,1206,338,408,263,7481,363,5214,27189,1705,1891,8324,313,29881,2052,29879,29897,393,508,367,1824,2168,304,2189,263,12875,310,9595,29892,1316,408,29901,13,13,29896,29889,3826,296,1705,1891,1436,749,313,2772,18800,1125,382,12711,398,756,9615,278,11265,310,27189,1705,1891,429,25990,29892,301,2548,21796,29892,322,916,18161,5786,393,526,451,20704,491,738,2323,7855,29889,13,29906,29889,10050,29899,29888,686,1821,18897,313,29940,7818,29879,1125,382,12711,398,6511,363,278,11265,310,5412,13436,21608,29892,1316,408,1616,29892,6314,13876,29892,322,916,5412,4452,29892,607,508,367,18093,29892,5239,29892,322,3534,287,373,27189,1705,1891,9999,29886,6048,29889,13,29941,29889,3826,296,1705,1891,848,8635,29901,382,12711,398,29915,29879,2908,14153,508,367,1304,304,3787,848,297,263,27189,1705,1891,8214,29892,13138,263,11592,322,17772,982,304,3787,322,2130,848,29889,13,29946,29889,3826,296,1705,1891,10110,1147,2450,29901,382,12711,398,29915,29879,2908,14153,508,367,1304,304,1653,13436,2893,1907,393,526,11592,322,27189,1705,1891,29892,14372,15724,304,2761,1009,1914,7333,2472,29889,13,29945,29889,3826,296,1705,1891,330,11500,29901,382,12711,398,29915,29879,2908,14153,508,367,1304,304,1653,27189,1705,1891,330,11500,21796,393,526,6534,29892,17772,29892,322,11592,29889,13,13,29923,12711,398,29915,29879,15040,8078,9863,6511,18777,304,2048,27189,1705,1891,8324,313,29881,2052,29879,29897,393,508,6222,3345,630,9595,1728,278,817,363,1006,4210,4314,29889,910,28936,263,9377,3464,310,671,4251,29892,1316,408,29901,13,13,29896,29889,3826,296,1705,1891,28273,681,25700,313,7698,24768,1125,382,12711,398,6511,363,278,11265,310,27189,1705,1891,25700,393,526,1065,491,1009,5144,1549,15040,8078,29879,29889,13,29906,29889,3826,296,1705,1891,11421,9704,10643,29901,382,12711,398,29915,29879,2908,14153,508,367,1304,304,5702,322,11539,278,10298,310,22535,10106,263,11421,9704,29892,13138,1301,862,3819,322,6993,29889,13,29941,29889,3826,296,1705,1891,28931,6757,29901,382,12711,398,29915,29879,2908,14153,508,367,1304,304,1653,27189,1705,1891,28931,6757,393,526,11592,29892,17772,29892,322,21308,546,29899,8017,29889,13,29946,29889,3826,296,1705,1891,18988,2791,1691,29901,382,12711,398,29915,29879,2908,14153,508,367,1304,304,1653,27189,1705,1891,18988,2791,1691,393,2758,15724,304,1010,373,278,21957,310,4959,297,263,11592,322,17772,8214,29889,13,13,3563,497,29892,382,12711,398,8128,263,13988,7481,363,5214,27189,1705,1891,8324,322,15040,8078,29879,29892,427,17961,263,9377,3464,310,671,4251,393,526,451,1950,411,13807,6555,1891,6757,29889],"total_duration":137408298224,"load_duration":1133514053,"prompt_eval_count":26,"prompt_eval_duration":5896927000,"eval_count":592,"eval_duration":130377445000}
tip

Since we sign the response to aid verifiability, the response is first fully collected unlike the usual streaming interface you might find in e.g. ChatGPT. Hence, you can expect it to take ~2 minutes for the full response.

Step 3.2: Verify the response

Running the curl command above with -v option shows us two important headers:

x-oyster-timestamp: 1709037534
x-oyster-signature: b9240b9bf78a955b354323ffa111ab75e479a54bca107463fdba1079055fc13f050a5e4bbecb0c934d82df48f8550cb6e2debfc2b77a9118134302cbd7b18acf1c

A verification contract is deployed at 0x5fb2559a81beff3864c907a49da8a2fd657693fc on the Polygon chain with the following verifier function:

interface IVerifier {
function verifyResult(
uint64 timestamp,
string memory modelName,
string memory prompt,
string memory request_context,
string memory response,
string memory response_context,
bytes memory sig
) external view;
}

The timestamp and signature are available in the response headers. The rest of the fields are part of the request and response. In case there was no context passed in the request, it can be set to an empty array string ("[]").