SlideShare une entreprise Scribd logo
1  sur  86
Télécharger pour lire hors ligne
Fabio Akita
@akitaonrails
@codeminer42
@theconf_br
@omnitrade_br
21-22 SET 2018
@THECONF_BR
CRYPTOGRAPHIC
HASH/DIGEST
 > require "digest"
 => true
 > Digest::SHA256.hexdigest("hello world")
 =>
"b94d27b9934d3e08a52e52d7da7dabfac484efe3
7a5380ee9088f7ace2efcde9"
 > Digest::SHA256.hexdigest("hello world!")
 =>
"7509e5bda0c762d2bac7f90d758b5b2263fa01cc
bc542ab5e3df163be08e6ca9"
CRYPTOGRAPHIC
HASH/DIGEST
 > Digest::SHA256.hexdigest("Lorem ipsum dolor sit amet,
consectetuer adipiscing elit. Aenean commodo ligula eget dolor.
Aenean massa. Cum sociis natoque penatibus et magnis dis parturient
montes, nascetur ridiculus mus. Donec quam felis, ultricies nec,
pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.
Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In
enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam
dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus.
Vivamus elementum semper nisi. Aenean vulputate eleifend tellus.
Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.
Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus.
Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum.
Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur
ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas
tempus, tellus eget condimentum rhoncus, sem quam semper libero,
sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit
vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante
tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus.
Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis
leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna.
Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,")
 =>
"4d0fcee44bd65ea0a0c983da992b053d6f5d94a25e91eae6a783f59fb
5ef0cc1"
 De:
 Para:
 Valor: 0.01234567 BTC
TRANSAÇÕES
ACUMULAM EM
BLOCOS
 git branch –b mempool
 git add panda_sapo.transaction
 git commit –m “de panda, p/ sapo,
0.0123456 BTC”
 git push origin mempool
TRANSAÇÕES
ACUMULAM EM
BLOCOS
 git branch –b mempool
 git add panda_sapo.transaction
 git commit –m “de panda, p/ sapo,
0.0123456 BTC”
 git push origin mempool
 git checkout master
 git merge mempool
NEVER TRUST BYZANTINE GENERALS!
def compute_hash_with_proof_of_work( difficulty, hash )
nonce = 0
loop do
signature = calc_hash_with_nonce( nonce, hash )
if signature.start_with?( difficulty )
return [nonce, signature]
else
nonce += 1
end
end
end
def calc_hash_with_nonce( nonce, hash )
Digest::SHA256.new.tap do |sha|
sha.update( nonce.to_s + hash )
sha.hexdigest
end
end
> hash = Digest::SHA256.hexdigest("hello world")
> puts Benchmark.measure {
compute_hash_with_proof_of_work("0000", hash) }
0.040000 0.000000 0.040000 ( 0.044949)
> puts Benchmark.measure {
compute_hash_with_proof_of_work("00000", hash) }
1.030000 0.000000 1.030000 ( 1.047740)
> puts Benchmark.measure {
compute_hash_with_proof_of_work("000000", hash) }
42.920000 0.040000 42.960000 ( 43.642561)
 Para Bitcoin (SHA256):
980 MH/s(milhões de hash/seg)
 > USD 500
 NÃO TEM ROI!
 Para Bitcoin (SHA256):
13.5 TH/s(TRILHÕES de hashes)
 > USD 8000 (fila de espera)
 > 10 mil dias para ROI
 17.468 tubos a vácuo
 70 mil resistors
 1.500 relays
 6.000 switches manuais
 5 milhões de pontos de solda
 167 m2
 30 toneladas
 180 kW
1.468 GWh/ano
 (DUAS ISLÂNDIAS)
17 mil vezes mais BARATO
40 MILHÕES de vezes MENOR
400 MIL vezes menos energia
120 MIL vezes mais leve
1.300xmais PODEROSO!
17 mil vezes mais BARATO
40 MILHÕES de vezes MENOR
400 MIL vezes menos energia
120 MIL vezes mais leve
1.300xmais PODEROSO!
Cada habitante da
Terra precisaria doar
USD 10 BILHÕES para
minerar UM BITCOIN
E levaria 35 MIL
vezes a IDADE DO
UNIVERSO até assinar
1 BLOCO
~ 30 blocos por dia
(1Mb/bloco)
~ 12 BTC por bloco
~ 360 BTC por dia
(~ USD 3.6 milhões por dia)
~ 6.122 PH/s
(= 6.2 milhões de GTX 1080 Ti)
pragma solidity ^0.4.19;
contract BancoSimples {
mapping (address => uint) private saldos;
address public dono;
function BancoSimples() public {
dono = msg.sender;
}
function depositar() public payable returns (uint) {
require(msg.value > 0);
saldos[msg.sender] += msg.value;
return saldos[msg.sender];
}
function sacar(uint valor) public returns (uint) {
require(valor <= saldos[msg.sender]);
saldos[msg.sender] -= valor;
msg.sender.transfer(valor);
return saldos[msg.sender];
}
function verSaldo() constant public returns (uint) {
return saldos[msg.sender];
}
}
pragma solidity ^0.4.19;
contract BancoSimples {
mapping (address => uint) private saldos;
address public dono;
function BancoSimples() public {
dono = msg.sender;
}
….
function verSaldo() constant public returns (uint) {
return saldos[msg.sender];
}
}
pragma solidity ^0.4.19;
contract BancoSimples {
….
function depositar() public payable returns (uint) {
require(msg.value > 0);
saldos[msg.sender] += msg.value;
return saldos[msg.sender];
}
….
}
pragma solidity ^0.4.19;
contract BancoSimples {
….
function sacar(uint valor) public returns (uint) {
require(valor <= saldos[msg.sender]);
saldos[msg.sender] -= valor;
msg.sender.transfer(valor);
return saldos[msg.sender];
}
…
}
 Contratos Inteligentes
 Identidade Digital
 Armazenamento Distribuído
 Registro de Terras
 Eleições Digitais (de verdade)
 Infraestrutura de pagamentos
 Ativos digitais
 Eficiência e Transparência no
Governo
 Basicamente, a extinção do Cartório
 Basicamente, a extinção de todo
centralizador de dados
OBRIGADO!
@akitaonrails
@codeminer42
(become@codeminer42.com)
@theconf_br
@omnitrade_br

Contenu connexe

Plus de Fabio Akita

30 Days to Elixir and Crystal and Back to Ruby
30 Days to Elixir and Crystal and Back to Ruby30 Days to Elixir and Crystal and Back to Ruby
30 Days to Elixir and Crystal and Back to RubyFabio Akita
 
Uma Discussão sobre a Carreira de TI
Uma Discussão sobre a Carreira de TIUma Discussão sobre a Carreira de TI
Uma Discussão sobre a Carreira de TIFabio Akita
 
THE CONF - Opening Keynote
THE CONF - Opening KeynoteTHE CONF - Opening Keynote
THE CONF - Opening KeynoteFabio Akita
 
A Journey through New Languages - Rancho Dev 2017
A Journey through New Languages - Rancho Dev 2017A Journey through New Languages - Rancho Dev 2017
A Journey through New Languages - Rancho Dev 2017Fabio Akita
 
Desmistificando Mitos de Startups - Sebrae - AP
Desmistificando Mitos de Startups - Sebrae - APDesmistificando Mitos de Startups - Sebrae - AP
Desmistificando Mitos de Startups - Sebrae - APFabio Akita
 
A Journey through New Languages - Guru Sorocaba 2017
A Journey through New Languages - Guru Sorocaba 2017A Journey through New Languages - Guru Sorocaba 2017
A Journey through New Languages - Guru Sorocaba 2017Fabio Akita
 
A Journey through New Languages - Insiter 2017
A Journey through New Languages - Insiter 2017A Journey through New Languages - Insiter 2017
A Journey through New Languages - Insiter 2017Fabio Akita
 
A Journey through New Languages - Locaweb Tech Day
A Journey through New Languages - Locaweb Tech DayA Journey through New Languages - Locaweb Tech Day
A Journey through New Languages - Locaweb Tech DayFabio Akita
 
A Journey through new Languages - Intercon 2016
A Journey through new Languages - Intercon 2016A Journey through new Languages - Intercon 2016
A Journey through new Languages - Intercon 2016Fabio Akita
 
Premature Optimization 2.0 - Intercon 2016
Premature Optimization 2.0 - Intercon 2016Premature Optimization 2.0 - Intercon 2016
Premature Optimization 2.0 - Intercon 2016Fabio Akita
 
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização PrematuraConexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização PrematuraFabio Akita
 
The Open Commerce Conference - Premature Optimisation: The Root of All Evil
The Open Commerce Conference - Premature Optimisation: The Root of All EvilThe Open Commerce Conference - Premature Optimisation: The Root of All Evil
The Open Commerce Conference - Premature Optimisation: The Root of All EvilFabio Akita
 
Premature optimisation: The Root of All Evil
Premature optimisation: The Root of All EvilPremature optimisation: The Root of All Evil
Premature optimisation: The Root of All EvilFabio Akita
 
Elixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
Elixir - Tolerância a Falhas para Adultos - Secot VIII SorocabaElixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
Elixir - Tolerância a Falhas para Adultos - Secot VIII SorocabaFabio Akita
 
Elixir: Tolerância a Falhas para Adultos - OneDay Baixada Santista
Elixir: Tolerância a Falhas para Adultos - OneDay Baixada SantistaElixir: Tolerância a Falhas para Adultos - OneDay Baixada Santista
Elixir: Tolerância a Falhas para Adultos - OneDay Baixada SantistaFabio Akita
 
Evento Codeminer UFRN 2016
Evento Codeminer UFRN 2016Evento Codeminer UFRN 2016
Evento Codeminer UFRN 2016Fabio Akita
 
QCON SP 2016 - Elixir: Tolerância a Falhas para Adultos
QCON SP 2016 - Elixir: Tolerância a Falhas para AdultosQCON SP 2016 - Elixir: Tolerância a Falhas para Adultos
QCON SP 2016 - Elixir: Tolerância a Falhas para AdultosFabio Akita
 
"Elixir of Life" - Dev In Santos
"Elixir of Life" - Dev In Santos"Elixir of Life" - Dev In Santos
"Elixir of Life" - Dev In SantosFabio Akita
 
Restrição == inovação - 17o Encontro Locaweb SP
Restrição == inovação  - 17o Encontro Locaweb SPRestrição == inovação  - 17o Encontro Locaweb SP
Restrição == inovação - 17o Encontro Locaweb SPFabio Akita
 
languages.map(&:latest).reduce(&:future).sort.first - Rupy Campinas 2015
languages.map(&:latest).reduce(&:future).sort.first - Rupy Campinas 2015languages.map(&:latest).reduce(&:future).sort.first - Rupy Campinas 2015
languages.map(&:latest).reduce(&:future).sort.first - Rupy Campinas 2015Fabio Akita
 

Plus de Fabio Akita (20)

30 Days to Elixir and Crystal and Back to Ruby
30 Days to Elixir and Crystal and Back to Ruby30 Days to Elixir and Crystal and Back to Ruby
30 Days to Elixir and Crystal and Back to Ruby
 
Uma Discussão sobre a Carreira de TI
Uma Discussão sobre a Carreira de TIUma Discussão sobre a Carreira de TI
Uma Discussão sobre a Carreira de TI
 
THE CONF - Opening Keynote
THE CONF - Opening KeynoteTHE CONF - Opening Keynote
THE CONF - Opening Keynote
 
A Journey through New Languages - Rancho Dev 2017
A Journey through New Languages - Rancho Dev 2017A Journey through New Languages - Rancho Dev 2017
A Journey through New Languages - Rancho Dev 2017
 
Desmistificando Mitos de Startups - Sebrae - AP
Desmistificando Mitos de Startups - Sebrae - APDesmistificando Mitos de Startups - Sebrae - AP
Desmistificando Mitos de Startups - Sebrae - AP
 
A Journey through New Languages - Guru Sorocaba 2017
A Journey through New Languages - Guru Sorocaba 2017A Journey through New Languages - Guru Sorocaba 2017
A Journey through New Languages - Guru Sorocaba 2017
 
A Journey through New Languages - Insiter 2017
A Journey through New Languages - Insiter 2017A Journey through New Languages - Insiter 2017
A Journey through New Languages - Insiter 2017
 
A Journey through New Languages - Locaweb Tech Day
A Journey through New Languages - Locaweb Tech DayA Journey through New Languages - Locaweb Tech Day
A Journey through New Languages - Locaweb Tech Day
 
A Journey through new Languages - Intercon 2016
A Journey through new Languages - Intercon 2016A Journey through new Languages - Intercon 2016
A Journey through new Languages - Intercon 2016
 
Premature Optimization 2.0 - Intercon 2016
Premature Optimization 2.0 - Intercon 2016Premature Optimization 2.0 - Intercon 2016
Premature Optimization 2.0 - Intercon 2016
 
Conexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização PrematuraConexão Kinghost - Otimização Prematura
Conexão Kinghost - Otimização Prematura
 
The Open Commerce Conference - Premature Optimisation: The Root of All Evil
The Open Commerce Conference - Premature Optimisation: The Root of All EvilThe Open Commerce Conference - Premature Optimisation: The Root of All Evil
The Open Commerce Conference - Premature Optimisation: The Root of All Evil
 
Premature optimisation: The Root of All Evil
Premature optimisation: The Root of All EvilPremature optimisation: The Root of All Evil
Premature optimisation: The Root of All Evil
 
Elixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
Elixir - Tolerância a Falhas para Adultos - Secot VIII SorocabaElixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
Elixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
 
Elixir: Tolerância a Falhas para Adultos - OneDay Baixada Santista
Elixir: Tolerância a Falhas para Adultos - OneDay Baixada SantistaElixir: Tolerância a Falhas para Adultos - OneDay Baixada Santista
Elixir: Tolerância a Falhas para Adultos - OneDay Baixada Santista
 
Evento Codeminer UFRN 2016
Evento Codeminer UFRN 2016Evento Codeminer UFRN 2016
Evento Codeminer UFRN 2016
 
QCON SP 2016 - Elixir: Tolerância a Falhas para Adultos
QCON SP 2016 - Elixir: Tolerância a Falhas para AdultosQCON SP 2016 - Elixir: Tolerância a Falhas para Adultos
QCON SP 2016 - Elixir: Tolerância a Falhas para Adultos
 
"Elixir of Life" - Dev In Santos
"Elixir of Life" - Dev In Santos"Elixir of Life" - Dev In Santos
"Elixir of Life" - Dev In Santos
 
Restrição == inovação - 17o Encontro Locaweb SP
Restrição == inovação  - 17o Encontro Locaweb SPRestrição == inovação  - 17o Encontro Locaweb SP
Restrição == inovação - 17o Encontro Locaweb SP
 
languages.map(&:latest).reduce(&:future).sort.first - Rupy Campinas 2015
languages.map(&:latest).reduce(&:future).sort.first - Rupy Campinas 2015languages.map(&:latest).reduce(&:future).sort.first - Rupy Campinas 2015
languages.map(&:latest).reduce(&:future).sort.first - Rupy Campinas 2015
 

Desmistificando Blockchains - 20o Encontro Locaweb SP

  • 2.
  • 3.
  • 5. CRYPTOGRAPHIC HASH/DIGEST  > require "digest"  => true  > Digest::SHA256.hexdigest("hello world")  => "b94d27b9934d3e08a52e52d7da7dabfac484efe3 7a5380ee9088f7ace2efcde9"  > Digest::SHA256.hexdigest("hello world!")  => "7509e5bda0c762d2bac7f90d758b5b2263fa01cc bc542ab5e3df163be08e6ca9"
  • 6. CRYPTOGRAPHIC HASH/DIGEST  > Digest::SHA256.hexdigest("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,")  => "4d0fcee44bd65ea0a0c983da992b053d6f5d94a25e91eae6a783f59fb 5ef0cc1"
  • 7.  De:  Para:  Valor: 0.01234567 BTC
  • 8.
  • 9. TRANSAÇÕES ACUMULAM EM BLOCOS  git branch –b mempool  git add panda_sapo.transaction  git commit –m “de panda, p/ sapo, 0.0123456 BTC”  git push origin mempool
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. TRANSAÇÕES ACUMULAM EM BLOCOS  git branch –b mempool  git add panda_sapo.transaction  git commit –m “de panda, p/ sapo, 0.0123456 BTC”  git push origin mempool  git checkout master  git merge mempool
  • 17.
  • 18.
  • 19. def compute_hash_with_proof_of_work( difficulty, hash ) nonce = 0 loop do signature = calc_hash_with_nonce( nonce, hash ) if signature.start_with?( difficulty ) return [nonce, signature] else nonce += 1 end end end def calc_hash_with_nonce( nonce, hash ) Digest::SHA256.new.tap do |sha| sha.update( nonce.to_s + hash ) sha.hexdigest end end
  • 20. > hash = Digest::SHA256.hexdigest("hello world") > puts Benchmark.measure { compute_hash_with_proof_of_work("0000", hash) } 0.040000 0.000000 0.040000 ( 0.044949) > puts Benchmark.measure { compute_hash_with_proof_of_work("00000", hash) } 1.030000 0.000000 1.030000 ( 1.047740) > puts Benchmark.measure { compute_hash_with_proof_of_work("000000", hash) } 42.920000 0.040000 42.960000 ( 43.642561)
  • 21.  Para Bitcoin (SHA256): 980 MH/s(milhões de hash/seg)  > USD 500  NÃO TEM ROI!
  • 22.  Para Bitcoin (SHA256): 13.5 TH/s(TRILHÕES de hashes)  > USD 8000 (fila de espera)  > 10 mil dias para ROI
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.  17.468 tubos a vácuo  70 mil resistors  1.500 relays  6.000 switches manuais  5 milhões de pontos de solda  167 m2  30 toneladas  180 kW 1.468 GWh/ano  (DUAS ISLÂNDIAS)
  • 30.
  • 31. 17 mil vezes mais BARATO 40 MILHÕES de vezes MENOR 400 MIL vezes menos energia 120 MIL vezes mais leve 1.300xmais PODEROSO!
  • 32. 17 mil vezes mais BARATO 40 MILHÕES de vezes MENOR 400 MIL vezes menos energia 120 MIL vezes mais leve 1.300xmais PODEROSO!
  • 33. Cada habitante da Terra precisaria doar USD 10 BILHÕES para minerar UM BITCOIN E levaria 35 MIL vezes a IDADE DO UNIVERSO até assinar 1 BLOCO
  • 34.
  • 35.
  • 36. ~ 30 blocos por dia (1Mb/bloco) ~ 12 BTC por bloco ~ 360 BTC por dia (~ USD 3.6 milhões por dia) ~ 6.122 PH/s (= 6.2 milhões de GTX 1080 Ti)
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61. pragma solidity ^0.4.19; contract BancoSimples { mapping (address => uint) private saldos; address public dono; function BancoSimples() public { dono = msg.sender; } function depositar() public payable returns (uint) { require(msg.value > 0); saldos[msg.sender] += msg.value; return saldos[msg.sender]; } function sacar(uint valor) public returns (uint) { require(valor <= saldos[msg.sender]); saldos[msg.sender] -= valor; msg.sender.transfer(valor); return saldos[msg.sender]; } function verSaldo() constant public returns (uint) { return saldos[msg.sender]; } }
  • 62. pragma solidity ^0.4.19; contract BancoSimples { mapping (address => uint) private saldos; address public dono; function BancoSimples() public { dono = msg.sender; } …. function verSaldo() constant public returns (uint) { return saldos[msg.sender]; } }
  • 63. pragma solidity ^0.4.19; contract BancoSimples { …. function depositar() public payable returns (uint) { require(msg.value > 0); saldos[msg.sender] += msg.value; return saldos[msg.sender]; } …. }
  • 64. pragma solidity ^0.4.19; contract BancoSimples { …. function sacar(uint valor) public returns (uint) { require(valor <= saldos[msg.sender]); saldos[msg.sender] -= valor; msg.sender.transfer(valor); return saldos[msg.sender]; } … }
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.  Contratos Inteligentes  Identidade Digital  Armazenamento Distribuído  Registro de Terras  Eleições Digitais (de verdade)  Infraestrutura de pagamentos  Ativos digitais  Eficiência e Transparência no Governo  Basicamente, a extinção do Cartório  Basicamente, a extinção de todo centralizador de dados
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.