# Pluggable crypto for Ethereum nodes: Masterchain experience

- Channel: [Devcon](https://streameth.org/devcon)
- Date: 2018-10-07
- Duration: 15:08
- Watch: https://streameth.org/watch/yt-faVnsBRLAL4
- YouTube: https://www.youtube.com/watch?v=faVnsBRLAL4

## Description

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more.
https://archive.devcon.org/archive/watch/3/pluggable-crypto-for-ethereum-nodes-masterchain-experience

Ethereum has a few subsystems which use cryptography in their core functionality: 1. Transaction processing system, 2. P2P node communication, 3. EVM (Ethereum Virtual Machine), 4. Mining. So far all these systems use only one crypto library but they use it in different ways. We have developed an extra crypto-layer, which makes crypto to work as an additional abstract layer. The extra-crypto layer is completely transparent for all ethereum logic. It allows to switch crypto-algorithms to use in Ethereum.

Speaker(s): Alexey Troshichev, Dmitry Bozhko
Skill level: Intermediate
Track: Developer Infrastructure


Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum
Learn more about devcon: https://www.devcon.org/
Learn more about ethereum: https://ethereum.org/ 

Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. 
Devcon 3 was held in Cancún, Mexico on Nov 1 - 4, 2017
Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/

## Transcript

[Music] so hello ladies and gentlemen I'm here today to share my our experience on creating the pluggable krypter krypter provider for aetherium notes and which we used in master chain project so who we are I am mitra Bochco i'm the critic or developer at master chain project and the one man who I want to introduce who unfortunately couldn't come here to this great conference it's Alex it's Russia chef and he's master chain architect so what is master chain master chain is Russian national platform for storing and exchanging financial data based on blockchain technology so the two key words in this definition is National and blockchain so we've choose the public ethereum protocol for as a basis for a master chain project why we do that because the first etherium protocol have large experience with work and vilde of course it has supports it has a smart contracts and it has big big cim yux it had a big community and has big community and this community is grows and solves many many new issues so this platform wouldn't be abandoned so what is master chain it's a fork it's a fork of public aetherium protocol it's also supports of course smart contracts and the main difference is it based on scripto ghost crypto stands for government standard scriptum it is the main standard in Russian Federation for all cryptography if you are interested you could just read the white paper for master Shane project this link is for this wet wet paper so why we have to use the custom cryptography the second and the the first and the main it is because only government standards crypto algorithms have legal power so if you want to build any system which involves any kind of cryptography your cryptography in Russian Federation should be the cost and not just only your own implementation of cost its it has to be certified by Russian Federal Security Services not only or not not only not even your only step or your solution has to be certified by FSB yet but but cryptography is definitely that kind what you need to certified in Russian Federation so there are only few only certified crypto service providers have to be used and you can say whoa you I can I can implement the ghosts myself and get and certified it no you you could probably do that but it's extremely extremely difficult that's why only a few vendors of tsps are presented in the market in the Russian market so we used for our project is crypt approach CSP for 4-0 and what's what's the main difference what what does ghost crypto algorithms family consists the first one is the hash function the hash function is ghosts are 4:11 212 it called streebek calls for Slovak God and it has two modes 256 bits and 512 bits but in our project master chain we used only six bits so the second is the it CD say algorithms for digital signature it calls ghost r34 10 2012 and it doesn't have the specific nickname it supports 20 hundred 256 bit curves and 512 bit curves with different parameters for each curves we used 256 bit curve with the params set a also it has a symmetric K block cipher still still running ghosts 24 147 developed in 89 in 1989 it calls magma there has a new there is a new modern algorithm which were built in 215 it calls cosmetic but he still doesn't have the certified implementations so we couldn't use it and last operation it's the bunch it's it's it's several operations for transport security the diffie-hellman scheme and it works with its ADIZ a ghost algorithm and with symmetric k block cipher with magma and in crypt approach ESP there is a certified implementation of TLS protocol so we we've decided to choose this one for for our project so what was a cerium crypto and recover before we started we started at version 1 1 5 and looks like it was a big mess because there were Krypton module which had a wrapper for crypto hashes for it cities say 80s implementation and for implementation of curves XP 256 K 1 built for Bitcoin and it wraps all all those functions in one Krypton module but suddenly there were redundant calls from p2p communication system from mining system from EVM directly calls to those to those functions so we decided to redesign it we've built a single crypt adapter which were transparent for all build business logic notes business logic calls this script adapter have unified calls to a wrapper interface and each each library like this be rapper like go star rapper or any other rapper you can you can write here by your own so each each of this rapper I implement this rapper interface and raps they're exactly the exactly library so first we've choose the open source source ghost are so we can just test that all functions that were present in the original theorem are switchable to the new cryptography so and then after that we've built that CSP wrapper for third party library crypt approach CSP which is a black box for us and this theme is kind of work very good so and it builds like that so you can implement your own crypto wrapper which would wipe your rap your own crypto library in fact you can do the mix mode use the NIST cryptography or ghost cryptography in the same way so what have to from entire room to master chain the three types of hashes shot 256 shot three in two months to 256 bits and 512 bits we switched it to streebek it's it is say and SEC P 256 K 1 we have switched to ghost city say with 256 bit curve with perhaps at a and we've redeveloped the equal function I will tell you a bit more later on the next slide about this but we've implemented compressed signature for ghost ghost algorithm family so a kookabura works now very good it recovers the pub key from compressed signature but then you have to verify it with certified verification function from that CSB so it also it also has to and it also works with 256 bit curves with parameter a on master chain there Semite symmetric cryptography which were used in air leaks encryption between the communication of two nodes it was ace it switched to Magnum symmetric ciphers with 20 50 256 bits key and block size of 60 four bits for magma switched from 124 bits from Ace and of course we we've read out of Arabic script arabic's encryption why that as a thought as I said if you have if you have certified implementation of one part of any any cryptographic function it doesn't mean that the whole solution are certified by itself so that's why we have to we have two ways the first way is trying to certify in F is B the whole oral plagues encryption protocol or just switched it to certified TAS so we've we've choose the second one and the human protocol in communication LP is so we just we just switch the encryption anything which is going through our stands like in the original theorem so about compressed signature because of the different different algebra when you're working with curves in God's standard we have to reproduce compressed signature which was used in nist curves in bitcoin and in a theorem so we did find a way we but it was some something interesting because agri-cover function was created without modification of original certified CSP but that's why we have to we have to call the verification function on this so first of all you you're gonna restore the pop key from the compressed signature and then you have - you have to give the verification function the original signature and the restored pop key so that that solution would be certified and last one we've implemented notes white list as a smart contract for authorized communication and for authorized mining it was it was a requirement for FinTech association so crypto greetings complaint with this requirements can be used with our cryptid after transparently for the rest of ethereum logic and again the hash function in 256 bit modes it CDSA in 256 bit with 256 bit curves your compressed signature support with 256 bit curves and symmetric block cipher with key with 256 bits and block size 128 or 64 bits and if you implement your own TLS protocol you should do it because you cannot you cannot communicate with nodes in master chain without this implementation so it was glad to talk about some cryptography so you can ask some questions for me right right after this presentation have a nice day [Music]
