sudo cp ~/Downloads/geth-darwin-amd64-1.10.10-bb74230f/geth /usr/local/bin/
geth --datadir $PWD
Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: 7280000 Petersburg: 7280000 Istanbul: 9069000, Muir Glacier: 9200000, Berlin: 12244000, London: 12965000, Engine: ethash}"
London: IP1559에서 추가된 트랜잭션 사용가능
Engine: ethash(POW) / qlicue(POA)
신뢰? 데이터를 정확히 전달
TCP: 신뢰보장 o / 속도느림
UDP: 신뢰보장 x / 속도빠름
geth: 블록체인에서 생성되는 모든 데이터 관리
keystone: 해당 노드에서 생성되는 키스토어 파일 관리
geth --datadir $PWD account new
프라이빗키 중요 -> 보안은 어떻게?
키스토어 파일!
키스토어 파일 + 비밀번호 -> 프라이빗키!
두 개의 알고리즘 = aes: 프라이빗키를 복구 + scrypt: 비밀번호를 암호화!
KeyStore비밀번호 + KDF(파라미터) -SCRYPT알고리즘-> Derived Key
프라이빗키 = 할당된 주소(지갑)의 소유권
지갑을 생성 x / 생성된 지갑에 할당 o
-> state 변화 = 지갑 생성 x, 트랜잭션 o
A: Scrypt의 결과값은 Private Key를 복호화하는데 사용하는 키
A: Scrypt는 현존하는 단방향 해시함수 중 가장 강력한 알고리즘 중 하나.
알고리즘 자체가 결과값을 생성할 때 메모리 오버헤드를 갖도록 설계되어 bruteforce(0부터 하나씩 넣기)공격이 힘들게 설계.
하나의 지갑으로 여러개의 계정 관리? mnemonic
마스터노드/account/.../
master seed가 동일하면 동일한 private key, address
const bip39 = require("bip39");
const { hdkey } = require("ethereumjs-wallet");
const mnemonic = bip39.generateMnemonic();
console.log(`mnemonic is : "${mnemonic}"`);
(async () => {
const seed = await bip39.mnemonicToSeed(mnemonic); // seed === entropy
const rootKey = hdkey.fromMasterSeed(seed);
const hardenedKey = rootKey.derivePath("m/44'/60'/0'/0");
const childKey = hardenedKey.deriveChild(0); // 값조정 가능
const wallet = childKey.getWallet();
const address = wallet.getAddress();
const privateKey = wallet.getPrivateKey();
console.log(`seed is ${seed.toString('hex')}`)
console.log(`======== rootKey =======`)
console.log(rootKey)
console.log(`======= childKey =======`)
console.log(childKey)
console.log(`======= wallet is =======`)
console.log(wallet)
console.log(`address is ${address.toString("hex")}`);
console.log(`privateKey is ${privateKey.toString("hex")}`);
})()
여기서 생성된 니모닉으로 타 지갑에서 사용하면 동일한 계정생성
const bip39 = require("bip39");
const { hdkey } = require("ethereumjs-wallet");
const mnemonic = bip39.generateMnemonic();
console.log(`mnemonic is : "${mnemonic}"`);
(async () => {
const seed = await bip39.mnemonicToSeed(mnemonic); // seed === entropy
const rootKey = hdkey.fromMasterSeed(seed);
const hardenedKey = rootKey.derivePath("m/44'/60'/0'/0");
console.log(`seed is ${seed.toString('hex')}`)
for (let i = 0; i < 10; i++) {
console.log(i)
const childKey = hardenedKey.deriveChild(i); // 값조정 가능
const wallet = childKey.getWallet();
const address = wallet.getAddress();
const privateKey = wallet.getPrivateKey();
console.log(`<CHILDKEY>`)
console.log(childKey)
console.log(`<WALLET IS>`)
console.log(wallet)
console.log(`[address] ${address.toString("hex")}`);
console.log(`[privateKey] ${privateKey.toString("hex")}`);
console.log('============')
} })()
생성된 니모닉을 metamask에서 사용한 후 생성된 계정 주소 비교