StarkEx for perpetual trading uses external price feeds, which are given to the system in the oracle price tick transaction. StarkEx for Perpetual supports combining many prices from many Oracles/providers into one single quorum. This page describes the technical steps that you are required to perform in order to be able to be an Oracle provider for StarkEx for Perpetual.
As detailed in the crypto section, STARK proofs use different hash functions and signatures from Ethereum, and therefore in order to sign on prices for the system you will need to create your private
starkKey. A recommended and easy yet secure method to create your
starkKeywith your Ethereum key is demonstrated here:
Create an Ethereum signature on the constant string "StarkKeyDerivation" (or
Hash (using keccak) r and s signature components to one 256-bit word
Remove the last 5 bits of the resulted number to get the 251-bit stark private key
Derive the stark public key from the stark private key with the relevant CLI function
Using Ganache's default Eth account:eth_key = 0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1deth_address = 0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1eth_signature =fd85e77f5bb436eb90a4c3324a02fea6ef766e6ac85bffccb6e1cdc03479e9ac058e6fb13916131dd4df1911098e2df71d582ab86281bf2553e55571aa99064b1ceth_signature_hash = keccak256(r, s) =0x2f008fa70d291380abafd4a98029ff706940d392b2a30d57c09d49a2447407f2stark_private_key = last251Bits(ethSignatureHash) =178047D3869489C055D7EA54C014FFB834A069C9595186ABE04EA4D1223A03Fstark_key = public_cli(starkPrivateKey) =0x1895a6a77ae14e7987b9cb51329a5adfb17bd8e7c638f92d6892d76e51cebcf
assetId, the on-chain contract saves as part of its
syntheticConfiguration a list of trusted public keys that are allowed to sign this asset. The oracle's public key must be included in the configuration. Otherwise, the STARK proof will not be able to use its signature.
Call the hash function in the CLI with the following fields:
timestamp - 32 bit number (seconds since epoch)
price - 120 bit number, with 18 decimal digits after the decimal point
asset_name (of your choice, per asset. for example "BTCUSD") - 128 bit number
oracle_name (your identity. e.g. "Chain") - 40 bit number
Parameters 3 and 4 should be consistent among all the providers of every Oracle entity (i.e. Chainlink, Maker, etc.) that sign on a specific asset.
The CLI function combines and hashes the parameters as shown here:
timestamp = January 1st, 2020 = hex(1577836800) = 0x5e0be100price = $11512.34 = hex(11512.34 * (10**18)) = 0x27015cfcb0230820000asset_name = 128bits(hex("BTCUSD")) = 0x42544355534400000000000000000000oracle_name = hex("Maker") = 0x4d616b6572first_number = 0(84-bit) || AssetName (128-bit) || oracleName (40-bit) =425443555344000000000000000000004d616b6572second_number = 0(100-bit) || Price(120-bit) || Timestamp (32-bit) =27015cfcb02308200005e0be100data_hash = pedersen(first_number, second_number) =3e4113feb6c403cb0c954e5c09d239bf88fedb075220270f44173ac3cd41858
signature = StarkSign(key=stark_private_key, data=data_hash) =r: 0x6a7a118a6fa508c4f0eb77ea0efbc8d48a64d4a570d93f5c61cd886877cb920s: 0x6de9006a7bbf610d583d514951c98d15b1a0f6c78846986491d2c8ca049fd55