privacy-scaling-explorations / core-program

155 stars 45 forks source link

[WIP] Module/Week 1 #29

Closed adrianmcli closed 5 months ago

adrianmcli commented 5 months ago

1️⃣ Week 1 - Cryptographic Basics

Practical

Study

adrianmcli commented 5 months ago

@NOOMA-42 has stated he will fill in the Practical (Circom) section of this Module. I will review and make my edits afterwards.

adrianmcli commented 5 months ago

The answer for writing a circuit to check output of hash:

pragma circom 2.1.6;

include "circomlib/poseidon.circom";

template HashProof() {
    signal input preimage;
    signal input hash;
    signal output hashOutput;

    component hasher = Poseidon(1);
    hasher.inputs[0] <== preimage;

    hashOutput <== hasher.out;

    // Enforce that the hash matches the given hash
    hash === hashOutput;
}

component main = HashProof();

/* INPUT = {
    "preimage": "12345",
    "hash": "4267533774488295900887461483015112262021273608761099826938271132511348470966"
} */

Instead of showing the above, we should break it down so that we force the student to come up with the above. We can give it to them in parts. Please see the latest commit for an example.

NOOMA-42 commented 5 months ago
  1. I removed set membership section because a very simple set membership is Merkle tree inclusion. We just go over in the previous section.
  2. I change private key to public key to elliptic curve addition. The code is easier to understand and also involved with cryptography
adrianmcli commented 5 months ago

@NOOMA-42 do you think it is sufficiently simple and black-boxed?

I will just merge it now, we can always improve this later.