Merkle Tree Project
マークルツリープロジェクト
Hey there!
こんにちわ!
After going through this week’s content you may be wondering, "why am I learning about trees and data storage this week?".
今週のコンテンツを見て、「なぜ今週はツリーとデータストレージについて学ぶんだろう?」と疑問に思われたかもしれませんね。
The reason is that blockchains have a storage problem. They require that nodes in the network store every value recorded in their shared database. For ethereum this means all account balances, as well as every persistent variable on a smart contract. As we begin to work with smart contracts next week we need to be careful how much data we are storing on the blockchain. The less data we store, the cheaper it will be.
その理由は、ブロックチェーンにはストレージの問題があるからです。ブロックチェーンは、ネットワーク上のノードが、共有データベースに記録されたすべての値を保存することを要求します。イーサリアムの場合、これはすべての口座残高と、スマートコントラクト上のすべての永続的な変数を意味します。来週からスマートコントラクトを扱うので、ブロックチェーンに保存するデータの量に注意する必要があります。保存するデータが少なければ少ないほど、コストが安くなります。
Merkle Tree Gift List
マークルツリーギフトリスト
Your project this week is to build an application which gives out gifts, but only to names on the list. The catch is that on the server you are only allowed to store one 32 byte value in the server memory. This 32 byte value has to be enough for the server to be able to determine who is on the list.
今週のプロジェクトは、リストに載っている名前にだけプレゼントを贈るアプリケーションを作ることです。ただし、サーバーのメモリには32バイトの値を1つだけ保存することが許されています。この32バイトの値は、サーバーが誰がリストに載っているかを判断するのに十分でなければなりません。
Here is your starter repository: https://github.com/ChainShot/GiftList
ここにあなたのスターターリポジトリがあります:
To get started, read the readme for further instruction!
まずは readme を読んで、さらに詳しい説明を読んでください!
Hints
ヒント
Think of the client as the prover here. They are the ones trying to prove to the server that the one name is in the list. Likewise think of the server as the verifier here. They are taking the client's proof and, using minimal information, able to verify that the name sent from the client is actually in the list.
ここではライアントが証明者だと考えてください。クライアントはサーバーに対して、ある名前がリストに含まれていることを証明しようとするものです。同様に、サーバは検証者だと考えてください。サーバーはクライアントの証明を受け、最小限の情報を使って、クライアントから送られた名前が実際にリストにあるかどうかを検証することができるのです。
Check out the /utils folder for everything you need for the Merkle Tree. Take a look at the example.js file to see how to create a root, create a proof, and verify that proof.
Merkle Treeに必要なものは/utilsフォルダにあります。example.jsファイルを見て、ルートを作成し、証明を作成し、その証明を検証する方法を確認してください。
We modified the MerkleTree implementation so you won't have to! You can see we used a few helpers from the ethereum-cryptography library to convert between types.
今回は、Merkle Tree実装を変更して、Ethereum Cryptographyライブラリからいくつかのヘルパーを利用して、タイプ間の変換を行うことにより、あなたがしなくても済むようにしました。
Read meテキスト和訳
Gift List
To get started with the repository, clone it and then run npm install
in the top-level directory to install the depedencies.
このリポジトリを使い始めるには、リポジトリをクローンし、トップレベルのディレクトリで npm install
を実行して、depedencies をインストールします。
There are three folders in this repository:
このリポジトリには3つのフォルダがあります。
Client
You can run the client from the top-level directory with node client/index
. This file is a script which will send an HTTP request to the server.
トップレベルのディレクトリから、node client/index
でクライアントを実行することができます。このファイルはサーバーに HTTP リクエストを送信するスクリプトです。
Think of the client as the prover here. It needs to prove to the server that some name
is in the MERKLE_ROOT
on the server.
クライアントはここでは prover と考えてください。ある name
がサーバーの MERKLE_ROOT
にあることをサーバーに証明する必要があります。
Server
You can run the server from the top-level directory with node server/index
. This file is an express server which will be hosted on port 1225 and respond to the client's request.
トップレベルのディレクトリから node server/index
でサーバを実行することができます。このファイルは、ポート1225でホストされ、クライアントのリクエストに応答するエクスプレスサーバです。
Think of the server as the verifier here. It needs to verify that the name
passed by the client is in the MERKLE_ROOT
. If it is, then we can send the gift!
サーバはここでは verifier として考えてください。サーバーは、クライアントから渡された name
が MERKLE_ROOT
にあるかどうかを確認する必要があります。もしそうであれば、ギフトを送ることができます。
Utils
There are a few files in utils:
utilsにはいくつかのファイルがあります。
-
The
niceList.json
which contains all the names of the people who deserve a gift this year (this is randomly generated, feel free to add yourself and others to this list!) -
niceList.json`は、今年のギフトにふさわしい人々の名前をすべて含んでいます (これはランダムに生成されます。このリストに自分自身や他の人を自由に追加してください!)。
-
The
example.js
script shows how we can generate a root, generate a proof and verify that some value is in the root using the proof. Try it out from the top-level folder withnode/example.js
-
example.js
スクリプトは、ルートを生成し、証明を生成し、その証明を使ってルート内にある値を検証する方法を示しています。トップレベルのフォルダにあるnode/example.js
で試してみてください。 -
The
MerkleTree.js
should look familiar from the Merkle Tree module! This one has been modified so you should not have to deal with any crypto type conversion. You can import this in your client/server -
MerkleTree.js`はMerkle Treeのモジュールでおなじみですね。このモジュールは修正されているので、暗号の型変換をする必要はありません。クライアント/サーバーでこれをインポートすることができる。
-
The
verifyProof.js
should also look familiar. This was the last stage in the module. You can use this function to prove a name is in the merkle root, as show in the example. -
verifyProof.js`も見覚えがあるはずです。これはこのモジュールの最後のステージです。この関数は、例にあるように、ある名前がmerkleルートにあることを証明するために使用することができる。
<next chapter>
Congrats on finishing Week 2 🎉
2週目終了おめでとうございます🎉。
Celebration
Learning retrospective**
学習を振り返って
This week, we learned about Merkle Trees. You'll see this amazing data structure will come up time and time again, whether you're discussing blockchain architecture or building smart contracts.
今週は、Merkle Treesについて学びました。この素晴らしいデータ構造は、ブロックチェーンアーキテクチャの議論でも、スマートコントラクトの構築でも、何度も出てくることがわかると思います。
We also learned about Ethereum Data Storage. It's important to understand how Ethereum works behind the scenes to be an effective web3 developer. This will help you write better smart contracts, and also help you learn how to get data from the blockchain into a decentralized application.
また、Ethereum Data Storageについても学びました。効果的なWeb3開発者になるためには、Ethereumが舞台裏でどのように機能しているかを理解することが重要です。これは、より良いスマートコントラクトを書くのに役立ち、また、ブロックチェーンから分散型アプリケーションにデータを取得する方法を学ぶのに役立ちます。
Next Steps
次のステップ
We highly encourage you to share out what you've learned with the wider community 🌎
私たちは、あなたが学んだことをより広いコミュニティで共有することを強くお勧めします🌎。
Share a recap on Twitter!
Twitterで復習をシェアしよう
There's no better way to solidify your understanding than to teach it to others, jump into discord and help other students who may be stuck to solidify your mastery of these concepts. Students who help others will also be considered for our official Teaching Assistant program :)
Discordに飛び込んで、これらのコンセプトの習得に行き詰っている他の生徒を助けてください。他の人を助けた生徒は、私たちの公式ティーチング・アシスタント・プログラムの対象にもなります :)
Help other students
他の生徒を助ける
Next week we'll start working directly with Ethereum! We'll learn all about communicating with Ethereum Nodes and how to send transactions to the blockchain.
来週からはEthereumを直接扱います! イーサリアムノードとの通信やブロックチェーンへのトランザクションの送信方法など、すべてを学びます。
THIS WEEK SECTION IS OVER.WELL DONE!