Nillion 🛠️ Build an app with Blind Computation with the Nillion SDK
ETHGlobal·Wed, Oct 9, 2024, 12:00 AM
Join Andrei and Steph on this workshop and learn all about building an app with Blind Computation using the Nillion SDK. Nillion is new internet infrastructure for the private storage, computation and decentralization of data. Learn about the Nillion MPC network and get started building your first Nada function to perform blind computation of the Millionaires Problem. As new users flock to web3, critical infrastructure advancements are needed to scale. Join us April 5th-26th for three weeks of hacking and summits around shaping the future of Ethereum. ----------------- Follow us: https://x.com/ETHGlobal?s=20 Check us out: https://ethglobal.com/ Email us at: hello@ethglobal.com
Transcript
[Music] hello everybody my name is Andre and I'm the VP of engineering at neon today I'm really excited to tell you about the SDK we are releasing just in time for the scaling ethereum hackathon nilon is a new internet infrastructure for the private storage computation and decentralization of data it is a decentral decentralized network but not a block chain that utilizes a novel mathematical Innovation called Neil message compute or nmc in short it represents a generational leap in technology from a predecessor technology known as secure multiparty computation or MPC unlike blockchain Network nodes do not run immutable ledgers designed to store transaction data and unlike MPC nodes do not have to communicate with one another when performing computation the resulting new technology of opens up a unique decentralized uh set of use cases and it can also be used to enhance many of the most widely used blockchains however please note that nean still uses blockchain as payments and coordination there now let's double click a bit on the blockchain statement um and explore why nean is important for the ethereum ecosystem as all of you know blockchains are great at decentralizing trust however the prohibitive costs of storing large amounts of data as well as the transparency they offer as a public Ledger technology prevents them from being applied to a lot of use cases especially ones where privacy is very important in light of these limitations nean intends to augment ethereum not compete with it in order to unlock new opportunities by enabling the creation of private dexes private rollups private order books and cross-chain trading execution uh um and also private voting for Dows and one of my favorites which is private cross chain non-custodial Key Management at the same time it can be used for new decentral uh decentralized use cases such as secure password storage biometric uh document signing and uh kyc AML secure logging and even all the way to um privacy respectful personal AI agents scaling ethereum is the perfect opportunity for us uh in fact to put our technology in the hands of the ethereum community in order to help them unlock all those privacy enabled use cases it also marks a shift in our approach from a traditional working behind closed doors to embracing open source philosophy and building together with you our wonderful Community this in fact is a significant commitment on our part because we want to hear what you have to say and to use that feedback to guide the evolution of our technology let's take a quick look at the road map and the vision for this project real technology breakthroughs are quite rare in our community which makes it very challenging to plan the future still we want to make sure that we are predictive enough in what we release and when we release so that other projects will trust us to build real applications for their user there are two major road maps that happen in parallel the first one is for the neon technology and here the SDK release marks the first important Milestone giving the community access to our developer preview version of our technology and also inviting the community to come build this technology together with us the SDK comes with a local computation Network and abstracted payment solution so developers can focus exclusively on building applications um next after the SDK release we'll go through a period of continuous improvements to the SDK after which we are planning to release a public test net followed by a May net soon after the second road map uh is about our path to going full open source although we are releasing the asdk binaries right now the plan is to slowly start open- sourcing the client libraries followed by the actual Network nodes so that by the end of the year we can become fully open source having talked about uh the SDK and the road map let's take a quick look at what will be available today in the SDK so the main feature that we are shipping the SDK with is the ability to store and retrieve Secrets this means that users can store and retrieve intage and blobs using the local network that is provided through the SDK and can also Grant permissions to other users and programs to compute on their secrets or to access them the second most important uh or equally important uh feature is blind computation basically users will be able to compute functions uh on integers using any combination of the following operations uh such as addition subtraction multiplication and division eal statements U reveal operations and modu and we are also shipping an experimental feature um that allows you to use um arrays uh basically zip unzip uh map and reduce operations on Ras uh that being said let's take a quick look at the nean architecture and how the network uh works so NE technology is based on a new mathematical Innovation called NE message compute or nmc in short which allows nodes in a permissionless decentralized network to compute information in a secure way without really having to send messages to each other during this computation unlike blockchain Network nodes are not primarily tasked with storing transaction data on an immutable Ledger instead the node's purpose is to perform secure computation in a verifiable fault tolerant and decentralized matter nmc takes arbitrary data it transforms particules it shreds it basically it splits it and then distributes the resulting particles across a network of nodes the nodes can store and run computation on those particles and then return the result to the desired end point for reconstruction the nodes are actually blind to whatever they're Computing and yet they are able to compute at near client server speed due to the lack of inter node messaging which is unique to nmc using a verifiable secret sharing mechanism on the output uh ensures the correct reconstruction of the results uh in the even in the presence of faults now nmc solves the scalability issues uh which is specific to traditional uh secure multiparty computation which is that uh in a secure multiparty computation nodes must exchange information to compute outputs which could be really really slow to give you an example when calculating 1 million um multiplications for instance um secure multiparty computation uh technology would take upwards of 20 28 hours um with nmc nodes do not really have to exchange information messages uh when they process data and instead they uh are running computation locally at nearly plain text or client server speeds which basically makes nmc about a billion times faster than U secure multiparty computation in such a scenario let's take a look at the Practical example now the nmc network consists of an input interface uh what we call dealer nodes or and individual users through which data provided by the user um gets transformed with blinding factors that were produced by the nmc nodes and the data becomes um unrecognizable once that data is transformed basically it is masked with the blinding factors produced by the NFC nodes then it is stored in the nean network no nmc node at this point can recognize who owns the data data and what the data that they store actually is for instance if a user wanted to store their password like in this example um the password would be transformed into a random sequence of numbers such that the NFC nodes in the network couldn't really make sense of it it doesn't mean anything uh to them now if a user wants to change or use the data stored in the network for a particular purpose purpose they can instruct the nmc nodes to process the data once the nodes have completed the task they send the output to the resulting nodes for instance if a user wanted to use their password to sign a document nodes would then sign the document with the users's uh password without knowing for whom and what they're working on the result uh nodes then run nmc's reconstruction mechanism to obtain the real output which is the unmasked output the sign document using the output from the NFC nodes and the masking factors that initially transform the data now the result nodes have obtained the output without having had any insight into the input uh initially provided by the dealer nodes in this step there will be a lot more information on blog posts if you're interested in um how everything works on a technical level so please take a look at those resources now let's get to the fun part um we are offering 55,000 umll in prices for building on neon basically uh we're splitting $3,000 to uh Noble use cases of blind computation uh maybe one or two winning projects um and like if you're looking for few ideas as to what you could build then um you could try to implement a secure voting system for dos you could try to implement blind auctions secure order books uh or even maybe some games U next we are giving $2,000 to the best application that is integrating nean Tech and this will be just one project and here we're looking for developers who are willing to integrate nean secure store retrieve and or compute functionality into an app and optimizing it for really great ux we will also provide uh qualification requirements shortly next I would like to invite staff to walk you through a concrete example of uh blind computation on million with uh an example which is called the millionaires program thank you all and have fun bye hi hey devs I'm steper pilia developer relations lead at Nan and today I'm going to show you how to solve the millionaires problem using blind computation on million the Millionaire's problem is a classic MPC scenario where a group of really rich people want to figure out which one of them is the richest without giving up their actual numbers or net worth we're going to imagine a very similar scenario where three friends Alice Bob and Charlie are all at lunch and have just finished the bill comes and they decide that the friend with the highest salary should pay the bill Alice makes 10,000 Bob makes 8,000 and Charlie makes 12,000 so we know that Charlie should pay the bill but Alice suggests that this is the perfect opportunity to use million for blind computation so all three friends can input their salaries as secret integers to million and then they can run a blind computation function to figure out which one should pay without ever having to reveal their actual salaries so that's what we're going to build today and we'll take a three-step approach to solving this the first thing we'll do is store the millionaires program on the network then each friend will store their salaries as secrets with bindings and permissions so that Alice has permission to actually use those secret integers in the program that she's written last Alice will run blind computation to compare the three salaries and show will reveal the output and that will decide who has to pay for lunch so all of this code is actually in an open source repo and you can find it really easily by going to the nilon docs docs. million.com um scroll down to developer quick start which is in the side panel and you'll see something called million python starter this is a big repo of code with lots of different examples um that you can run and use we have multi-party examples single party computing examples permissions examples how to store and retrieve Secrets all of those different things um but clone this repo locally and then run through the read me to set everything up so install your CLI dependencies set up your environment um and bootstrap your local environment so that you have all of the environment variables accessible that you'll need to run the examples when you've done all that go to the millionaires problem example folder this will will get us started and this also notes that you need to have set up already I'm not going to run through this step because I already have a setup but I'll go straight into the examples so let me pull up my code and go to this folder so as you can see I'm in the millionaires program folder here and let's go to the read me to get started so as we were just saying in our version of the millionaires problem the three friends are going to finish lunch and figure out who should pay so we'll take a three-step approach and let's get into step one where Alice creates and stores the program in the network so I actually have a little mirror visualization of this too so here's step one Alice creates and stores the program in the network and then she also needs to share her user ID and the resulting program ID with Bob and Charlie so let's get into how Alice creates and stores that program this is step one so go to the 01 store secret code in this function Alice is taking a program she already created called millionaires um and the full millionaires program uh is actually in the programs folder so I'm just going to go to programm millionaires so that we can take a look this is the NADA program that Alice wrote to um perform the blind computation so so there's three different parties there's Alice there's Bob and there's Charlie and each of these parties is providing a secret integer input and that is their salary so Alice is providing Alice salary Bob is providing Bob's salary and Charlie is providing Charlie salary those need to be in the network um or provided at compute time so that this function can run with those three inputs so that's the setup for this and lines 12 through 16 or 17 are where the bulk of the logic for this program is happening so we're trying to figure out which of the three friends has the largest position or largest salary so on line 13 we're comparing Alice's salary to Bob's salary and this is just a little if else so if Alice's salary is larger than Bob's salary you enter the second line um which is comparing Alice's salary to Charlie's salary so if Alice's salary is bigger than Bob's and bigger than Charlie's we return integer zero which means that party zero has the largest salary otherwise if hers is bigger than Bob's uh but smaller than Charlie's that means Charlie has the biggest salary so return integer two if Bob's salary is bigger than Alice's salary go down to this line and compare Bob's to Charlie's if Bob's is larger uh will return integer one meaning Bob has the highest salary otherwise return two because Charlie would have the largest Sal salary in that case and so largest position is output to the output party which in this case is Alice so Alice is the person who is running this line computation function and based on this last line for output Alice is the party that will also be able to read the result of this computation which is returned here okay so that's our NADA program now we need Alice to store this program in the network during step one so this is just a little bit of setup we're creating a python client for Alice the program name is Millionaires and Alice has compiled this program um to a folder or to a file rather and that file is accessible here it's just the NADA binaries for the compiled program millionaires program that we just looked at so this is how Alice stores the program in the network uh she stores the program here providing the cluster ID the program name and the path to that compiled binary code and we also remember need to share Alice's user ID and the program ID with Bob and Charlie so that they can do the next step which is storing their secrets so we're just going to print those out um and then when we run step two we're passing in Alice's user ID and the program ID so that Bob and Charlie know that for the next step so let's run step one one uh from the command line this is the wrong terminal here we are so we're in millionaires problem example I'm going to run Python 3 and then step one okay so you can see a couple things happened Alice stored the program in the network the millionaires program this is the program ID um and the convention for this is the user ID that stored the program so this is Alice's user ID slm Millionaires and Alice is telling Bob and Charlie her user ID which is this first half of the string before Millionaires and the Millionaire's program ID which is this piece so the next thing we'll do is copy and run step two um you can see that user ID is that string and then the program ID is that full string slm millionaires so before that let's look at the logic for step two we just finished step one step two is to have Bob and Charlie each store their salaries in the network as secrets and as Bob and Charlie store these secrets they're doing two special things they're adding bindings and they're also adding permissions so the bindings bind the secret to the Millionaire's program ID and that's saying that the specific program ID is allowed to use uh the secret and then the permissions um is allowing Alice to be the one to compute using the secret so let's go to the code for step two again step two is where Bob and Charlie store their salaries in the network so this is looping through any parties that are in this config parties um I'm just going to show you the config quickly so the config part end parties is just Bob and Charlie's information so each of them has a user key and a node key you can see the party names are Bob and Charlie the secret names that they're using are Bob salary and Charlie salary and the values are 8,000 and 12,000 and these all correspond to what we had in the millionaires program for um Bob's salary Charlie salary and then the names of the parties so that's why that's important they all have to match up um so that the program knows what to expect so we're getting uh the party names and the party IDs and then each of them is creating the secret that they're stor in the network so the secret value again is coming from that config so Bob's value was 8,000 and Charlie's was 12,000 and then this is where we're starting to create the secret Bings so the secret bindings are specific to the program so we're adding in the program ID so that the bindings are bound to the specific program ID then we're adding the party this specifies who is the input party that will provide um the secret to the program and so for Bob's secret the input party is Bob and for Charlie's secret the input party is Charlie and we'll print that out just to see it on the command line next we need to create permissions so this permissions the secret and says who's allowed to use the secret so maybe who's allowed to view it or update it in this case we're setting compute permissions so we're saying a spefic specific user ID um is allowed to use it in a specific program ID but only if they're Computing so they can't read it or see it all they can do is compute using it which is why this is a really cool example of blind computation Alice is given permissions to compute using these secret salaries but she'll never be able to see them and so that's why we're assigning Alice's user ID compute permissions for the millionaires program and last but not least we're doing the actual store Secrets operation this takes in the cluster ID all of those secret bindings the stored secrets and permissions so that secret is stored with all of those things and is bound to a program and is permissioned for Alice and then we're passing the the program ID and each of the store IDs which is where the secret lives in the network to Alice um so that she can run step three but let's go back to the terminal and we'll run step two in step one we printed out the command to pass into step two um you could also kind of manually type through this command if you uh had console logged or something the user ID and the program ID but just for ease of use feel free to copy the command from the previous step so two things happened here Bob stored his secret and Charlie stored his secret and you can see the bindings and the compute permissions for each uh friend Bob and Charlie so Bob stored the salary of 8,000 at this specific store ID Charlie stored the salary of 12,000 at this other store ID and now we'll pass the storyes to Alice so that she can compute using these storyes um without seeing the salaries so Alice will use these in step three let's look at step three quickly okay so in step three Alice runs the millionaires program computation using those secret salary store IDs and she'll also provide her own salary as a secret at computation time Alice could have stored her salary in the network ahead of time but since she's running the computation anyway she'll just provide it at computation time and then she'll also receive the output of the program and she'll be able to let the friends know who should pay for lunch so let's go to step three in the code okay so here Alice is initializing her client and getting her party ID and she's creating the computation bindings which are slightly different than the secret Bindings that were previously created when storing Secrets uh so computation bindings add all of the different input parties remember there were three input parties in the millionaires program there were these were the three input parties they were Alice Bob and Charlie so all three of these need to be added as program bindings so this is the first input party we're adding Alice and then let's ignore the compute party just for now this is how we're adding Bob and Charlie as input parties we're just looping through um each of the additional parties and adding them as input parties here and the output party is Alice and that's because if we come back to this program we designated that Alice will be the one to receive the output so those are all of the different bindings the input parties and the output parties and then the next thing is that Alice will provide her computation time secret so she's going to provide her salary uh directly to the computation rather than having stored it before so she's just passing in that secret value and providing her computation time secret now that we have all of those different things we can create the actual compute function so compute takes in cluster ID compute bindings which are all those input and output parties um as well as any store IDs which is where those previous Secrets live in the network so Bob and Charlie have given Alice their store IDs to use and then the computation time Secrets which are just Alice's secrets that's Alice's secret salary that she's also passing into the computation in this situation there's no public variables but if you had any for your computation you would just add them in here and finally this is where the magic happens we compute and print the result so if you remember from the millionaires program we're not printing the name of the person paying for lunch we're printing the index so either index zero which corresponds to Alec Alice one to Bob or two to Charlie so this is just doing a little bit um of mapping to the name so it's taking all of the input parties um and mapping to the name so this will print out who should pay for lunch let's run step three and figure out who should pay oops so step two printed out this python command for step three again it's just giving you all of those inputs from the previous step for ease of use copy that and paste it into the command line you can see Alice is providing her salary as a computation time secret and this is now running the computation it was sent to the network this is the compute ID for this program and compute is complete the output result is position two and so the richest friend is Charlie and Charlie should be the one who pays for lunch all right we did so many things we learned how to store and retrieve Secrets add program and secret bindings um add compute permissions and actually compute and for kind of next steps or if you want to do more I encourage you to go to the nilon documentation and do some reading at the very end of the quick start you see places to keep exploring you can check out um more examples in all of these different permissions single and multi multi-party compute folders um and then learn about more of the concepts and the na L Frameworks um I would love to see what you think of this video and what you think of neillian feel free to post on our Forum check out our open-source code on GitHub we've got lots of different repos and I hope to see something that you build in the next hackathon thank you so much for watching and have a great [Music] day
Automatic transcript — names and jargon may be misspelled.