https://www.docker.com/get-started
Start the newly installed Docker application.
Open the Terminal (Terminal
) app and run:
docker run -it debian
It is recommended that you install the Terminal app for Windows available at:
https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701
Open the Terminal (Terminal
) app and run:
docker run -it debian
Or to reuse your a previously started container run:
docker attach $(docker start $(docker ps -l -q))
You will evenutually see a line similar to this:
root@5555b7f58ebe:/#
This is the command prompt of the Debian operating system that is now running within a container on your computer.
Type the following command to show the Debian version:
cat /etc/os-release
It should output Debian GNU/Linux 12 (bookworm)
amongt other information.
wget
is a utility which can download files from the internet. To install wget
run:
apt-get update && apt-get install -y wget
geth
is the most popular Ethereum client. It is written in the Go programming language.
To download geth
,
if you have processor with an x64 architecture (e.g., AMD, Intel), run:
cd && wget -O geth.tar.gz https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.13.4-3f907d6a.tar.gz
if you have processor with an ARM architecture (e.g., Apple M1), run:
cd && wget -O geth.tar.gz https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-arm64-1.13.4-3f907d6a.tar.gz
To unpack and install then downloaded program files run:
cd && tar -xvf geth.tar.gz --exclude=COPYING --strip-components=1 && rm geth.tar.gz && chmod u+x * && mv * /usr/bin
Type the following command to show the location of the geth
program:
which geth
It should output /usr/bin/geth
.
You are now ready to participate in the Ethereum network. To start you local node run:
geth
If you follow the output, you will notice that your node will do the following:
- Find peers
- Once found, it will start downloading a local copy of the blockchain
If it fails to find any peers, it might be because your operating system firewall or the network is blocking the connections.
Try following:
- Connect to a less restrictive network, like your mobile phone hotspot
⚠️ Temporarily disable the firewall in the operating system settings (do not forget to enable the firewall after lab session)
If you want to stop your node press CTRL+C
.
To interact with the blockchain using your Ethereum node's CLI (command line interface a.k.a. console) run:
geth --syncmode light --verbosity 1 console
You can find the reference for the console commands in the Web3 documentation.
To view the peer nodes that you are currently connected to:
admin.peers
You will notice that each peer has a remote IP address (here the IP address is 94.176.237.140
):
remoteAddress: "94.176.237.140:30303"
You can query the peer's IP address using a Geolocation tool to find out where they are.
Take a look at block number 3
:
eth.getBlock(3)
Take a look at the latest block number:
eth.blockNumber
Take a look at the latest block:
eth.getBlock(eth.blockNumber)
Block number 14000
has an interesting message in it's extra data:
web3.toAscii(eth.getBlock(14000).extraData)
Now take look at the extra data in the latest block:
web3.toAscii(eth.getBlock(eth.blockNumber).extraData)
Take a look at block 1000000
:
eth.getBlock(1000000)
Block 1000000
has two transactions. Take a look at the first transaction in that block:
eth.getTransaction("0xea1093d492a1dcb1bef708f771a99a96ff05dcab81ca76c31940300177fcf49f")
Take a look at how much Ether the account that mined the last block has:
web3.fromWei(eth.getBalance(eth.getBlock(eth.blockNumber).miner), "Ether")
Create a new account:
personal.newAccount()
Exit the console:
exit
On Mac:
https://download.docker.com/mac/stable/Docker.dmg
On Windows:
https://download.docker.com/win/stable/Docker%20Desktop%20Installer.exe
Open the Terminal (Terminal
) app and run:
docker run -it debian
It is recommended that you install the Terminal app for Windows available at:
https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701
Open the Terminal (Terminal
) app and run:
docker run -it debian
Install the cryptographic library OpenSSL:
apt-get update && apt-get install -y openssl
Encrypt and decrypt a plaintext message with symetric key cryptography.
Create a file with a message:
echo Attack at 5:00 > message.txt
Read the file with a message:
cat message.txt
Encrypt the message:
openssl enc -AES-256-CBC -base64 -pbkdf2 -in message.txt -out encrypted.txt -p -pass pass:password
Show the encrypted ciphertext:
cat encrypted.txt
Decrypt the ciphertext:
openssl enc -AES-256-CBC -base64 -pbkdf2 -in encrypted.txt -out decrypted.txt -p -pass pass:password -d
Show the decrypted message:
cat decrypted.txt
Encrypt and decrypt a plaintext message using the RSA (Rivest–Shamir–Adleman) public / private key cryptography.
Create a file with a message:
echo Retreat at 6:00 > message.txt
Read the file with a message:
cat message.txt
Create a private key:
openssl genpkey -algorithm RSA -out private.txt
View the created private key:
cat private.txt
Derive a public key:
openssl rsa -pubout -in private.txt -out public.txt
View the created public key:
cat public.txt
Encrypt the message using the public key:
openssl pkeyutl -encrypt -pubin -inkey public.txt -in message.txt -out encrypted.bin
Show the encrypted ciphertext:
base64 encrypted.bin
Decrypt the ciphertext using the private key:
openssl pkeyutl -decrypt -inkey private.txt -in encrypted.bin -out decrypted.txt
Show the decrypted message:
cat decrypted.txt
Sign and verify a plaintext message using EC (Elliptic-curve) public / private key cryptography.
Create a file with a message:
echo Send 1 million USD to John Smith > message.txt
Read the file with a message:
cat message.txt
Create a private key:
openssl ecparam -name secp256k1 -genkey -noout -out private.txt
View the created private key:
cat private.txt
Derive a public key:
openssl ec -pubout -in private.txt -out public.txt
View the created public key:
cat public.txt
Sign the message using the private key:
openssl dgst -sha256 -sign private.txt -out signature.bin message.txt
Show the message signature:
base64 signature.bin
Verify the signature using the public key:
openssl dgst -sha256 -verify public.txt -signature signature.bin message.txt
Alter the message:
echo Send 2 million USD to John Smith > message.txt
Verify the signature using the public key:
openssl dgst -sha256 -verify public.txt -signature signature.bin message.txt