Preimage Commitment
Last updated
Last updated
Preimage Commitment is a crucial cryptographic primitive in the construction of Runera. Cryptographic primitives are fundamental encryption algorithms that are well-established and frequently used to build secure computer systems.
The purpose of a Preimage Commitment is to conceal the execution trace of a circuit until the Prover reveals the execution trace preimage to the Verifier. The execution trace consists of all the input and output signal values generated during the circuit's execution process. In the context of hash functions, if hash(a) = b, 'a' is called the preimage and 'b' the hash value. When the Prover discloses the preimage corresponding to a Preimage Commitment, the Verifier checks it to confirm it adheres to the circuit's execution rules.
Consider a specific scenario involving gate C, which has one input (1) and one output (5), and its function is to perform a NOT operation on its input. Suppose that when the circuit execution reaches gate C, its input value is "value," as shown below:
The Prover sends the hash value of the input line (4) and the output line (5) value of gate B to the Verifier. The Verifier then uses these hash values to construct a script for on-chain verification, which we will discuss in detail later. The hash values of the input and output given here are referred to as the Preimage Commitment. The purpose of the Preimage Commitment is to prevent the Prover from altering the pre-committed execution path for malicious purposes. Once the Verifier has constructed this script, the Prover reveals the values of the input and output.
The Verifier uses a local program to verify whether the inputs and outputs disclosed by the Prover comply with the rules of gate B. If the Prover's output does not match the gate's rules, a transaction can be used to prove the Prover's malfeasance. The script corresponding to this transaction is as follows:
When the Prover behaves maliciously, such as providing an input of 1 and also providing an output of 1 (indicating dishonesty), the Verifier can spend the UTXO locked by the above script to prove that the Prover has acted maliciously. The specific construction of this script will be discussed later in the document.