‘이더리움 댑 개발’ 세미나 보조 교재 – Learn Ethereum 3

이번 함께 읽기에서는 Section 3: Ethereum Implementations을 정리합니다.

  • Chapter 6, Smart Contract Development and Test Fundamentals
  • Chapter 7, Writing a UI for our DApps
  • Chapter 8, Ethereum Tools and Frameworks

대부분 이미 세미나에서 다룬 내용들입니다. 빠르게 본문을 읽어나가고, 아래 요약한 내용들과 정리한 내용들만 다시 한 번 주의 깊게 읽어봅니다.

  • 자바스크립트 테스트에서 이더 값을 비교할 때 Big Number(BN 함수) 사용
  • 컨트랙트 security analysis tool
  • The Ethereum client API
    •  web3.js
    •  ethers.js
      • Similar to JavaScript Web3
    •  EthereumJS
      • Provide collections of utility functions

 

예제로 사용되는 digital art market 댑은 ERC721 댑을 개발해야 한다면 유용한 참고자료가 될 수 있음을 기억해 둡니다.

Working with Swarm

스웜은 bzz 프로토콜을 사용합니다.

스웜을 시작하려면 Geth와 Swarm을 설치해야 합니다.

  • 스웜 설치
    • 가장 간단한 방법은 built-in launchpad PPAs (Personal Package Archives)를 사용하는 것입니다.
  • Geth 설치

 

Running an example of Swarm

  • 스웜을 시작하려면 계정이 필요합니다.
    • geth account new
  • swarm -bzzaccount {계정}
    • 어느 정도 시간이 지나도 peer에 연결되지 않는 경우에는 최신 버전을 다운로드 해서 사용합니다.
      • https://swarm.ethereum.org/downloads/
        • 압축을 풀고 /usr/bin으로 복사합니다.
          • sudo cp -rp ./swarm /usr/bin/
  • 스웜은 geth 콘솔과 완전히 통합됩니다. 스웜에서 geth 콘솔을 사용하려면 새로운 터미널을 열고 다음과 같이 geth attach 명령을 실행합니다.
    • geth attach $HOME/.ethereum/bzzd.ipc
    • console.log(bzz.hive)로 피어 연결 상태를 볼 수 있습니다.
  • hello.txt 파일을 업로드 합니다.
    • 새 터미널을 열고 hello.txt 파일을 생성하고, swarm up 명령을 실행해서 업로드 합니다. 업로드 파일에 대한 해시 값을 리턴합니다.
      • swarm up hello.txt
    • 업로드된 파일은 로컬 HTTP 게이트웨이 8500 포트를 통해 액세스할 수 있습니다.
      • http://localhost:8500/bzz:/<file_hash>
    • HTTPS Swarm public gateway를 사용해서 액세스할 수도 있습니다.
      • https:/​/​swarm-gateways.​net/​bzz:/​<file_​hash>

Ethereum messages – Whisper

아래 인용한 본문 내용을 주의 깊게 다시 읽고 해당 내용을 기억하도록 합니다.

  • Whisper is an Ethereum P2P communication protocol that allows messaging between DApps. It provides a simple API that we can use to send an encrypted message through the Ethereum blockchain and receive and decrypted messages with the hash key. It can be used for DApps publish-subscribe coordination signaling and building secure, untraceable decentralized communication.
  • Whisper is currently at the POC 2 stage and supports the Geth and Parity clients. Whisper currently uses the ssh protocol string of devp2p. When sending an encrypted message, the message content can be encrypted by default either asymmetrically or symmetrically.
  • Whisper envelopes contain the encrypted payload and some metadata in plain format. It is sent and received by Whisper nodes.
  • Whisper envelope contains important information for the message:
    • Version
      • This can be up to 4 bytes (currently one byte containing zero) and indicates the encryption method. If the Version is higher than the current one, the envelope cannot be decrypted, and therefore can only be forwarded to the peers.
    • Expiry
      • This is the message expiry time (Unix time in seconds).
    • TTL
      • This defines the message’s time-to-live in seconds.
    • Topic
      • This is 4 bytes of arbitrary data.
    • AESNonce
      • This is used in symmetric encryption and represents 12 bytes of random data.
    • Data
      • This is encrypted byte array data.
    • EnvNonce
      • This is 8 bytes of arbitrary integer data that’s used for Proof-of-Work (PoW) calculations.

Envelope’s payload has encrypted byte array data; it is the Whisper message in plain format.

  • Here is the message’s structure:
    • [ flags, optional padding, payload, optional signature]
      • Flags
        • There’s a single byte for the flag to specify the message has a signature.
      • Padding
        • This is used to align the message size, and it can contain random data.
      • Signature
        • This is the signature that’s used for sending the message. It is the ECDSA signature of the Keccak-256 hash of the unencrypted data.
      • Payload
        • This is the payload of the message.
About the Author
(주)뉴테크프라임 대표 김현남입니다. 저에 대해 좀 더 알기를 원하시는 분은 아래 링크를 참조하세요. http://www.umlcert.com/kimhn/

Leave a Reply

*