Skip to content

ETH-TOKYO-WITH-KUHELL/zk-application-roadmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 

Repository files navigation

Roadmap

  • I want to make some improvements on this project
  1. upgrade login function
  2. group handling function
  3. try to make good UI
  4. upgrade NFT contract for group verification

Reference site

1. Upgrade login function

๐Ÿ’ก The new identity contains two random secret values trapdoor and nulifier , and one public value commitment
  • private value

    • trapdoor
    • nulifier
      • these two secret values are similar to Ethereum private keys and are used to generate Semaphore zero-knowledge proofs and authenticate signals
  • public value

    • Identity commitment
      • identity commitment is similarly to Ethereum addresses
  • generate identites

    import { Identity } from "@semaphore-protocol/identity"
    
    const { trapdoor, nullifier, commitment } = new Identity()

1.1 Upgrade process

1.1.1 AS-IS

// solidity contract
mapping(address => mapping(bytes32 => uint)) private users;

function getUserInfo(bytes32 _username) external view returns(uint){
    require(users[msg.sender][_username] != 0, "there is no user");
    return users[msg.sender][_username];
}
// next.js
const contract = new ethers.Contract(env.FEEDBACK_CONTRACT_ADDRESS, Feedback.abi, signer)
await contract.getUserInfo(formatBytes32String(_name))

1.1.2 Identifying the Problem

  • ์•Œ๊ธฐ ์ „์—๋Š” commitment ๊ฐ’์ด private key ๊ฐ’์ธ ์ค„ ์•Œ์•˜์ง€๋งŒ, ์ด๊ฒŒ public key ๊ฐ’์ด์—ˆ๋‹ค.
  • ๊ทธ๋ž˜์„œ ์ด ๊ฐ’์ด ๋…ธ์ถœ๋˜๋Š”๊ฒŒ ๋ฌธ์ œ๊ฐ€ ๋˜๋Š” ์ค„ ์•Œ์•˜์ง€๋งŒ ์•„๋‹ˆ์—ˆ๋‹ค.
  • ๊ทธ๋Ÿฌ๋ฉด public ๊ฐ’์„ ํ†ตํ•ด ๋ณธ์ธ์ž„์„ ์ฆ๋ช…ํ•˜๊ฒŒ ๋˜๋ฉด login ํ•˜๊ณ  ๋ฐ”๋กœ proof๋ฅผ ๊ฐ”๋Š”๋ฐ, ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ ์ฐฝ์œผ๋กœ ์ด๋™ํ•ด์„œ ๋น„๋ฐ€๋ฒˆํ˜ธ ๊ฐ’์„ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋ฐ›์•„์„œ new Idenenty('parameter') ๋ฅผ ํ†ตํ•ด ๋‚˜์˜จ ๊ฐ’์„ setStorageํ•ด์ฃผ๋ฉด ๋ฌธ์ œ๊ฐ€ ํ•ด๊ฒฐ๋  ๊ฒƒ ๊ฐ™๋‹ค

1.1.3 TO-BE

const identity = new Identity("secret-message")
console.log(identity.toString())
// '["8255d...", "62c41..."]'
  • '["8255d...", "62c41..."]' ์ด ๊ฐ’์ด new Identity("secret-message") ๊ฐ’์ด ๊ฐ™์€ ๊ฒฝ์šฐ์—” ๋˜‘๊ฐ™๋‹ค
  • ๊ทธ๋Ÿฌ๋ฉด ์ด ๊ฐ’์„ setStorageํ•ด์„œ ์‚ฌ์šฉํ•˜๋ฉด nulifier, trapdoor ๊ฐ’์„ proof ํ•  ๋•Œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค

1.1.4 Something to prove

  • new Identity("secret-message") ์—์„œ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋ฐ›์€ ๊ฐ’์ด ๊ฐ™์€ ๊ฒฝ์šฐ ์ฒ˜์Œ์— ์ƒ์„ฑ๋  ๋•Œ๋ž‘ ๋‹ค์‹œ ์ƒ์„ฑํ•  ๋•Œ์™€ ๊ฐ™์€ ์ง€ ์ฆ๋ช… ๋˜์–ด์•ผํ•œ๋‹ค
  • ๊ฐ™๋‹ค๋ฉด mapping ์— ์ €์žฅํ•œ public value๊ฐ€ joinGroup transaction์„ ์„œ๋ช…ํ•  ๋•Œ mapping์— ์ €์žฅ๋˜์—ˆ๊ณ , ๊ทธ๋ฃน NFT๋ฅผ ๋ณด์œ ํ•จ์ด ์ฆ๋ช…๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ณด์•ˆ์ด ์ ์šฉ๋œ๋‹ค
  • ๋งŒ์•ฝ mapping์— ์ €์žฅ๋œ commitment ๊ฐ’์ด ๋…ธ์ถœ๋˜๋”๋ผ๋„, ์ฒ˜์Œ joinGroupํ•  ๋•Œ ์ž…๋ ฅํ•œ new Identity("secret-message") ๊ฐ’์€ ์œ ์ € ๋ณธ์ธ๋งŒ ์•Œ๊ธฐ ๋•Œ๋ฌธ์— ์ƒ๊ด€์ด ์—†๋‹ค
  • ๊ทธ ๊ฐ’๊นŒ์ง€ ์•Œ์•„์•ผํ•˜๊ณ , ์„œ๋ช…ํ–ˆ๋˜ ์ง€๊ฐ‘์˜ private key๊นŒ์ง€ ํƒˆ์ทจํ•ด์•ผ ์ง€๊ฐ‘์— ์—ฐ๊ฒฐํ•ด์„œ ์„œ๋ช…์„ ํ†ตํ•ด ์ธ์ฆ๋˜์–ด์•ผ password ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•œ๋‹ค

Releases

No releases published

Packages

No packages published