Blockchain adalah teknologi Distributed Ledger yang terdiri dari serangkaian block yang terhubung secara kriptografis dengan algoritma SHA256. Dalam simulator ini setiap block mengandung:
Mekanisme: Sistem hash berantai dimana:
Dalam Simulator: Coba ubah data di block sebelumnya - akan terlihat inconsistency di block berikutnya
Struktur Jaringan:
Implementasi: Meski simulasi single node, konsep dasar menunjukkan:
Coba lakukan ini di simulator:
Smart Contract adalah program yang dieksekusi otomatis ketika kondisi tertentu terpenuhi. Contoh implementasi:
class Block { constructor(index, timestamp, data, previousHash) { this.index = index; this.timestamp = timestamp; this.data = data; this.previousHash = previousHash; this.hash = this.calculateHash(); } calculateHash() { return CryptoJS.SHA256( this.index + this.previousHash + this.timestamp + JSON.stringify(this.data) ).toString(CryptoJS.enc.Hex); } }
class Blockchain { constructor() { this.chain = [this.createGenesisBlock()]; } createGenesisBlock() { return new Block( 0, new Date().toISOString(), { data: 'Genesis Block' }, '0000000000000000000000000000000000000000000000000000000000000000' ); } getLatestBlock() { return this.chain[this.chain.length - 1]; } addBlock(newBlock) { if (this.validateNewBlock(newBlock)) { this.chain.push(newBlock); return true; } return false; } validateNewBlock(newBlock) { const lastBlock = this.getLatestBlock(); const expectedHash = CryptoJS.SHA256( newBlock.index + newBlock.previousHash + newBlock.timestamp + JSON.stringify(newBlock.data) ).toString(CryptoJS.enc.Hex); return ( newBlock.index === lastBlock.index + 1 && newBlock.previousHash === lastBlock.hash && newBlock.hash === expectedHash ); } isChainValid() { for (let i = 1; i < this.chain.length; i++) { const current = this.chain[i]; const previous = this.chain[i - 1]; if (current.hash !== current.calculateHash()) return false; if (current.previousHash !== previous.hash) return false; } return true; } }
Setiap input akan menghasilkan "sidik jari digital" unik sepanjang 64 karakter hexadesimal (0-9, a-f).
Contoh:
Input: "Hello"
SHA-256: 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
๐ก Analogi: Seperti DNA digital dimana setiap data memiliki pola unik 64 karakter
Secara matematis hampir mustahil menemukan dua input berbeda dengan hash yang sama.
Probabilitas tabrakan:
1 / 115,792,089,237,316,195,423,570,985,008,687,907,853,269,984,665,640,564,039,457,584,007,913,129,639,936
Contoh perbandingan:
Input 1: "Hello" โ 185f8db32271fe25...
Input 2: "hello" โ 2cf24dba5fb0a30e...
๐ Keamanan: Butuh 2ยนยฒโธ operasi untuk menemukan collision - setara dengan 10ยฒโท tahun dengan superkomputer modern
Perubahan 1 bit pada input mengubah โ50% bit output secara acak.
Contoh demonstrasi:
Input 1: "Blockchain"
Hash: 625da44e4eaf58d53c94ea6736e6bc44ff53760f1ff4ae3259a9e111e1dcd15f
Input 2: "BlockchaiN" (ubah huruf terakhir)
Hash: 76d55d77c2a0c19175e5f02fafd9e0e3967c79c6e1b4e1c1446f7268b9d5a2d3
Perubahan yang terjadi:
โก Implikasi: Membuat reverse engineering input dari hash menjadi tidak mungkin
Block #1234
Data: "Transfer 5 BTC dari A ke B"
Hash sebelumnya: 0000c3af...
Hash baru: 19d6689c... โ Perubahan 1 karakter di data akan membuat hash baru sama sekali tidak terkait
// Contoh penggunaan SHA-256 const hash = CryptoJS.SHA256('Contoh data').toString(CryptoJS.enc.Hex); // Hasil: 'a3f4c5d6...' (64 karakter hexadesimal)