1 00:00:00,000 --> 00:00:08,000 Please welcome our next speaker, Nick Dorian, on Geolocation and Homomorphic Encryption. 2 00:00:14,460 --> 00:00:16,960 Alright, good morning. Can everyone hear me correctly? 3 00:00:17,420 --> 00:00:19,280 Okay, awesome, awesome. 4 00:00:19,580 --> 00:00:24,600 Okay, so today we're going to talk about geolocation and homomorphic encryption. 5 00:00:24,860 --> 00:00:26,240 My name is Nick Dorian. 6 00:00:26,400 --> 00:00:28,860 You can find me on Twitter, GitHub, maybe the Darknet. 7 00:00:30,000 --> 00:00:31,160 Using that screen name. 8 00:00:31,480 --> 00:00:33,040 And this is my first DEF CON. 9 00:00:33,520 --> 00:00:40,280 So, thank you all of you for being part of my first DEF CON. 10 00:00:40,600 --> 00:00:42,940 Okay, so first a little bit about me. 11 00:00:43,400 --> 00:00:45,360 I currently work at McKinsey. 12 00:00:45,840 --> 00:00:49,480 Kind of has this kind of very traditional, old-fashioned vibe to it. 13 00:00:50,000 --> 00:00:54,100 But currently we use, not to make a whole pitch, 14 00:00:54,300 --> 00:00:58,300 but currently we use React, Node, Docker, kind of modern stuff. 15 00:00:58,500 --> 00:00:59,900 Plus if your grandparents have ever, 16 00:01:00,000 --> 00:01:02,920 been like, why don't you stop playing video games and get a real job? 17 00:01:03,200 --> 00:01:05,040 Like, your grandparents will know what you do now. 18 00:01:05,560 --> 00:01:11,320 But I like to think that I have this hacker ethos from my previous roles with One Laptop for Child, 19 00:01:11,600 --> 00:01:14,860 Code for America, kind of like open source groups. 20 00:01:15,180 --> 00:01:18,460 And I think, despite working on some very serious projects, 21 00:01:18,620 --> 00:01:23,840 kind of my more famous work is Fortran.io, if any of you have been there. 22 00:01:25,120 --> 00:01:27,820 But anyway, today we're not going to talk about any of that. 23 00:01:27,920 --> 00:01:29,900 We're going to talk about this really interesting idea. 24 00:01:29,900 --> 00:01:34,460 That goes to something we use every day, mapping and geolocation. 25 00:01:35,420 --> 00:01:38,980 And pretty much all the time you're doing this, probably you did this today already. 26 00:01:39,300 --> 00:01:42,220 You get a GPS signal down to your phone or device. 27 00:01:42,900 --> 00:01:46,960 You ask a server, where's the nearest place that I'm trying to get to? 28 00:01:47,160 --> 00:01:48,700 And it comes back with a bunch of results. 29 00:01:49,200 --> 00:01:51,980 But also, if you think about it, it's a little bit creepy that, 30 00:01:52,040 --> 00:01:54,120 especially if you have Google location history on, 31 00:01:54,280 --> 00:01:57,840 I can go back years and figure out what restaurant did I go to? 32 00:01:57,980 --> 00:01:59,440 What was I doing this day? 33 00:01:59,440 --> 00:02:00,240 That kind of thing. 34 00:02:03,560 --> 00:02:09,380 So, yeah, so is anyone like a mapping geospatial developer person in real life? 35 00:02:09,800 --> 00:02:11,040 Okay, great. 36 00:02:11,200 --> 00:02:13,780 Okay, so if you've done this before or even if you haven't, 37 00:02:13,880 --> 00:02:16,620 there's really two different ways that people go about doing this. 38 00:02:16,820 --> 00:02:19,400 The first one is make a client-side app. 39 00:02:19,540 --> 00:02:20,540 Everything's client-side. 40 00:02:20,920 --> 00:02:28,460 And to find places that are near you or in that area, you have to download all the geodata 41 00:02:28,460 --> 00:02:29,320 down to the client. 42 00:02:29,440 --> 00:02:34,160 And then they make some sort of calculation based on a JavaScript spatial library. 43 00:02:34,940 --> 00:02:39,400 And there are two reasons that people, especially companies, don't like to do this. 44 00:02:39,840 --> 00:02:42,280 One of them is that it's a big data set. 45 00:02:42,420 --> 00:02:45,580 For example, let's say you were trying to figure out the precinct where I vote. 46 00:02:46,660 --> 00:02:49,360 That needs to be very accurate, needs to be very precise. 47 00:02:49,680 --> 00:02:53,600 And just downloading the data set from my state would be hundreds of megabytes. 48 00:02:54,100 --> 00:02:56,380 So that's not something we can do on the client side. 49 00:02:56,720 --> 00:02:59,320 And then for something like the Google example that I showed 50 00:02:59,440 --> 00:03:02,800 you earlier, if I'm looking up burrito places, Google doesn't want 51 00:03:02,800 --> 00:03:06,180 to share its whole data set of burrito places in my area. 52 00:03:06,660 --> 00:03:11,660 So instead, what most people do is the server option, this option B, 53 00:03:12,480 --> 00:03:16,540 where this client gives up its geolocation data, sends it over, 54 00:03:16,740 --> 00:03:18,660 and then the server decides what's good for that. 55 00:03:18,960 --> 00:03:21,500 So this works for all those different examples I mentioned before, 56 00:03:21,720 --> 00:03:26,200 where there's a lot of data, you can't really download all the data, 57 00:03:26,320 --> 00:03:28,260 or it's proprietary information. 58 00:03:29,440 --> 00:03:32,160 And then the other point is, you have to give up your location. 59 00:03:32,760 --> 00:03:37,020 And it makes sense, because how are they supposed to tell where you are 60 00:03:37,020 --> 00:03:40,380 or what's near you if you haven't given them your latitude and longitude? 61 00:03:40,540 --> 00:03:41,480 It's like not possible. 62 00:03:42,140 --> 00:03:44,180 But what if there was a third option? 63 00:03:44,400 --> 00:03:48,240 So I'm not a mathematician or a cryptographer by training. 64 00:03:48,540 --> 00:03:52,160 I assume we do have a number of math and cryptography people here. 65 00:03:52,500 --> 00:03:56,380 But when I was reading about this a couple years ago, I was surprised about this, 66 00:03:56,440 --> 00:03:58,940 to hear about this thing, which is apparently a real thing, 67 00:03:59,440 --> 00:04:00,540 called homomorphic encryption. 68 00:04:01,460 --> 00:04:05,060 And when I try to describe it to someone, it sounds a little bit like magic. 69 00:04:05,720 --> 00:04:10,140 But it's just math, like advanced math that took people a long time to figure out, 70 00:04:10,220 --> 00:04:13,040 and I'm not prepared to fully understand. 71 00:04:13,400 --> 00:04:16,580 But essentially what it means is people can do calculations 72 00:04:17,940 --> 00:04:23,440 on numbers while they're encrypted without ever knowing the underlying value. 73 00:04:24,320 --> 00:04:29,420 So there are two classical examples of why you might try to do that, which is, 74 00:04:29,440 --> 00:04:33,280 what I've been hearing before I came into this mapping problem of it. 75 00:04:33,520 --> 00:04:36,680 So the first example is like a stock example. 76 00:04:36,940 --> 00:04:40,080 Like say you're about to sell many thousands of dollars of stock, 77 00:04:40,280 --> 00:04:43,020 and there are different fees and things that are going to be incurred 78 00:04:43,020 --> 00:04:44,520 by different people in your supply chain. 79 00:04:44,800 --> 00:04:49,540 But the moment you get the word out there, I'm going to sell $3,000 of this stock, 80 00:04:50,100 --> 00:04:52,700 other people are going to start speculating against you. 81 00:04:52,820 --> 00:04:58,180 Like there's all these like, what is it, micro-traders or high-frequency trading. 82 00:04:58,400 --> 00:04:58,840 Right. 83 00:04:58,840 --> 00:05:01,960 So you don't want to leak that information while you're doing the calculation, 84 00:05:02,480 --> 00:05:05,100 but you do want to know what the final calculation is. 85 00:05:05,440 --> 00:05:09,580 So the concept in that example is you might send the number encrypted, 86 00:05:09,860 --> 00:05:14,280 they do math on it encrypted, and then you decrypt the result on your side. 87 00:05:15,060 --> 00:05:17,800 The other example that I've seen, this is a commercial product, 88 00:05:17,980 --> 00:05:22,220 but I don't really remember whose it is, is that if you think about it, 89 00:05:22,240 --> 00:05:25,120 Google has access to all the plain text of all of your emails. 90 00:05:25,260 --> 00:05:28,320 Because when you do a search, Google needs to be able to search 91 00:05:28,320 --> 00:05:29,000 that text. 92 00:05:29,460 --> 00:05:36,440 And so there's this particular software or service where they encrypt all of your emails 93 00:05:36,680 --> 00:05:43,660 on the server and you send kind of an encrypted search query into that 94 00:05:43,660 --> 00:05:48,860 to search your email without revealing what is your email and what are you searching. 95 00:05:49,900 --> 00:05:53,020 So this is relatively new in terms of like math. 96 00:05:53,220 --> 00:05:58,020 The first like partially homomorphic system was described in the 1970s. 97 00:05:58,320 --> 00:06:02,120 So the reason it's called partially homomorphic is that it can do addition 98 00:06:02,120 --> 00:06:07,200 or it can do multiplication, but it can't do everything in general. 99 00:06:07,540 --> 00:06:11,480 So it was only in 2009 that some researchers who now work 100 00:06:11,480 --> 00:06:16,040 at IBM published the first fully homomorphic encrypto system. 101 00:06:16,360 --> 00:06:19,400 So if you look at the code, it kind of goes down very far, 102 00:06:19,480 --> 00:06:23,340 down to like assembly of different logic gates and things like that. 103 00:06:23,380 --> 00:06:24,280 So it's very intimidating. 104 00:06:24,700 --> 00:06:26,720 And we're not going to talk about that today. 105 00:06:27,500 --> 00:06:28,300 But it's very interesting. 106 00:06:28,320 --> 00:06:31,120 Instead, I use something called the pillier cryptosystem. 107 00:06:31,260 --> 00:06:34,020 Is there a cryptographer here who can correct my pronunciation 108 00:06:34,020 --> 00:06:36,140 of pillier cryptosystem? 109 00:06:37,180 --> 00:06:38,120 Oh, thank goodness. 110 00:06:38,360 --> 00:06:40,980 Okay. I get to be the expert. 111 00:06:41,080 --> 00:06:41,560 This is great. 112 00:06:41,940 --> 00:06:44,920 Okay. I watched a YouTube video this morning and they said pillier. 113 00:06:45,060 --> 00:06:46,760 So let's go with it. 114 00:06:48,100 --> 00:06:52,160 So why are we not using homomorphic encryption magic all the time? 115 00:06:52,240 --> 00:06:54,080 Because then everyone would have things. 116 00:06:54,200 --> 00:06:57,560 First thing is people are already pretty okay with sharing data. 117 00:06:57,560 --> 00:07:00,200 Like you didn't feel uncomfortable telling Google 118 00:07:00,200 --> 00:07:01,760 that you were in Las Vegas. 119 00:07:02,580 --> 00:07:05,000 And especially if you trust the business with their money. 120 00:07:05,140 --> 00:07:08,000 Like the example I gave earlier of the stock market, 121 00:07:08,240 --> 00:07:11,300 like makes sense like in terms of like an academic paper. 122 00:07:11,620 --> 00:07:14,760 But then it's like wait a minute, why am I doing thousands of dollars 123 00:07:14,760 --> 00:07:17,660 of trades with a company that I don't even trust? 124 00:07:18,040 --> 00:07:21,840 Like what if they get the result and then they wait five seconds 125 00:07:21,840 --> 00:07:24,740 and then they broadcast it, but they've actually done some like. 126 00:07:24,900 --> 00:07:27,540 So I'm not. 127 00:07:27,560 --> 00:07:29,940 So it seems like a really interesting idea, 128 00:07:30,220 --> 00:07:33,800 but because of the practicalities and then also 129 00:07:33,800 --> 00:07:38,240 because it's very expensive on a computation speed and time level, 130 00:07:38,440 --> 00:07:42,140 it hasn't really taken off as like a general purpose thing. 131 00:07:43,240 --> 00:07:45,860 But the example we're going to talk about today I think is a 132 00:07:45,860 --> 00:07:48,840 little bit more possible or more relevant use 133 00:07:48,840 --> 00:07:49,940 of homomorphic encryption. 134 00:07:50,480 --> 00:07:53,140 And it's involving your geolocation. 135 00:07:53,600 --> 00:07:57,380 And the example that I'm going to do is sort of like a treasure 136 00:07:57,560 --> 00:07:59,680 hunt or geocaching kind of example. 137 00:08:00,040 --> 00:08:03,160 So here you are on the road and you're like hey, 138 00:08:03,280 --> 00:08:04,900 I think that I've solved the puzzle. 139 00:08:05,060 --> 00:08:06,160 I'm at the end of the road. 140 00:08:06,860 --> 00:08:08,080 I think I've found it. 141 00:08:08,240 --> 00:08:10,340 But for whatever reason you're being watched, 142 00:08:10,540 --> 00:08:12,120 you don't want to give away your location. 143 00:08:12,360 --> 00:08:13,640 You're like being very secretive. 144 00:08:14,120 --> 00:08:19,600 So the server can't tell you where the finish line is either 145 00:08:19,600 --> 00:08:22,320 because otherwise you would say hey, I'm in Las Vegas. 146 00:08:22,460 --> 00:08:22,960 Am I winning? 147 00:08:23,140 --> 00:08:25,380 And they'd say no, you're only winning if you're in Colorado. 148 00:08:25,900 --> 00:08:27,140 And then they'd be like okay, great. 149 00:08:27,560 --> 00:08:27,880 I'm going there. 150 00:08:28,260 --> 00:08:31,680 So the server can't reveal the answer and you for whatever 151 00:08:31,680 --> 00:08:33,720 reason don't want to share your coordinates. 152 00:08:34,080 --> 00:08:37,520 And then there's this other person here with the spy device 153 00:08:37,520 --> 00:08:42,020 that I'm seeing is watching your connection or something, 154 00:08:42,340 --> 00:08:45,080 trying to see if someone's going to share where they are 155 00:08:45,080 --> 00:08:46,620 or where the finish line is. 156 00:08:48,380 --> 00:08:51,100 So in order to make this work, like I said before, 157 00:08:51,240 --> 00:08:52,860 I chose the Piliar cryptosystem. 158 00:08:53,100 --> 00:08:56,380 Not because it's partially homomorphic so it can do 159 00:08:56,380 --> 00:09:01,980 addition and multiplication by other like non-encrypted numbers. 160 00:09:02,180 --> 00:09:04,400 But it can't do something like X squared, 161 00:09:04,540 --> 00:09:06,040 multiplying a number by itself. 162 00:09:06,400 --> 00:09:08,920 Just because of however it is architected. 163 00:09:09,180 --> 00:09:10,900 There are some other systems out there. 164 00:09:11,140 --> 00:09:14,520 While I was preparing these slides I saw there's a web 165 00:09:14,520 --> 00:09:15,460 assembly library. 166 00:09:15,940 --> 00:09:19,640 The main reason behind me choosing the libraries I did was 167 00:09:19,640 --> 00:09:22,200 I wanted there to be a server and a client 168 00:09:22,200 --> 00:09:24,380 that could communicate using the same thing. 169 00:09:24,560 --> 00:09:26,140 And the bottleneck on that is 170 00:09:26,140 --> 00:09:28,820 finding some cryptographer who's made like a 171 00:09:28,820 --> 00:09:30,700 JavaScript implementation of this. 172 00:09:31,180 --> 00:09:33,100 So I found the Piliar cryptosystem. 173 00:09:33,400 --> 00:09:35,680 This goes back to the 1990s or so. 174 00:09:35,960 --> 00:09:38,280 And there's a few different implementations out there. 175 00:09:38,380 --> 00:09:39,960 I was pretty happy with how it worked out here. 176 00:09:41,920 --> 00:09:43,920 And like I mentioned, there's limits to what you can 177 00:09:43,920 --> 00:09:46,660 and can't do within these systems. 178 00:09:47,100 --> 00:09:49,080 So okay, I'm going to show you some code now. 179 00:09:49,280 --> 00:09:50,980 I hope that we're, I don't, yeah. 180 00:09:51,340 --> 00:09:52,940 So here's, I'm going to show you some code now. 181 00:09:53,060 --> 00:09:54,100 So you're on the treasure hunt. 182 00:09:55,140 --> 00:09:55,940 And you. 183 00:09:55,940 --> 00:09:57,180 You've loaded this library. 184 00:09:57,520 --> 00:09:58,900 You create a key pair. 185 00:09:59,100 --> 00:10:03,020 So I know, I think a number of us have used PGP, GPG. 186 00:10:03,220 --> 00:10:06,660 So if you really like public private key pairs before, 187 00:10:06,940 --> 00:10:10,060 now you can have public private key pairs for each one 188 00:10:10,060 --> 00:10:11,940 of your numbers that you use. 189 00:10:12,080 --> 00:10:13,620 So now you have a lot more keys. 190 00:10:14,240 --> 00:10:18,820 In this example, I generated a key with only 128 length. 191 00:10:19,080 --> 00:10:20,820 But I've since updated the GitHub repo. 192 00:10:21,020 --> 00:10:23,240 Now it's 1,024 length. 193 00:10:23,600 --> 00:10:25,320 You can pretty much set it to any size. 194 00:10:25,320 --> 00:10:26,980 It just takes a little longer for it to generate 195 00:10:27,440 --> 00:10:28,720 your public private key. 196 00:10:29,860 --> 00:10:31,520 So you're at this location. 197 00:10:31,780 --> 00:10:34,520 You know where you are, with latitude and longitude. 198 00:10:34,740 --> 00:10:35,940 And you generate a key. 199 00:10:37,120 --> 00:10:40,000 And then you want to send up the latitude 200 00:10:40,000 --> 00:10:41,240 and longitude encrypted. 201 00:10:41,760 --> 00:10:44,920 Now for whatever reason, the JavaScript library I was using 202 00:10:44,920 --> 00:10:47,280 only accepts them as positive integers. 203 00:10:48,140 --> 00:10:51,400 I think I asked earlier, and there's some mapping people here, 204 00:10:51,480 --> 00:10:55,100 but not a lot, and generally the way things we do, 205 00:10:55,100 --> 00:10:58,480 latitude and longitude these days, is we have negative 90 206 00:10:58,480 --> 00:11:02,300 be the south pole, positive 90, north pole, negative 180 207 00:11:02,300 --> 00:11:05,100 be the international date line going west, 208 00:11:05,400 --> 00:11:07,100 and then wrap around to plus 180. 209 00:11:07,420 --> 00:11:09,980 So I had to make everything into positive integers. 210 00:11:10,220 --> 00:11:12,660 So I have like a little ACKY thing there. 211 00:11:12,960 --> 00:11:15,460 And then encrypt them. 212 00:11:18,080 --> 00:11:20,140 So that gets set up to the server. 213 00:11:20,420 --> 00:11:24,740 And the latitude and the longitude are now 617 digit, 214 00:11:25,320 --> 00:11:25,820 numbers. 215 00:11:26,360 --> 00:11:28,120 Like it looks just like a number, 216 00:11:28,220 --> 00:11:29,600 but it's actually encrypted. 217 00:11:30,200 --> 00:11:31,920 Kind of like when you send a PGP message, 218 00:11:32,040 --> 00:11:33,380 there's a blob of crypto text. 219 00:11:33,600 --> 00:11:34,380 And you're like, what is that? 220 00:11:34,720 --> 00:11:39,540 This is kind of a number that in the pillar crypto system 221 00:11:39,540 --> 00:11:41,920 represents your latitude or your longitude. 222 00:11:42,520 --> 00:11:45,340 And in fact, I assume some of you 223 00:11:45,340 --> 00:11:50,080 have done JavaScript trying to work with the Twitter API. 224 00:11:50,460 --> 00:11:53,640 And already the number of tweets is above the limit 225 00:11:53,640 --> 00:11:55,080 of JavaScript numbers. 226 00:11:55,100 --> 00:11:58,280 So if you deal with a 617 digit number, 227 00:11:58,460 --> 00:12:00,200 there's a special JavaScript library 228 00:12:00,200 --> 00:12:02,240 called big number that helps you deal 229 00:12:02,240 --> 00:12:03,600 with these crazy big numbers. 230 00:12:05,880 --> 00:12:08,500 And another thing is there's some kind of nonce or something 231 00:12:08,500 --> 00:12:12,060 in the system so that the server can't just guess 232 00:12:12,440 --> 00:12:14,800 your latitude, longitude, and generate the same number 233 00:12:14,800 --> 00:12:15,860 with the same public key. 234 00:12:16,340 --> 00:12:18,440 Instead, they're just going to keep 235 00:12:18,440 --> 00:12:20,020 generating lots of different numbers 236 00:12:20,020 --> 00:12:23,500 and not be able to find out if this is bigger or smaller 237 00:12:23,500 --> 00:12:23,940 than it. 238 00:12:25,780 --> 00:12:30,760 So in this case, I'm going to kind of spoil the source code 239 00:12:30,760 --> 00:12:31,280 for you. 240 00:12:31,420 --> 00:12:34,680 In my example, the winning location 241 00:12:35,060 --> 00:12:37,180 is Colorado because it's a rectangle. 242 00:12:37,640 --> 00:12:39,980 And I figured it would be a good, simple example. 243 00:12:40,540 --> 00:12:44,340 So if you're inside Colorado, I should 244 00:12:44,340 --> 00:12:47,180 be able to measure your offset to the north, south, east, 245 00:12:47,320 --> 00:12:47,680 and west. 246 00:12:48,060 --> 00:12:50,780 And two of them should be positive and two of them 247 00:12:50,780 --> 00:12:51,480 should be negative. 248 00:12:52,240 --> 00:12:54,680 If you're in the center, kind of this rectangle 249 00:12:54,680 --> 00:12:56,260 diagram here is what I'm talking about. 250 00:12:57,080 --> 00:12:59,440 You should have north be positive, south be negative, 251 00:12:59,660 --> 00:13:00,260 and so on. 252 00:13:01,000 --> 00:13:02,720 But then I thought, wait a minute. 253 00:13:02,820 --> 00:13:08,860 What if I send my location to the server 254 00:13:08,860 --> 00:13:11,820 and it calculates the difference from its target location? 255 00:13:11,980 --> 00:13:15,500 It's basically telling me how far away I am from the target. 256 00:13:15,860 --> 00:13:18,800 So I also multiply each one of them 257 00:13:18,800 --> 00:13:20,340 by a different random offset. 258 00:13:20,780 --> 00:13:24,480 So you might know which direction you're in relative. 259 00:13:24,480 --> 00:13:27,320 But you don't know how far away you 260 00:13:27,320 --> 00:13:30,260 are from it because it's randomized all of them. 261 00:13:33,020 --> 00:13:37,760 So the only one who can actually decrypt and parse the response 262 00:13:38,400 --> 00:13:41,000 is the initial user. 263 00:13:41,220 --> 00:13:42,740 So they get it back. 264 00:13:42,920 --> 00:13:46,820 They find out that they're still south of the target area. 265 00:13:47,020 --> 00:13:50,520 But they don't have to reveal that to anyone else. 266 00:13:51,520 --> 00:13:54,460 And even if our hacker friends are 267 00:13:54,460 --> 00:13:56,900 able to go over and look at the server, 268 00:13:57,520 --> 00:13:58,960 even if they get inside the server 269 00:13:58,960 --> 00:14:00,620 and look at the logs, the database, 270 00:14:00,820 --> 00:14:03,220 see any kind of information that the server ever had, 271 00:14:03,440 --> 00:14:08,340 they're not able to decrypt the original latitude and longitude. 272 00:14:09,880 --> 00:14:13,060 So I tried to make a Jupyter notebook for all of you. 273 00:14:13,120 --> 00:14:16,160 But when my code hit Jupyter, it created 274 00:14:16,160 --> 00:14:18,560 kind of a catastrophic error. 275 00:14:18,700 --> 00:14:21,520 This is like a 90s astronomy joke I thought of this morning. 276 00:14:21,700 --> 00:14:22,040 Did anyone? 277 00:14:23,780 --> 00:14:24,220 OK. 278 00:14:26,480 --> 00:14:28,700 Anyway, so it didn't do well in Jupyter. 279 00:14:28,840 --> 00:14:29,940 If someone wants to look at my code, 280 00:14:30,040 --> 00:14:32,080 I have a bit.ly link and a long link 281 00:14:32,080 --> 00:14:33,500 if someone wants to see that. 282 00:14:34,460 --> 00:14:36,140 But you might say, wait a minute, Nick. 283 00:14:36,220 --> 00:14:37,460 In the first example, you're just 284 00:14:37,460 --> 00:14:38,660 showing places that were near me. 285 00:14:38,780 --> 00:14:39,940 I don't want to do a treasure hunt. 286 00:14:40,420 --> 00:14:41,460 I don't want to do that. 287 00:14:41,540 --> 00:14:42,780 I want to find places that are near you. 288 00:14:42,900 --> 00:14:45,140 And this is something I'm really interested in finding, 289 00:14:45,620 --> 00:14:49,140 a really high tech crypto way to handle it. 290 00:14:49,380 --> 00:14:51,580 Except Chipotle's isn't really a good example. 291 00:14:52,400 --> 00:14:53,860 So I actually. 292 00:14:53,860 --> 00:14:55,340 Last year, I met with someone who's 293 00:14:55,340 --> 00:14:58,640 in the Syrian American Medical Society. 294 00:14:59,000 --> 00:15:01,860 And they were saying that there are these hospitals that they 295 00:15:01,860 --> 00:15:04,460 have to keep track of and send information and supplies 296 00:15:04,460 --> 00:15:05,300 back and forth. 297 00:15:07,060 --> 00:15:09,460 But they don't want there to be a list anywhere 298 00:15:09,920 --> 00:15:11,820 where you can just download a KML file 299 00:15:12,700 --> 00:15:14,320 and cause problems for people. 300 00:15:15,080 --> 00:15:16,900 And because this is a high risk. 301 00:15:17,000 --> 00:15:18,620 And I thought, because there's a risk 302 00:15:18,620 --> 00:15:21,000 that they're being targeted by Russia, 303 00:15:21,020 --> 00:15:23,320 it's probably better if this list is never created. 304 00:15:23,320 --> 00:15:25,760 And also, because this is just an experiment, 305 00:15:25,900 --> 00:15:28,020 I didn't want to dive into it. 306 00:15:28,120 --> 00:15:30,260 But as a demo, I'm like, this is kind of something 307 00:15:30,820 --> 00:15:32,140 we should try to aspire to. 308 00:15:32,280 --> 00:15:34,500 Is there a way that people can keep track of their resources 309 00:15:35,200 --> 00:15:37,540 and know what's the place closest to them 310 00:15:37,540 --> 00:15:39,460 without revealing everything? 311 00:15:41,720 --> 00:15:44,520 So I can't use the Pilear crypto system anymore, 312 00:15:44,680 --> 00:15:47,200 because it only uses addition and subtraction. 313 00:15:47,260 --> 00:15:50,340 There's actually a really funny error if you try to multiply. 314 00:15:50,860 --> 00:15:53,040 It's a good luck with that error. 315 00:15:53,560 --> 00:16:00,120 Just a nice implementation by whoever wrote that library. 316 00:16:00,600 --> 00:16:03,000 But it led me to think about this problem of like, 317 00:16:03,140 --> 00:16:06,700 if the server can calculate the distance 318 00:16:06,700 --> 00:16:10,040 and sort the closest one to the furthest one for you, 319 00:16:10,180 --> 00:16:12,000 they could do that for themselves as well. 320 00:16:12,120 --> 00:16:14,180 They could create millions and billions of points 321 00:16:14,180 --> 00:16:17,680 all around the world and find out which point is closest to you 322 00:16:17,680 --> 00:16:18,860 and say, I know where you are. 323 00:16:19,140 --> 00:16:22,820 And if the server can't sort by distance, how is it going 324 00:16:22,820 --> 00:16:26,360 to do anything other than send you all the data 325 00:16:26,740 --> 00:16:27,580 and all the distances? 326 00:16:28,020 --> 00:16:30,520 And if you've ever spent some time with like a protractor 327 00:16:30,520 --> 00:16:34,320 and a compass, you know that if you get the distance 328 00:16:34,320 --> 00:16:37,540 from a few different points, you can triangulate where they are. 329 00:16:38,220 --> 00:16:42,180 So this would actually be kind of interesting cryptographically, 330 00:16:42,340 --> 00:16:45,160 but practically, if someone sends you three requests, 331 00:16:45,300 --> 00:16:47,100 like oh, what's near me, what's near me, what's near you, 332 00:16:47,140 --> 00:16:48,220 now I know all of your locations. 333 00:16:49,600 --> 00:16:51,740 So instead, there's something called a geohash. 334 00:16:51,920 --> 00:16:52,800 Has anyone seen that? 335 00:16:52,800 --> 00:16:53,620 Have you seen a geohash before? 336 00:16:53,900 --> 00:16:55,540 It's been on XKCity a couple times. 337 00:16:56,040 --> 00:16:59,600 So the idea behind a geohash is there's 26 letters 338 00:16:59,600 --> 00:17:03,180 and 10 numerals, so a total of 36 options. 339 00:17:04,000 --> 00:17:09,280 And what you do is you divide the world up into a 6x6 grid, 340 00:17:10,180 --> 00:17:14,520 and then you divide that square up into a 6x6 grid on and on 341 00:17:14,520 --> 00:17:16,780 until you have the level of precision that you want. 342 00:17:16,980 --> 00:17:21,960 So where we are right now in Las Vegas is this geohash. 343 00:17:21,960 --> 00:17:24,480 It's something you can kind of share kind of quickly 344 00:17:24,480 --> 00:17:25,820 and copy back and forth. 345 00:17:26,020 --> 00:17:27,940 And if you want it to be less precise, 346 00:17:28,080 --> 00:17:30,220 you just take letters and numbers off. 347 00:17:30,620 --> 00:17:33,240 So I'm interested in maybe the right way 348 00:17:33,240 --> 00:17:36,220 of implementing this system is for you to tell the server, 349 00:17:36,320 --> 00:17:37,740 this is my current geohash. 350 00:17:38,040 --> 00:17:41,980 Can you give me the locations near me organized 351 00:17:41,980 --> 00:17:46,040 by a geohash that's a little bit longer than my current location, 352 00:17:46,620 --> 00:17:47,820 if that makes some sense? 353 00:17:48,220 --> 00:17:51,760 So you're telling them this is how much I'm willing to share in terms 354 00:17:51,760 --> 00:17:56,100 of location, how much further are you willing to go on your locations 355 00:17:56,100 --> 00:17:57,200 when you share them with me? 356 00:17:58,700 --> 00:18:01,280 Then I thought about it a little bit more and I realized there's a problem. 357 00:18:01,840 --> 00:18:05,740 If I'm in one of those geohash squares somewhere like in the center, 358 00:18:05,960 --> 00:18:08,640 then I just send that one geohash square and I'm fine. 359 00:18:08,960 --> 00:18:14,340 But if I'm at the corner, I have to send, and my search radius is big enough 360 00:18:14,340 --> 00:18:19,540 to go into the neighboring grids, then I have to ask for four grids. 361 00:18:19,700 --> 00:18:21,680 And then it will be very obvious to whoever is 362 00:18:22,300 --> 00:18:27,380 listening in that I'm somewhere near that corner if I'm asking for all of them. 363 00:18:28,540 --> 00:18:34,240 So instead I think probably the right way to implement this would be for the client 364 00:18:34,240 --> 00:18:35,780 to suggest a random offset. 365 00:18:36,000 --> 00:18:40,040 So sometimes it's going to be one or two or three or four grid squares, 366 00:18:40,320 --> 00:18:44,860 but it's meaningless because they've just randomly offset that location. 367 00:18:45,120 --> 00:18:48,800 So it's not clear to the server why they've chosen that offset 368 00:18:49,120 --> 00:18:51,340 or where they are within that space. 369 00:18:55,060 --> 00:19:00,460 So future ideas, right now I just, I told you I had the example of Colorado, 370 00:19:00,760 --> 00:19:01,740 which is just a rectangle. 371 00:19:02,140 --> 00:19:04,420 I think there's a potential for other shapes. 372 00:19:04,800 --> 00:19:10,420 Just even using addition, subtraction, and scalar multiplication, 373 00:19:10,800 --> 00:19:15,980 you could easily do like a y equals mx plus db to make a triangle, right? 374 00:19:16,100 --> 00:19:20,820 So a mix of triangles and boxes to make up larger, more interesting shapes. 375 00:19:22,020 --> 00:19:24,460 There's some different JavaScript libraries that I mentioned 376 00:19:24,950 --> 00:19:27,740 that could support this and other geo calculations. 377 00:19:28,820 --> 00:19:32,620 If there's, I know there's a talk later today about post-quantum encryption. 378 00:19:32,900 --> 00:19:36,260 Are we have any post-quantum crypto fans here? 379 00:19:36,440 --> 00:19:40,940 So one thing that that is using is using lattice-based encryption, 380 00:19:41,300 --> 00:19:44,560 which for reasons I don't fully understand, again, not a mathematician, 381 00:19:45,580 --> 00:19:50,760 lattice-based encryption is really good for homomorphic applications like this. 382 00:19:51,340 --> 00:19:54,280 So as that gets more popular and more widespread, 383 00:19:54,920 --> 00:19:57,800 these homomorphic applications could also benefit from that. 384 00:19:58,560 --> 00:20:01,660 There's also something, if you do research into homomorphic encryption, 385 00:20:01,840 --> 00:20:03,360 there's like a voting system. 386 00:20:03,780 --> 00:20:07,200 Has anyone seen like a homomorphic voting system thing before? 387 00:20:08,440 --> 00:20:12,780 So like we said before, you're able to do calculations on numbers you can't see. 388 00:20:13,120 --> 00:20:17,480 So there's a crypto system, okay, yeah, I'm running out of time. 389 00:20:17,620 --> 00:20:21,000 But yeah, there's a crypto system where you can add up the votes totals without 390 00:20:21,000 --> 00:20:22,180 knowing people's votes. 391 00:20:22,500 --> 00:20:24,120 Okay, I'm sorry I'm running out of time. 392 00:20:24,340 --> 00:20:26,480 Do we have time for questions or that's like it? 393 00:20:27,660 --> 00:20:30,800 Okay, that's it, but I still am alive as a person. 394 00:20:30,960 --> 00:20:36,700 I'm here and you can email me, Twitter, GitHub, you can figure out where I am. 395 00:20:36,800 --> 00:20:37,600 Okay, thank you so much.