# Extending Ethereum with Enterprise Smart Contracts

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

## 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/extending-ethereum-with-enterprise-smart-contracts

A depth walkthrough of extending Smart Contract logic into a secure, scalable cloud execution environment using Cryptlets and the Cryptlet Proof Engine.

Speaker(s): Marley Gray
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

thank you good morning so it's all my inner body smart contracts at 15 minutes it's a pretty deep topic this is also known as scriptlets if my smart contracts is a nice marketing term for people that aren't very technical but let's talk about some background first so in Azure Microsoft's cloud platform we have some pillars that we've built upon to build this platform the first of which is identity Azure Active Directory is an open federated identity system supports open authentication it's the dominant identity system used in a crisis today it allows us to do open Federation second is a secret storage or HSMs so we have HSM that scale and so they call a droid key vault that lets you bring your own keys bringing on secrets and things like that recently announced the confidential compute platform which is essentially describing enclaves at scale in the cloud both SGX and what we call hypervisor based or HSM excuse me VSM based on claves that allow you to have secure confidential compute in the cloud and then lastly hyper scale so we have a platform that was developed called service fabric that runs things like xbox live so we have like this massively scalable platform that we can we can build upon so let's describe what this does so ESC is the acronym reasoning so unify support contracts essentially under the covers we call the the ESC framework running in the excuse me ESC fabric running has some core infrastructure capabilities the first of which is we authenticate users so we use Azure Active Directory to authenticate those users now don't think we can use this to authenticate using Facebook if you want to but essentially you authenticate the user would an attached message that flows into the system to create a secure session it's themselves have dependencies meaning this is what are required or require an enclave what kind of runtime environment do I need my dad or a Java or a rust it so those dependencies are inspected and then the infrastructure has essentially many hsn's available to it those can be in the cloud that can also be on prim and then we pool scarce resources enclaves would be one of them but we envision that you would want to use things like FPGAs to accelerate the zero knowledge proof generation a6 GPUs whatever some sort of combination so we allow you to have single sort of we call them delegates essentially but you're delegating your cryptographic operations to this Enclave environment so what happens at runtime is a crypto delegate gets built that will be injected with an enclave with the appropriate secrets in the appropriate AP is that you're trying to use for the platforms if you're using ECC or the ECC libraries you also might get a composite where you would get both an enclave and an FPGA and you can call this thing a foo and give me a food at runtime and then I'll have my algorithms generators err knowledge proof or whatever you want to do so you can really compose this hardware acceleration for the requirements that you have to allow this do things like dynamic allocation and de-allocation so we pull these resources to get massive scale and also reduces cost so you can start doing very innovative things with low cost you're only paying for what you're using so you're not gonna pay for all this stuff 24 by 7 you're gonna pay for it for the second or two if anything what you're doing that you're actually using it for transaction now we'll talk more about some of the kid around fication zuv this but you can do everything from just basic signatures to threshold encryption so you can do encryption in the cloud as well I'm using these so the broader framework we do support multiple Ledger's down at the bottom we have a couple years ago we announced blockchain is a service just unfortunately named it that for some reason it seems like a good idea at a time but since it was based on etherium everything we do at Microsoft really starts for the theory when we sort of branch out from there so it applies the theorem alliance or forum and things like that but we also support court on these others because we abstract them away with what we call the blockchain router and this is a common abstraction pattern what we define a basic interface where anyone can do write a connector that plugs into the router as a simple interface definition and then it has very blotchy and specific I knows how to create watching specific transactions you will create contract proxies which is essentially taking that next step where we talk about a type system CREP let's don't know what watching they're talking to they don't care they deal with message types so strongly typed messages are very important for contractual business we need to know not only what a message structure is but what data types are embedded we keep don't allow variants so they need to be declared integers or doubles or floats or whatever or composite types 'its will then use those message types and then they pass them down to the proxy the proxy can ingest those message types and then convert them into the appropriate watching transaction you see the scripted gala gets attached to these various locations these things are again generated on the fly we support multiple signatures so you have familiar with certificate chains we call it a crippled onion which are layers of of crypto validations of each operation both from an attestation standpoint that the code ran and confident confidentially from the Enclave to the source of your data actually came from where it was supposed to come so we create this signature onion each signature validates all they nested signatures underneath it so we sign at multiple levels we also have cypher diversity so you can sign with ECC RSA any ciphers that you want to support it's very flexible platform up at the top so these cripples we'll talk about them a little bit later you can write them in dot Java today or native but will support any sort of platforms we're agnostic what you want to do you it'll be open so that you can port your own runtime and create your own container that runs in this platform above the layer we're using standard AMQP if you're not familiar with that that's a iso standard for for messaging that's used in the enterprise so we're using AMQP is the basic interface and those messages the strongly typed messages are what are being passed back and forth so you define your API with their types and your messages you can stick a rest or an RPC on top of that message AMQP very simply and easily or you can just serialize your messages to json which is the default so it's a very open platform very easy to integrate into any front-end application or any existing application a couple of things that you should note about this if you the cripples are running above the law chain they can run in a singleton pattern you can also reach out 'its can communicate with each other so we talked about watching Oracle's you can certainly write a blockchain Oracle here and write attested data to an 80 underlying blockchain if you're thinking about writing an Oracle and you're concerned if you know how do I support Moulton block chains this is one way for you to do that to write your Oracle once and support many different block chains but you can also do Oracle services directly from crippling to it so you can have a utility it which is what we usually call an Oracle can do more than that actually pass a tested data to another that's running at a contract we have three basic 'its you have your utility it's those are the ones that can provide a tested data but you can also connect to an ERP system you could react to some sort of event that happens in the outside world very easily and then that utility Griphook can then communicate with what we call a contract triplet which represents your typical smart contract or Enterprise smart contract so what we call it but we also have a token grip what as well the spirit of this conference which essentially is a contract triplet with token behaviors exposed as well and it allows you to create these types of scenarios so the toca Chrome for example is very interesting if you create a token the it actually controls all the ERC twenty sort of functions so the the issue the transfer the burn the menteng all that stuff it's controlled through the in itself but then I can extend the behavior so I can add behavior for my token and off chain and that can also assume the identity and use the identity of the person that has a balance for that token so you do some very interesting things with this platform as well so we're not really sure what we're customers gonna do but the interesting thing is you can do attack Riblet go up on the outside and then also you can create your proxy you can have it monitor events of the local watch chain and react to them as well in the outside world so how do you get started a lot of people asked we've been talking about this for some time when do I get to see code when do i when can i play with this well we tried to get this done before the show we're gonna come out and say hey it's open here go run this go this URL and you can get a test drive but we couldn't pull that off in time but as soon within the next hope two weeks we'll be able to have an environment where you can go out and do a test drive where you couldn't stand up this environment and you can build an enterprise smart contract and 'its from scratch to start learning and this platform is currently and what we call early adopter or private early adopter preview private preview which we're going into a regular cadence I'll talk about that in a little bit but if you're building these things essentially all you have to do the infrastructure is built for you and abstracted from me so as you would expect you simply focus on what you're trying to do the first thing you always will we'll talk about us you know contract first development so you will develop your message types so you define your message types and you can pick your language and donors job and this is what it looks like pretty simple getters and setters or the base properties this is in c-sharp we're inheriting this is the token Crippler inherits from the base token and then it has constructor messages create token that derives from the base token constructor and we have you know like return types now here you can see others we can have time I'll switch over and chase them some more of the code but this is example of that the types that you'll do see really simple types that serialize to JSON so you just kind of pay attention to that you really the framework takes care of this they're all at serialization for you so standardized if you ever done cross-platform serialization with JSON it's not as smooth as it always seems it should be but we've taken care of that for you next you then write your equipment code utility contractor token depending what you're writing you'll derive from you always drive for the basic Riblet class here so this is the typical then you implement the interfaces there's a contract to put in the face by default a token it is a contract triplet you cannot be a token without being a contract and that has to do with the isolation level that the code runs in whereas a utility it can be multi-tenant so I can have multiple subscribers to an oracle type service a contract can only have one binding and what we called us essentially a binding each instance of that same binding gets a new instance of a that's either running in a full-on cleaved environment or a partial on cleaved environment with Krypton delegate so crippled at basic constructors this is where we construct its API it's can be inspected by simply passing a real simple message and the framework and saying tell me about the it's you have registered and you can pick one let's say tell me what your API is what that means is it's going to take care of its functions these are these message types I defined as the types when I say these all serialize automatically to JSON so when I query it it's gonna serialize all these things here my functions with their JSON structure and here are my returns with so you know exactly how to communicate with it so you can construct your own libraries or we can provide you a jar file or a DLL for you to work with those types very simple stuff then last thing you need to generate your proxy so this is where the we're tooling comes into play so we're doing a lot of work around the tooling so we'll generate as much of the proxy as possible for you so there's two types of ways to generate object models that get some sort of underlying data structure you can do a what we call data first that's where you've established the database like a sequel database or whatever or solidity in this case and then I can use that to then create a proxy from that structure so meaning I already have my solidity defined I can then generate a proxy now usually when you're writing your solidity for enterprise smart contractor you only want to put the logic down them it makes sense to put down in your enterprise smart card excuse me in your smart contract so you want to do things that that if you're transitioning assets or changing ownership for assets that are Providence on that blockchain then you want to do that and perform that logic on the in your solidity code there's lots of nuances there but it sensible will generate the proxy first code first is where you have the type system that you defined and will then create the solidity for you but you do some basic customizations these proxies can be written in any platform as well this is using the theorem so the theorem team the guys that consensus are doing a lot of work for generating the proxies for this platform and we expect each of the major platform providers and anyone will be able to take the standard interface which has an initialize function and execute async function that's it and you can plug it into the router it just works so again today we're supporting net JVM and native we'll listen to our customers if you have a particular one time you're interested in there's enough and we'll do the workhorse it'll be open so that you will be able to create your own and port over there we're gonna do rich tool in Visual Studio Visual Studio code as well will you'll see that and the test-drive when you start to play with it in a couple weeks so follow ups I'm out of time here come by our booth we're just outside the door here well doing demos you can go more in depth in code you get hands-on the hands-on labs actually see what it looks like watch for the the test-drive coming out in a couple of weeks they don't include the hands-on labs the extensions and the sample source will be released at the same time so you if you if your code is not working and go look at the finished code to see what's what you've done wrong and then I will be transitioning from public from private preview to more public previews in the coming months [Applause] [Music]
