New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Fhenix 🛠 Learn all about FHE and Fhenix

ETHGlobalWed, Oct 9, 2024, 12:00 AM

Join Fhenix team on learning all about Fully Homomorphic Encryption (FHE) and Fhenix! Embark on a journey with ETHGlobal London, where innovation thrives, collaboration knows no bounds, and hierarchies fade into self-sovereign ownership. The most skilled web3 developers, designers and product builders from all around the globe come together for a weekend-long adventure to advance the Ethereum ecosystem at ETHGlobal London in March of 2024! ----------------- Follow us: https://x.com/ethglobal Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

[Music] hello thank you for uh checking out Phoenix we be we're we're sponsoring um a 5k Bounty so please um pay attention to this workshop and if you have any questions feel free to message me directly um we're going to have documentation any everywhere so if you want to kind of pause the video um to get some of the QR codes or the links um feel free to um but yeah other than that let's just get started um so what is Phoenix exactly so we're basically building an L2 um we're trying to add the ability for developers to uh add FHA operations to their smart contracts directly via FHA um and so we're the first blockchain to to support General fhe um real quickly before we dive into everything here's a quick cheat sheet um feel free to pause the video take a take it take a um go to this link um it'll basically set you up with all the good um tutorials and documentations that you'll need to work with the network it's pretty comprehensive uh but if you run into anything specifically feel free to reach out to me there's also like I said YouTube videos I will go over and walk through you uh walk through the step step by step um so is FHA fhe stands for fully homomorphic encryption which is kind of a fancy name for being able to run arithmetic Expressions over an encrypted field or operations over Cipher text or basically you can kind of think about it as I like to think about it as doing some sort of operations computation logic um without having to decrypt something so so basically you can um change the state of a network without revealing how the network has been updated um so homomorphic encryption is basically do some stuff on encrypted data basically what you do to a should happen to B there should be some sort of relation there hence the homomorphic um and fully homomorphic encryption is basically being able to do multiple operations over and over and over again um so arbitrary computation technically speaking um so I in a way that like um homomorphic encryption uses this thing called encryption which means you you're adding noise to kind of hide or encrypt um the the state of your plane text to make it private um and in order to do this you um need to run multiple operations in order to achieve a more complex State however the noise will compound um and hence we have this process called bootstrapping but in anyways that's a little bit more technical than is really necessary so I'm sure most of you are familiar with fhe versus zkp um so zks are the more common way of adding privacy or at least that's the narrative security um an encrypted state in in web 3 right now however FHA is kind of adding another element to this while zks are mostly good for point of attestation privacy it's kind of difficult to create a composable state um since that the state isn't really stored on chain interacting with these things um these different states usually require some sort of decryption so you know if you go to your favorite ZK privacy Network and you try to figure out how to run um a query on an encrypted field you know if you want to sort if you want to look at the IDS if you want to um drill into something have more complex logic it's very difficult um to do that because you can't really um run operations without decrypting but once you decrypt you leak everything to plain text and that kind of defeats the purpose of an encrypted Network um as you can see FHA currently has scalability issues um it is slow to some degree um slower than most operations however this is um rapidly evolving almost by the week and and throughput is increasing like you almost won't believe um composability also great with FHA um as we'll go on a little bit later but basically you know um allowing you to add an encrypted space to your uh solidity contracts or your or your contract state if you would is kind of this new novel introduction that Phoenix is bringing and again this is completely on Chain versus like where ZK mostly you're doing some of the private ZK stuff offchain are using more of a complex like system of different polls and levers if you would um and then you're just kind of submitting the proof on chain so that's the nice thing about FHA is it's more in kind the ethos of what blockchain stands for in terms of onchain operations um so real quickly a contract import we're not trying to reinvent the wheel here we want to make it as simple as possible for you guys to pick up um what we're trying to do um so basically if you just import fhe as you see up here um you can kind of just interact it interact with um with our library on your smart contract so you don't have to pick up a new language you can use the tools that you're familiar with um speaking of tools that you're familiar with I'm sure a lot of you are familiar with um hard hat so if you would like to use hard hat um we have a tutorial that will show you how to set up a local instance um on your machine and so this is probably the ideal way to do tests or to script out your tests um if you want to build uh more complex applications but there's also a remix plugin for those of you that are more familiar with remix I personally like remix because I'm a little bit more of a visual learner and I think this helps me kind of figure out what I need to pass in what I need to see what's actually happening with the contract in terms of interaction um and like I said so for both of these um we have tutorial videos I will walk you through step by step how to get set up uh if you get stuck anywhere feel free to message me um I'll try to help unblock you um so real quickly inputs I'm sure most of you are familiar with just passing in some sort of uint 32 uint 8 uint 256 for example which you know represents a number in your contract um however um with FG we're doing this thing called euin so it's basically just an encrypted unsigned integer uh of 8 bit length and there's 16 bit there's 32-bit larger bits uh bit integers will be um added in the future but basically um this is the form of a large Cipher text instead of an integer and what is a cipher text well not to get over complicated but a cipher Tex is basically just really long hash it's it's just a hash string um very similar to like a normal hash that you would see um and and basically what we're doing here is that we're passing in this number and then we're setting this number as an encrypted integer and then we're applying that logic as we're going on if you want more specific examples we have examples on our GitHub um and our docs but basically here there's are two ways that you can pass it in one is more of a typ casted version the first version where you see set output and then s output bites is General bite code that you can also pass in depending on your use case um so conditional logic does get a little tricky with FHA I'm going to skip over this slide here because there's a better one after but essentially you could see that the first example that we have right here using the if else um which is how we're kind of taught naturally naturally conditioned a software Engineers to to kind of write our conditional logic this way however um fhe is a bit like constant time code which means you uh want to have a single path to avoid branching because branching gets a little sticky with fhe um due to well the way I feel it is due to the deterministic nature of of what the cipher text is it doesn't necessarily Branch it's it's the value is already kind of set um so as you can see this is sort of a bad example the one that pointed on the left where if a uh if a is less than b um versus the probably the better way to do it is do this uh less than so LT is an operation and if you want more specifics on that all the operations that will exist on our docs um but essentially we're using a selector function here and the selector fun uh function for those of you might that might be more familiar with the fhm's version of the multiplexer the seu um basically you're taking an encrypted Boolean here is less than and then it's running down the path of A or B so it's going to assign a or it's going to assign B um to this EU in8 to return value if that makes sense it um there again there will be more um documentation on our docs and if you have any specific questions I would definitely recommend checking out sample contracts or messaging me directly um required statements are are relatively straightforward so they have to be slightly different than they exist in current solidity require um just due to the fact that uh if you want to um if if you want to continue to um you know you want your contract to be able to revert without necessarily having to reveal the contents of that function FH requires a great way to do it um conversion leakage so conversion leakage is very important when we're talking about security so I like to think about it that the two main things that we really want to avoid are decryption and leaking plain text to memory and if you don't decrypt then you avoid leaking PL text to memory um so basically if it existed somewhere there is a trace of it right so and here's a really quick example right so if you think about how the contract state is transitioning from state for state the initial thing that happens here is you're passing in an unencrypted integer value right and even though you do encrypt the integer value and proceed however you need to with the rest of your state if you were to look back at this initial State transition you would see that this unencrypted value was passed in so this is what I like to call conversion leakage um or or just I guess data leakage in general um and so if you would like plain text leakage if you would um you know I think this is something that's very important to remain cognizant of if you want to create secure applications um so from a high level what is fhos so at Phoenix here at Phoenix we're um we're basically um trying to build a comprehensive um Suite of of encryption products so um the fhos is currently a wrapper around the tfhe ERS Library which is maintained by Z which handles a lot of the FHA operations if you want more um information about that uh it'll be in the docs um and some of the differences between FHM and what we're trying to do here but again this uh the underlying library is composable such as it interacts with a threshold service network uh threshold service network is kind of like a multi-party key management Network which handles the threshold decryption um in the future Oracle will be called um from there Etc but I'll avoid going too deep into that if you want more specific information please check out the white paper um but from a high level this is kind of what we're trying to build and then um we have this thing called Phoenix JS implementation it's basically a JavaScript library that you can import into your client that will allow you to easier interact with the ABI so for example as you can see we were passing in Cipher text values so if you wanted to pass in a cipher text value five for example here's a quick example um also there are docs for how to handle permissions which is speaking of permissions what exactly are permissions so permissions are basically if you have an encrypted field and you want um to be able to view the encrypted field or you want other people to view the encrypted field this is how you do permissions I like to think of a really simple example as FHA poker right if we have our cards and we're playing I want to see what my two cards are so that I know how to play my hand and um but I don't want you to be able to view what my cards are and vice versa um so this is basically the way that you can do it and from a high level permissions are basically you can think about as an extension of EIP 712 um but in practice as you can see here we're pack we're passing in um the permissions object and we kind of have this modifier called only sender here which basically um checks to see if the uh message. sender basically the person who's actually calling this function has the correct key access to view the contents that they're trying to view um and so here's an example permissions it's very dynamically programmable so you can really set up the conditional logic however you want quick example is how an erc20 will an address that Ma to maps to an encrypted integer value that represents the amount of tokens that um uh you know a certain address owns um again here's a really quick sample contract um not too crazy if you want to import permissions there's documentation for that but as you can see we're not inventing Reinventing the wheel here like I said we're really trying to make it so that solidity developers um can pick this up as as frictionlessly as possible um you know basically think of it as like superpow functions that you can add to your current solidity developer Suite without having to completely change everything that you're doing um and so come winner hackathon we want you we want to see what you guys can build we think this is a great Frontier um yeah obviously just submit your gi gi Hub repo and um preference will be shown to projects that are able to integrate the complete Phenix stack which um does incre uh which does include a front end ABI integration ideally hosting um the whole nine yards um so General runtime tip tips if you guys want to see the specific operations I would definitely check out the docs but there's two main things to remain cognizant of when you're building with FHA um first of all is the operations themselves as you can see here addition operations are much simpler and less computationally expensive than something like a division operation um and so the actual type of function that you're calling is very important um and the other thing is the actual integer size right so if you're using an 8bit integer versus a 32-bit integer this going to have huge ramifications for the actual um um runtime so definitely make sure that you are cognizant of that and here's a pro tip for one of our developers core developers uh you know try using chat GPT it might be more helpful than you would think um you know if you pass in an example and then you try being like hey you know you pass in some of our example contracts and be like hey in this format if I was trying to make a voting contract how would I do it it might not give you the exact thing that you're looking for but it might kind of help you point in the right direction or at least some sort of structure um and yeah that's pretty much it if you want um you know if you want uh a more codal example um of to do one of our developers also set up a blind auction contract which is really good to kind of get a high level overview of sort of the nuances of building with FHA on Phoenix um and yeah so my name is Kyle again and if you uh do want to reach out to me my contact information is up here um so please don't hesitate to reach out and if you want to get started on these docs ahead of London um please let me know thank you very [Music] much

Automatic transcript — names and jargon may be misspelled.