Okay, hello. I'm Nikos. I'm a cryptography researcher at Fireblocks. This is Oren. He's a security researcher at Fireblocks. And we're here to talk about hacking crypto wallets. So what is a crypto wallet? So let's say you want to spend Bitcoin. You need a wallet. That wallet holds a key. That key allows you to sign transactions. Those transactions you can broadcast to the blockchain and send crypto to your favorite people. There is a problem with the setup because there is a single point of failure. The key is sitting in one place, ready to be stolen. How can you minimize that risk? You can use multi-party computation. Also known as MPC. So what is MPC? So at a very high level, the idea is that instead of having one key in one place, the key is split into shares. And those shares reside with different parties. Actually, MPC promises much more than what the picture suggests. Because the key is never assembled in one place. The parties calculate their shares. And the parties calculate their shares. And the public key via an interactive protocol. And then every time they want to sign a transaction, they run a different interactive protocol for calculating the signature. So small aside, MPC is much bigger than the use case I just described, which is threshold signatures. It is the crown jewel of modern cryptography. Basically, anything you can do with a trusted centralized party, you can do trustlessly. With MPC. There are numerous examples. I'm not going to go into them. But what I will say is that commercial adoption has been a bit slow. MPC has been around since the 80s. And the most significant use case before blockchain was the famous Danish sugar beet auction of 2008. And since the advent of blockchain, MPC is now protecting billions of dollars in cryptocurrency wallets. But we're not here to talk about MPC in itself. We're here to hack crypto wallets that are based on MPC. So what would that look like? One thing that could happen is a denial of service. Let's say I'm able to freeze your wallet so you can't spend your crypto. That's a problem. Something more severe would be signature forgery. Let's say Nikos and I, we have an MPC wallet. So every time we want to sign, we sign together. So I tell him, let's sign this $10 transaction to your favorite charity. He signs it. But because I took advantage of some flaw in the protocol, I actually made him sign a totally different transaction without him knowing. That's bad. But what's even worse would be private key exfiltration. Whereas by him signing that transaction, he leaked his key share to me. And now I can sign whatever I want, whenever I want, without his consent. Today's talk will be focused on this. We're actually going to show you three different attacks that all end with private key exfiltration. When will we be talking about attacking crypto? When will we be talking about attacking crypto wallets? MPC crypto wallets. I want you to have this threat model in mind. So these are a bunch of people participating with an MPC wallet together. So each time they want to sign, they need to collaborate. Now, one of those participants, namely Alice, will be acting maliciously. Now, either she woke up one day, decided to be evil, or maybe she was compromised by an attacker and now is using her identity to attack the other people. So whatever her motivation might be. She wakes up in the morning. Her only goal would be to exfiltrate the other counterparty's key shares. And she will do that by signing normal looking transactions with them. So the research findings that brought us here today were as follows. We have discovered four novel attacks, including three zero days. These findings have affected over 16 different vendors and our open source libraries. We'll be releasing at the last slide four fully working proof of concept exploits for these attacks. We'll be showing you. We actually used the very same proof of concept exploits against two vendor production environments and got the private keys. And the last thing I want to stress is most of our attacks are not implementation specific. We'll be attacking MPC at the protocol level. So the affected parties were numerous. Some of the biggest crypto wallets were affected. A number of crypto custodians were affected. The most popular consumer MPC wallet was affected. As well as some of the most popular open source MPC libraries. The attacks we'll be covering today. We'll start with attacking the most popular two party signing protocol. It's called Lindel 17. Carrying out the attack will be somewhat high interactivity required. Then we'll go to a second attack. We'll attack the most popular multi-party signing protocols. The GG 18, GG 20 family of protocols. And last but not least. We'll attack what we call a do it yourself protocol. Because it doesn't really closely adhere to any academic paper. Okay. So before we have a look at the exploits. We need a few items of background material. The first item in the background is the math. Thankfully no math. I mean no advanced math. The only thing. We're not going to be talking about elliptic curves. Or abstract groups. The only thing you need to know for today. Is the modulo operator. What is the modulo operator? Well very simply. X modulo N is the remainder of X. Divided by N. For example. 5 modulo 5 is 0. Because 5 is divisible by itself. And 6 modulo 5 is 1. Because 6 is greater than 5. And there's overflow. And yada yada yada. Great. Second item in the background. Is homomorphic encryption. This is a cool thing. So what is it? It is a special kind of encryption. That allows computation. On encrypted data. Without decrypting the ciphertext. That's very important to note. So for example. Let's say Alice sends an encryption. Of the number 42 to Bob. So here and throughout the talk. We will be using color coding. Red for values that Alice knows. Blue for values that only Bob knows. So Bob receives this thing. And he can operate on it. For example. He can multiply by the number 2. And he can add the number 100. He does this obliviously. Without knowing what's happening inside the ciphertext. Alice after receiving this. The resulting ciphertext. Can decrypt it. And learn the result. Without ever knowing what Bob exactly did. To the ciphertext. So there are many kinds of homomorphic encryption. I'm not going to dive into them today. But we will be looking at the most vanilla kind. Which is parameterized by a public key. N. This is a number. And it's the product of two big primes. This detail will become relevant. Later in the talk. So the last item in the background. Is the ECDSA signature scheme. This is the most important signature scheme. In the blockchain space. It is used by Bitcoin. It is used by Ethereum. Among other blockchains. And the protocols we'll be looking at. Implement this scheme. So how do you generate an ECDSA signature? It goes something like this. First you sample a random number K. This is a secret. And it is chosen afresh with each signature. It is also called the ephemeral key. Then to calculate the signature. You simply compute a function. Of the message to be signed. The ephemeral key. The private key. As well as an ECDSA constant. That everybody knows. That we denote by L. So that's for one party. What about multi-party? What about two parties? Well the idea that we've already alluded to. At the beginning of the talk. Is that instead of having the secret material residing in one place. The secret material will be split between the parties. Okay. So having covered the background. Now we can move on to our first exploit. We will show you how to compromise the LIDL 17 protocol. Implementations of the LIDL 17 protocol. And in order to explain how to compromise it. I need to tell you what the protocol is. So it goes something like this. So first there's a key generation. Where the parties choose random key shares. So that would be X1 for Alice and X2 for Bob. The next step in the key generation. Is for Bob to encrypt his share. Under a homomorphic scheme that he controls. And he sends that encryption to Alice. So he sends an encryption of X2 to Alice. I will remind you. That only Bob can decrypt this thing. But Alice can operate on it. And this is going to be important for signing. So before we move on. To signing. We need to address the elephant in the room. This is a cryptography talk. So there's going to be formulas involved. But nothing bad is going to happen. Oren will take care of you. Okay so let's have a look at signing. Signing goes something like this. So Alice uses the ciphertext she receives from Bob. During the key generation. To send an encrypted partial signature to Bob. The encrypted partial signature looks something like this. And the only reason I am displaying this formula. Is to show you that we have almost all of the ingredients. For the ECDSA signature scheme. We have the X's. We have the message. We have K1. We have the ECDSA constant L. The only thing that's missing is K2. So how does Bob finalize this thing? So he simply decrypts this value. Multiplies by his contribution to the ephemeral key. And reduces everything modulo L. At this point. He checks whether this thing is a valid signature. Why does he need to do that? Well he does this because you know. Maybe Alice fell asleep while during the signing process. And she forgot to multiply by her K1. At this point. Bob will fail to verify that the signature is valid. And Alice will be notified of this. Either because Bob tells her. Or because the signature never made it to the blockchain. So what happens in this case? Well to answer this question. We consult with the paper the protocol is based on. And the paper has a very interesting instruction. It says any abort will imply no later execution. Which means that if Bob detects an invalid signature. The wallet must be locked. Putting our adversarial hats on. We see this and we think. Well maybe we can leverage this into a denial of service attack. Maybe we can act as Alice. And send some garbage nonsense partial signature to Bob. And now the wallet is supposed to be locked. Right? So we went on to code this. We found some open source implementation. Of the 17. And we tried to do this. To our surprise. Nothing happened. Basically we tried again. And again. And the wallet was never locked. So we were kind of devastated by our failure. To mount some denial of service attack. To the drawing board. We're trying to understand. Wait. If this assumption. This instruction is part of the paper. Why is it there in the first place? So the paper is actually very clear. About why it's important. It says the only problem is. That Alice may send an incorrect partial signature to Bob. In which case. The mere fact that Bob aborts or not. Can leak a single bit. About Bob's private share of the key. Now. Taking it to its logical. Conclusion. We might think of an hypothetical attack. That looks something like this. First Alice would craft. A malicious signature. That would fail to verify. Depending on a single bit of Bob's key share. And then she will see if it verifies or not. Then she can do this again. And again. And again. Every time by seeing if the signature verified successfully. Or not. Knowing if that specific bit is one or zero. Then she can take these signatures later. Bam. She has the entire key share of Bob. She can combine it with her own. And sign away without his consent. So this is very easy. To do in PowerPoint with pictures. But to actually get the math to do this. You need a cryptographer like Nikos. So that's where we stopped relying on the paper. And we had to think for ourselves. And what we did is. We had a long hard look at the partial signature. That Alice sends to Bob. And we tried to mess around with it. We tried to tinker with the X. We tried to tinker with the message. Nothing happened. We tried to tinker with the K. Again nothing happened. But then the crypto gods smiled on us. Because we had the following breakthrough. We realized. That if Alice switches the modulus. So instead of using the L parameter. Of ECDSA. She uses the N public key. Of the homomorphic encryption scheme. These two values are equal. After Bob decrypts. If and only if. X2 modulo K1 is equal to 0. So I will spare you. The mathematical mumbo jumbo. And I will give it to you in a picture. Basically. When Alice switches the modulus. The following thing happens. If the signature is valid. X2 is divisible by K1. And I will remind you. That K1 is the value that Alice controls. And she knows. If the signature is invalid. And this is. This is very good for the attacker. Because this already gives a way. To learn the least significant bit. Why? Because Alice can simply set K1 equals 2. In this case she mounts the attack. She switches the modulus. And she obtains leakage X2 modulo 2. Equals 0 or not. And this is exactly Bob's least significant bit. Okay. So that's one bit. But what about the rest of them? So for the next bit. You can use the next power of 2. Namely 4. When you mount the attack. You obtain leakage whether 4. Whether X2 is divisible by 4. So this is great leakage. If X2 is already divisible by 2. Because if not. Then the leakage that you actually want. Is X2 minus 1 is divisible by 4. And to obtain this leakage. Well what you need to do. Is you need to do some math. You need to massage the algebra. You need to add an offset. To the partial signature. An offset that depends on. Whatever you already know of Bob's key. And this will give you the leakage. That you actually want. So to summarize. In order to exfiltrate the ith bit. You set K to be. The ith power of 2. You offset Alice's partial signature. By a value. That depends on whatever you already know. About Bob's key. And in the end. Depending on whether the signature fails or not. You obtain leakage. The ith bit of Bob's key share. We didn't leave it at this. And we wanted to see if it would actually work. So we went out. We found the most popular open source implementation. Of the Lindel 17 protocol. It was published by Zango. And we tried to see if we could make it work. So this is how the POC looks when it's run. As you can see on the right hand side of the screen. Every signature leaks us a single bit. Of Bob's private key share. Depending on whether the signature failed or not. We know whether it's 1 or 0. We only need to do this 256 times. Now it may sound a lot. But it only takes a couple of minutes. And bit by bit. We leak his entire key. Now we can combine it with our share of the key. And we have the entire private share. We can print it in hexadecimal format. Load it to Metamask or your favorite crypto wallet. And you're done. So we've disclosed this. To all the affected vendors. And they've since mitigated it. How did they do that? Well. They simply followed the paper's specification. So like. After you see that there was a failed signature. Just don't sign again. Now this works. It mitigates the attack. But there are also other ways. That you might want to do it. Where you don't get a possibility of a denial of service attack. And to explain a possible way of doing that. We'll need to introduce a new cryptographic primitive. It's called a zero-knowledge proof. What is a zero-knowledge proof? Basically it's a proof that yields the validity of a statement. And nothing else. So to illustrate with an example. Let's say Alice encrypts some number X. Along with a zero-knowledge proof. That that number is within some range. For example 1 to 42. Now Bob can receive this. And verify the zero-knowledge proof. And be certain that what he has. Is indeed a knowledge proof. He has an encryption of a number between 1 and 42. But he knows nothing else. Only what the zero-knowledge proof wanted him to know. So taking the intuition of this thing. We could maybe add a zero-knowledge proof. To the protocol. In order to make sure that Alice cannot deviate. From calculating the partial signature. In the way the protocol says she needs to do. Well, congratulations. You've learned how to compromise implementations. Of the most popular two-party signing protocol. And also how to mitigate it. And also how to mitigate it. And we're on to our second attack of the day. And we're on to our second attack of the day. Which is attacking the most popular multi-party signing protocol. Meaning it can be two parties, three parties. Or a hundred even. So this has affected many vendors in open source projects. So when we talked about the Lindel 17 protocol. So when we talked about the Lindel 17 protocol. We actually explained how it works. Like start to finish. But the Digi protocols. The thing with them is they're very complicated. They actually. They have seven and nine rounds of communication. So we don't have time to explain all that. And actually we don't even need to. Because the entire thing happens during the very first round. Because the entire thing happens during the very first round. The very first round implements what's called. A multiplication to addition. So let's dive into that. What is it? It's a way to transform two multiplicative shares. K and X. Into two additive shares. Alpha and beta. Where this equation applies. So how does the paper say that you could do that? It says that Alice needs to encrypt. Her multiplicative share K. Along with a zero knowledge proof. For doing just that. And send it over to Bob. Bob now can operate on this. Homomorphically encrypted value. He doesn't know what it is. But he can multiply his multiplicative share. His X. And to make sure that Alice doesn't learn anything about his X. Because that would be terrible. He adds a mask to mask it. Now Alice decrypts this. She gets alpha. Bob gets beta by being equal to minus mask. And as you can see. It so happens that K times X. Is equal to alpha plus beta. There's one very important thing. That we need to know about this. In the case of ECDSA. Where X and K are 256 bits. The mask needs to be sufficiently large. It needs to be bigger than 512. Now why is that? To give an intuition of how this masking works. We're going to use some visualization of small numbers. Let's say. We didn't even use a mask. If Alice would decrypt and get this value. X times K. She knows K. She could just divide it by the K she knows. And get X in the clear. That's why we need that mask. Adding the mask actually works. It masks it. Although she knows K. She doesn't know the mask. So she can't learn anything about Bob's X. But what happens if that's not the case? What happens for example. If K is even larger than the mask itself. In this case. We can see that adding the mask. Actually hides nothing. Like the most significant bits. Leak X in the clear. Now this could be a really great attack. Right? Like we could be Alice. We could choose a really big K. That's larger than the mask. Send it over. Decrypt this. And get everyone's key share in one go. But remember that zero knowledge proof that I mentioned. That she's sending over. Is a zero knowledge proof. That ensures that the number K. Is no bigger than 256 bits. Which kind of foils our entire. Plan of attack here. So we're going to get deeper into. The math of the zero knowledge proof. Hold on tight. How does it look like? Basically it's a bunch of numbers. The number Z is the one that will be focused on. Because that's the one that relates to the range proof. Part of the proof. Now how is Z calculated? It's equal to W. K. Which is the number Alice is trying to prove. Is sufficiently small. Times the hash that depends on W. Now when Bob receives this. He does a bunch of verifications. Over the other parts of the proof. That we're not going to touch on. And he makes sure that Z is small. Now as you can see. If K will be too large. Then Z will not be small enough. It will fail the range proof part of the proof. Now I just want to stress. That Alice has to follow. This specific formula. For calculating Z. Because if she doesn't. Some of the other verifications will fail. So how can we go about cheating. In this zero knowledge range proof. While adhering to this formula. Of calculating Z. What we're going to do. Is we're going to focus on this part of the equation. And we're actually going to try and zero it out. If we somehow manage to zero it out. Then it doesn't matter how big K is. Z is only equal to W. And we can use whatever big K we want. And pass the verification. So how will we do that? We're going to use what's called. The Chinese remainder theorem. For this use case. Because as Nikos mentioned earlier. N is a product of two primes P and Q. If this value we're trying to zero out. Modulo P and modulo Q. They both zero out. Then it also implies. That the value we're trying to zero out. Zeroes out. So we're going to use this lens. To zero out the left hand equations. One by one. And by doing so. We'll achieve our goal. Of zeroing out the right hand equation. So one by one. We start with the first one. It's actually surprisingly simple. Because Alice is free to choose whatever K she wants. How about she chooses K to be equal to Q. Then by definition. Q mod Q zeroes out. And we're half way there. The easy half though. So how do we go about the second part. How do we zero out this value. Modulo P. What happens if this hash. That depends on W. Happens to organically land on. A multiple of P. Well that would be fantastic right. So is it likely to happen. No. But what if we brute force W. Such as the hash that depends on it. Happens to be a multiple of P. Is this feasible you might ask yourself. The question is no. Not at all feasible. Because the paper says that. N needs to be 2048 bits. Which makes P and Q both over 1000 bits. Now that's impossible to brute force. And if we could brute force that right. We might as well just brute force X. Which is 256 bits. So what can we do. How about. During the key generation phase. Which happens once per wallet. Alice instead of choosing N. To be comprised of two equally sized prime numbers. She would choose. Asymmetrically sized prime numbers. Whereas P can be as small as 16 bits. Which is brute forceable in an instant. And we can have Q to be sufficiently large. To make up for the desired size of N. Now some of you might be thinking. Well maybe the protocol says. That there is a zero knowledge proof. To prevent us from choosing such an N. It turns out that there is no zero knowledge proof. That prevents us from using such an N. There is no ZKP. For no small factors. The only thing that the parties check. Is whether N is square free. We are not going to get into the technical definition. Of square freeness. But it sounds like we have a way. We have a hook. We have a way to get the goods. We can inject this N with a very small P. Then we can choose K to be equal to Q. Then we can cheat in the range proof. And then when we receive the MTA response. We can get all the X's in the clear. So are we done? Not so fast. Because remember the MTA formula. So this is what Alice obtains. During the MTA. Well in reality. There is a pesky modulo N operation. Happening there implicitly. And it's unavoidable. I'm not going to get into why it's unavoidable. But it's unavoidable. And it's very annoying for the following reason. K is now almost as big as N. And what happens to the leakage. When K is almost as big as N. So let's have a look at K times X. Plus the mask. Here we see the beautiful X. And the most significant bits in the clear. However. In the MTA operator. The most significant bits of X. They disappear. They jump off a cliff. They go bye bye. And the only thing that remains. Is a small leakage of X. How small? What Alice obtains using this attack. Is X mod P. And P is a 16 bit prime. If only there were a way. To obtain X from such remainders. Worry not Nikos. Once again. The Chinese remainder theorem comes to our rescue. Now let's explain how it works a bit more in depth. Let's say we have this small number. X which is 23. We can encode it in a myriad of ways. Like we can also in the screen. We can encode it decimally. We can also encode it hexadecimally. We can actually also use CRT. To encode a number. Now how would one go about doing that? You need to divide this number. By a few small primes. And save the remainder. Now just using this information. The primes and the remainders. You can feed them into CRT. To reconstruct the original number fully. Now it looks a bit like magic. But it also has some limitations. Namely. It would only work to encode a number. That is smaller than the product of the primes. In this example. Using the primes 3, 5 and 7. You could only encode a number as big as 105. We're trying to encode a number. As big as 256 bits. So to do that. We need a number of primes. That are each 16 bits of size. So if we can get these 16 reminders. By the leakage that we explained earlier. And feed them all into CRT. We have Bob's key share. That could work. Anything stopping us? Yes. We only have one N. Remember? While K is chosen afresh during every signature generation. N is chosen once per wallet. During the key generation phase. So we only have one P value. We can only do this. To achieve the very first leakage. So. Bear with me. What if. During the key generation phase. Alice. Instead of choosing N to be this handsome looking value. That is a product of two primes. She would choose N to be this monstrosity. That is a product of 16 small primes. Plus. Times. A prime that is as big to make up for the desired size of N. Well. You might be wondering. Well. Isn't there some zero knowledge proof in the protocol. To make sure that you can choose this monstrosity. It turns out that there is no zero knowledge proof. Before checking the bi-primality. Because the only thing that the parties check. Is whether N is square free. And I'm still not telling you what square freeness is. So. We're at the finish line. We can extract all of these moduli. By injecting the N. And then choosing the K. And then cheating in the range proof. When we have the normal looking N. We set K equals Q. And we obtain leakage X mod P. Now that we have the bizarro N. We set K equals N over PI. And we obtain leakage X mod PI. And we need to do this. In 16 different signature generations. 16 different signature sessions. In the first one. We're going to use the first K. It's going to give us X mod P1. In the second one. We're going to use the second K. It's going to give us X mod P2. And so on and so forth. Until we get the 16th leakage. We feed everything into the CRT algorithm. And we obtain. X in the clear. So. Once again. We went to see if this crazy idea would work. We found an open source implementation. Of the GG20 protocol. And we gave it a try. So. We start by choosing 16 small primes. To make our bizarro N. We choose K. We cheat in the range proof. And we get the desired leakage. Now we need to do this. We need to sign 16 times. Each time getting one of those leakages. And then we can feed all of this information into CRT. Once again. Combine it with our own key share. And we can print the full private key. In a beautiful hexadecimal format. Load it up. Spend away. No need for consent of any of the other parties. Once again. We have mitigated this attack. How would you go about mitigating such an attack? Well. You could add those zero-knowledge proofs. For making sure the well-formedness of N. So Alice can choose this bizarro N. That is needed to carry out the attack. Well. Congratulations. We're done with the second attack. We're on to the third and last. Great. So in the last few minutes. We will show you how to compromise. What we call a do-it-yourself protocol. For this protocol. We will be exfiltrating the key in a single signature. Actually. We're going to do that in less than a signature. We're going to do it in the first round of the first signature generation. So what does the protocol look like? So it is also an MTA based protocol. However. Here. There are no zero-knowledge proofs. Accompanying the ciphertext that the parties sent to each other. Furthermore. The mask now is chosen to be as big as N. And this is important. Because now. Our previous attack is no longer relevant. Because it doesn't matter how big K is. What's inside the encryption. Is always hiding the X. Okay. So what can we do about it? Well. We can do a lot about it. Because without the zero-knowledge proof. Alice can send something that's not even a ciphertext. She can send for example the value 4. In doing so. And by choosing a carefully crafted N. Specifically one that is not square free. Bob will inadvertently send back his X. In the clear. Actually it's not exactly in the clear. You need to do some data processing. And there's a bunch of primes involved. And you need to do CRT. And then you need to brute force a bit. But everything happens in seconds. Alright. So you could think about this attack. As a condensed version of the previous one. Whereas. Instead of getting the 16 leakages in 16 signatures. We get all of them in one signature. And then brute forcing offline. And then use CRT to reconstruct the key. Now this demo is going to go fast. So do not blink. We start the signing. We do the MTA phase. We get the leakage. We do the brute forcing. We fit it all into CRT. And voila. We have the private key. To conclude. We have all the attacks on MPC protocol. That all result in exfiltrating the private key. Which is bypassing the basic promise. Security promise. Of the MPC protocols. I don't know. I hope that you might find this as interesting. As exciting as we do. Because this is a new space. The cryptography is really interesting. And it could really use as many researchers. As many smart people's eyes looking over. Making sure everyone is implementing this stuff correctly. Here you can find all the proof of concept. Source codes. Today. As well as a technical white paper. Explaining the math in more depth. Than you could have ever dreamed of. And thank you very much for coming. Thank you.