A regular human who likes coding.
A regular human who likes coding.

Subscribe to iiiyu

Subscribe to iiiyu
<100 subscribers
<100 subscribers
Share Dialog
Share Dialog
Bitcoin and Ethereum are different design ideas for account systems. So their transaction systems are not the same.
Today, I will ignore Bitcoin and more explain about Ethereum.
Bitcoin uses Unspent Transaction Output.
Ethereum uses the normal account system.
If you ask me what is the blockchain, I will say the blockchain looks like a simple account book. It records one line of transfer records. Every record least includes three elements:
From where
To where
How much
In the blockchain world, the wallet address is an identity on transfer records.
If you have one wallet address, you could get a ticket to visit the blockchain world.
Unlike the current account system of Web2, a blockchain wallet address is not registered. It is obtained through a series of complex encryption algorithms using a private key.
A series of complex encryption algorithms used to generate the wallet address is public and fixed. This means that anyone can implement the method and generate the wallet address using any programming on any device at any time and no internet connection is required.
Each unique private key corresponds to a unique wallet address.
The private key is the only credential to operate the wallet.
If you lost the private key, it can't retrievable.
Ethereum has two account types:
Externally owned – controlled by anyone with the private keys
Contract – a smart contract deployed to the network, controlled by code.
Both account types can:
Receive, hold and send ETH and tokens
Interact with deployed smart contracts
The address format for both accounts is a 42-character hexadecimal string starting with 0x. etc.
Private Key -> Public Key -> Address.
Therefore, address generation requires three steps:
Private Key -> Public Key -> Address.
Therefore, address generation requires three steps:
Generate a random private key size of 64 hexadecimal characters. (256 bits / 32 bytes)
Generate a public key from the private key via the Elliptic Curve Digital Signature Algorithm. (128 hexadecimal / 512 bits / 64 bytes)
Get a 64-character string with the public key via the Keccak-256 hash function, and then take the last 40 characters as the address. (40 hexadecimal / 160 bits / 20bytes )
First, install sha3sum for keccak-256sum. https://github.com/maandree/sha3sum
// on macOS
brew install sha3sum
# Generate the private and public keys
openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout > key
# Extract the public key and remove the EC prefix 0x04
cat key | grep pub -A 5 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^04//' > pub
# Extract the private key and remove the leading zero byte
cat key | grep priv -A 3 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^00//' > priv
# Generate the hash and take the address part
cat pub | keccak-256sum -x -l | tr -d ' -' | tail -c 41 | awk '{print "0x"$1}'> address
# display your address
cat address
package main
import (
"crypto/ecdsa"
"fmt"
"log"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
)
func main() {
privateKey, err := crypto.GenerateKey()
if err != nil {
log.Fatal(err)
}
privateKeyBytes := crypto.FromECDSA(privateKey)
fmt.Println("SAVE BUT DO NOT SHARE THIS (Private Key):", hexutil.Encode(privateKeyBytes))
publicKey := privateKey.Public()
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
if !ok {
log.Fatal("cannot assert type: publicKey is not of type *ecdsa.PublicKey")
}
publicKeyBytes := crypto.FromECDSAPub(publicKeyECDSA)
fmt.Println("Public Key:", hexutil.Encode(publicKeyBytes))
address := crypto.PubkeyToAddress(*publicKeyECDSA).Hex()
fmt.Println("Address:", address)
}
Now we have two easy ways to generate the Ethereum wallet address offline and have the private key.
https://iiiyu.com/2022/08/02/how-to-generate-a-new-ethereum-address/
Generate Ethereum Private key, Public key, and Address using Bash and OpenSSL
Bitcoin and Ethereum are different design ideas for account systems. So their transaction systems are not the same.
Today, I will ignore Bitcoin and more explain about Ethereum.
Bitcoin uses Unspent Transaction Output.
Ethereum uses the normal account system.
If you ask me what is the blockchain, I will say the blockchain looks like a simple account book. It records one line of transfer records. Every record least includes three elements:
From where
To where
How much
In the blockchain world, the wallet address is an identity on transfer records.
If you have one wallet address, you could get a ticket to visit the blockchain world.
Unlike the current account system of Web2, a blockchain wallet address is not registered. It is obtained through a series of complex encryption algorithms using a private key.
A series of complex encryption algorithms used to generate the wallet address is public and fixed. This means that anyone can implement the method and generate the wallet address using any programming on any device at any time and no internet connection is required.
Each unique private key corresponds to a unique wallet address.
The private key is the only credential to operate the wallet.
If you lost the private key, it can't retrievable.
Ethereum has two account types:
Externally owned – controlled by anyone with the private keys
Contract – a smart contract deployed to the network, controlled by code.
Both account types can:
Receive, hold and send ETH and tokens
Interact with deployed smart contracts
The address format for both accounts is a 42-character hexadecimal string starting with 0x. etc.
Private Key -> Public Key -> Address.
Therefore, address generation requires three steps:
Private Key -> Public Key -> Address.
Therefore, address generation requires three steps:
Generate a random private key size of 64 hexadecimal characters. (256 bits / 32 bytes)
Generate a public key from the private key via the Elliptic Curve Digital Signature Algorithm. (128 hexadecimal / 512 bits / 64 bytes)
Get a 64-character string with the public key via the Keccak-256 hash function, and then take the last 40 characters as the address. (40 hexadecimal / 160 bits / 20bytes )
First, install sha3sum for keccak-256sum. https://github.com/maandree/sha3sum
// on macOS
brew install sha3sum
# Generate the private and public keys
openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout > key
# Extract the public key and remove the EC prefix 0x04
cat key | grep pub -A 5 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^04//' > pub
# Extract the private key and remove the leading zero byte
cat key | grep priv -A 3 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^00//' > priv
# Generate the hash and take the address part
cat pub | keccak-256sum -x -l | tr -d ' -' | tail -c 41 | awk '{print "0x"$1}'> address
# display your address
cat address
package main
import (
"crypto/ecdsa"
"fmt"
"log"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
)
func main() {
privateKey, err := crypto.GenerateKey()
if err != nil {
log.Fatal(err)
}
privateKeyBytes := crypto.FromECDSA(privateKey)
fmt.Println("SAVE BUT DO NOT SHARE THIS (Private Key):", hexutil.Encode(privateKeyBytes))
publicKey := privateKey.Public()
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
if !ok {
log.Fatal("cannot assert type: publicKey is not of type *ecdsa.PublicKey")
}
publicKeyBytes := crypto.FromECDSAPub(publicKeyECDSA)
fmt.Println("Public Key:", hexutil.Encode(publicKeyBytes))
address := crypto.PubkeyToAddress(*publicKeyECDSA).Hex()
fmt.Println("Address:", address)
}
Now we have two easy ways to generate the Ethereum wallet address offline and have the private key.
https://iiiyu.com/2022/08/02/how-to-generate-a-new-ethereum-address/
Generate Ethereum Private key, Public key, and Address using Bash and OpenSSL
No activity yet