YOUR NAME: 李亦宸 YOUR ID: B12401103 ## question 1 answer In Circom, the `<==` operator serves dual roles in both signal assignment and constraint generation. It assigns a value to the signals on the left-hand side, while simultaneously creating a constraint that verifies the assigned value. The operators `===` and `<--` have similar functions to `<==`, representing constraint generation and signal assignment respectively. However, there are important differences between them. The `<==` operator is generally preferred because it performs both signal assignment and constraint generation, ensuring the correctness of the computation. In the provided code, `c <== a * b;` assigns the value of `a * b` to the signal c and also creates a constraint that verifies this assignment. Similarly, `hash.inputs[0] <== a;` and `hash.inputs[1] <== b;` assign the values of a and b to the inputs of the hash component, while also creating constraints to verify these assignments. It’s important to note that while `<==` is used for signal assignment, it also ensures that the assigned values are verified through constraints. This is a key aspect of Circom’s design, which helps maintain the integrity of the computations within the circuit. ## question 2 answer main.plonk.sol uses its verifyProof function to calculate and varify the given proof. ## question 3 answer A `zkey` is a key file used in the Growth16 zk-SNARK (Zero-Knowledge Succinct Non-Interactive Argument of Knowledge), as it contains the proving and verification keys for a specific arithmetic circuit. These keys are generated during the setup phase of the Groth16 protocol and are necessary for creating and verifying proofs. On the other hand, a `circuit` refers to a representation of a computation. It’s a straight-line computation (no looping or flow-control constructs) consisting of just operations on bits, like AND, OR, NOT. In the context of zk-SNARKs and the Groth16 protocol, a `circuit` would represent the computation that the prover wants to prove they know the result of, without revealing any additional information. ## question 4 answer ``` pragma circom 2.1.6; include "circomlib/poseidon.circom"; // include "https://github.com/0xPARC/circom-secp256k1/blob/master/circuits/bigint.circom"; template MerkleTree () { signal input a, b, c, d; signal output e; signal input f; component hash = Poseidon(2); component hash2 = Poseidon(2); component hash3 = Poseidon(2); hash.inputs[0] <== a; hash.inputs[1] <== b; hash2.inputs[0] <== c; hash2.inputs[1] <== d; hash3.inputs[0] <== hash.out; hash3.inputs[1] <== hash2.out; e <== hash3.out; e === f; log(e); } component main = MerkleTree(); /* INPUT = { "a": "5", "b": "77", "c": "35", "d": "24", "f": "17499677547561660273017699567908067415377678347145626859540034597523441084050" } */ ``` ## question 5 answer [0,0]