The project consists of two services:
dot-login
client (this repo): here the ZKP is createddot-login-substrate-node
: here the ZKP is stored on-chain
Currently, Linux-based operating systems are supported (e.g. Ubuntu).
- install essential tooling:
sudo apt install build-essential
- install pkg-config:
apt install pkg-config
- install libssl-dev:
sudo apt install libssl-dev
- install cargo:
curl https://sh.rustup.rs -sSf | sh
- use nightly toolchain:
rustup override set nightly
- verify toolchain:
rustup toolchain list
# expected output stable-x86_64-unknown-linux-gnu (default) nightly-x86_64-unknown-linux-gnu (override) # <-- verify that override is set to nightly toolchain
docker build -t dot-login-client .
docker image ls
expected output:
# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
dot-login-client latest ec2046278f3f 5 hours ago 8.07GB
-
Run the container in interactive mode (
/bin/bash
) in order to follow the tutorial:docker run -it --rm rust-dot-login /bin/bash
-
Inside the container, you can run the application and follow the manual steps to complete the login process and generate the ZKP.
cd ./target/release ./dot_login
-
Copy the login URL into a browser, log in with your gmail account, and get redirected to http://localhost/#id_token={JWT} where {JWT} represents your JWT. Copy the URL into an editor and extract the JWT, this will be neede for the next step.
-
Create JWT Config File: Create a JWT config file and paste the JWT value.
touch current.jwt vi current.jwt
-
Run the Client Again: Execute the client again with the JWT.
./dot_login
-
Submit ZKP to Substrate Node: Copy the generated JSON and pass it to the substrate node by calling the extrinsic.
$ cargo build --release
-
Execute the client:
$ cd ./target/release $ ./dot_login # output Token/Key Pairs empty, Log first Google OAuth login: https://accounts.google.com/o/oauth2/auth?client_id=801054035848-vn7773nujkjq17c2lcmc3en3doonfu8u.apps.googleusercontent.com&response_type=id_token&redirect_uri=http%3A%2F%2Flocalhost&scope=openid+email&nonce=8cb107f3
-
Copy the login URL into a browser
-
Log in with your gmail account. You should be redirected to
http://localhost/#id_token={JWT}
where{JWT}
will represent your jwt. -
Create the jwt config file:
touch current.jwt
-
Open the file with an editor (e.g.
vi current.jwt
) and paste the jwt value into it (see step 3) -
Execute the client again:
./dot_login
# output Decoding XXXX.YYYY.ZZZZ&authuser=0&prompt=consent&version_info=VVVV Result Google JWT: iss: accounts.google.com azp: 801054035848-vn7773nujkjq17c2lcmc3en3doonfu8u.apps.googleusercontent.com aud: 801054035848-vn7773nujkjq17c2lcmc3en3doonfu8u.apps.googleusercontent.com sub: 110642249998642651331 nonce: 8cb107f3 nbf: 1716133413 iat: 1716133713 exp: 1716137313 jti: aada3718ebc02e095535a71090df2743c91ed499 email: [email protected] Generate salt for: "[email protected]" based on iss, aud, sub -> "abc" Starting generate the ZkProof... 1) Generating extended ephemeral public key -> "123..." 2) Generating ZkProof -> { "a": { "x": "0cb...", "y": "0d9..." }, "b": { "x": { "c0": "173...", "c1": "173..." }, "y": { "c0": "0a6...", "c1": "100..." } }, "c": { "x": "020...", "y": "02f..." } }
-
Copy the JSON from step 3 and pass it to the substrate node by calling the
zkProofModule.storeZkProof
extrinsic.
-
Get the node up & running
# 1) clone node repo git clone [email protected]:singkeo/dot-login-substrate-node.git # 2) build node cargo build --release # 3) start node (note: add --unsafe-rpc-external if you're planning to access it the node from a remote machine) ./target/release/node-template --dev
-
you can now submit the zk proof that you've generated in the client to the blockchain (see previous step)