Private Gateway
The Secret Network gateway is the connection between the relayer and the private computation contract. It implements the following interface:
Init Message:
pub struct InitMsg {
/// Entropy used for Prng seed.
pub entropy: String,
/// Optional admin address, env.message.sender if missing.
pub admin: Option<HumanAddr>,
/// scrt-rng Oracle code hash.
pub rng_hash: String,
/// scrt-rng Oracle contract address.
pub rng_addr: HumanAddr,
}
Handle Messages:
pub enum HandleMsg {
/// Triggers the scrt-rng contract to send back previously requested randomness.
KeyGen {
rng_hash: String,
rng_addr: HumanAddr,
},
/// Receives the callback message from scrt-rng. Actual key generation happens at this step.
ReceiveFRn {
cb_msg: Binary,
purpose: Option<String>,
rn: [u8; 32],
},
/// Process an interchain message through the private gateway.
Input {
inputs: PreExecutionMsg,
},
/// Receive results from private contract and broadcast logs for Relayer.
Output {
outputs: PostExecutionMsg,
},
}
Message Structs:
/// Message received from the relayer
pub struct PreExecutionMsg {
/// Task ID generated by the public gateway.
pub task_id: u64,
/// Source network (where to go once pulled into the next gateway).
pub source_network: String,
/// Destination contract address.
pub routing_info: HumanAddr,
/// Destination contract code hash.
pub routing_code_hash: String,
/// Encryption of (data, routing info, and user info).
pub payload: Binary,
/// Hash of encrypted input values.
pub payload_hash: Binary,
/// Signature of hash of encrypted input values.
pub payload_signature: Binary,
/// User public chain address.
pub user_address: HumanAddr,
/// User public key from payload encryption (not their wallet public key).
pub user_key: Binary,
/// User's wallet public key.
pub user_pubkey: Binary,
/// Handle to be called at destination contract.
pub handle: String,
/// Unique random bytes used to encrypt payload.
pub nonce: Binary,
}
/// Message sent to the destination private contract.
pub struct PrivContractHandleMsg {
/// JSON string of decrypted user inputs.
pub input_values: String,
/// Handle function to be called in the destination contract.
pub handle: String,
/// Public network user address.
pub user_address: HumanAddr,
/// Task ID passed along for later verification.
pub task_id: u64,
/// SHA256 hash of `input_values`.
pub input_hash: Binary,
/// Signature of `input_hash`, signed by the private gateway.
pub signature: Binary,
}
/// Message received from destination private contract with results.
pub struct PostExecutionMsg {
/// JSON string of results from the private contract.
pub result: String,
/// Task ID from private contract for verification.
pub task_id: u64,
/// SHA256 of decrypted (inputs + task ID) for verification.
pub input_hash: Binary,
}
Data Structs:
pub struct State {
/// Admin adress.
pub admin: CanonicalAddr,
/// Status of gateway key generation.
pub keyed: bool,
/// Count of tx.
pub tx_cnt: u64,
/// Private gateway encryption key pair.
pub encryption_keys: KeyPair,
/// Private gateway signing key pair.
pub signing_keys: KeyPair,
}
pub struct TaskInfo {
/// The original, encrypted payload.
pub payload: Binary,
/// The original payload_hash from the front-end.
pub payload_hash: Binary,
/// A unique hash for the task.
pub input_hash: [u8; 32],
/// The name of the network that message came from.
pub source_network: String,
/// Public address of the user that sent the message.
pub user_address: HumanAddr,
}
pub struct KeyPair {
/// Secret key part of the key pair.
pub sk: Binary,
/// Public key part of the key pair.
pub pk: Binary,
}
Last updated