You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
productChain is a blockchain designed to keep track of valid/verified products. Each transaction in a block is a `product Name` - `Manufacturer ID Pair`.
4
+
5
+
By default, the blockchain has 3 transactions in each block and a set difficulty of 4
6
+
These parameters can be changed in the `src/blockchain.ts` file. Run `tsc` in the `src` directory after any changes.
7
+
8
+
The blockchain uses a Discrete Log ZKP to verify products. This is done as follows,
9
+
10
+
`p` is a large prime and `g` is its generator
11
+
12
+
A product (with ID `x`) is sent to an trusted body for verification. After verifying the product, `y = g^x mod(p)` is calculated and published.
13
+
14
+
When an external verifier wants to verify if a product is legitimate, they should be able to do so without actually knowing the product's unique ID.
15
+
16
+
To accomplish this, we use the following Zero Knowledge Proof,
17
+
18
+
- A random number between `0` and `p - 1` is chosen and `h = g^x mod (p)` is calculated
19
+
-`h` is sent to the verifier. The verifier then send a random bit `b` (0/1)
20
+
-`s = (r + bx) mod(p - 1)` is calculated and sent to the verifier
21
+
- The verifier checks if , `g^s mod (p)` equals `hy^b mod(p)`
22
+
- This is done for multiple rounds (50 by default in our case). If the equality check fails once, then the productID is not valid
23
+
24
+
Thus, we are able to verify a productID without actually sending the productID to the verifier
25
+
26
+
Note : In this repo, a list of randomly generated UUIDs is present in `validproductIDs.txt` . For testing, only these productIDs will pass the ZKP. This is not a security hazard as the file is not used anywhere in the project.
27
+
28
+
29
+
# Running the test network
30
+
31
+
Run `npm install` , after cloning the repo.
32
+
33
+
Run `npm run start`, to start the peerList.
34
+
35
+
`cd` into the `src` folder to run the nodes.
36
+
37
+
Each terminal instance can be used to run a node in a randomly selected port,
38
+
39
+
Run `node miner.js` in multiple terminals.
40
+
41
+
Run `node api.js` in another terminal. The API runs at port `3000` by default.
42
+
43
+
To view the blockchain: Make a `GET` request to `http://localhost:3000/getChain` to get a copy of the blockchain.
44
+
45
+
To open the frontend, `cd` into `frontend` and run `npm install` , the frontend will open on some open port by default.
46
+
47
+
Connect each node with its peers [Option `1` in the CLI] before interacting with the blockchain.
0 commit comments