1 00:00:00,000 --> 00:00:05,940 So I'm here to try and tell you how to build a quantum true random number generator in the next 2 00:00:05,940 --> 00:00:12,640 20 minutes. So you're going to have to forgive me for speaking quickly. Now before we begin, 3 00:00:12,820 --> 00:00:16,940 we have to start with a description of what true randomness is. And the take-home lesson 4 00:00:16,940 --> 00:00:23,020 is that true random data is unpredictable. And what this means is that if you have any amount 5 00:00:23,020 --> 00:00:28,240 of true random data, an arbitrary amount of processing power and time, and perfect knowledge 6 00:00:28,240 --> 00:00:34,580 of how it was generated, you cannot predict the next bit with better than chance. And to meet this 7 00:00:34,580 --> 00:00:40,240 gold standard, your data has to be unbiased and not produced by an algorithm. And most of you 8 00:00:40,240 --> 00:00:45,220 probably know that computers use algorithms to generate pseudo random numbers. What some of you 9 00:00:45,220 --> 00:00:49,760 might not know is that even numbers that you generate in your head do not meet the standard. 10 00:00:50,820 --> 00:00:56,600 These numbers are interesting because they're useful for cryptography, scientific applications, 11 00:00:56,960 --> 00:00:57,740 and drinking games. 12 00:00:59,620 --> 00:01:04,600 So if you wanted random numbers, you have two basic approaches you can take. You can use a 13 00:01:04,600 --> 00:01:09,800 pseudo random number generator, which uses an initial secret starting condition and an algorithm 14 00:01:09,800 --> 00:01:15,360 to generate a deterministic sequence of numbers, which is considered for most applications a good 15 00:01:15,360 --> 00:01:21,680 enough approximation to the random distribution to be used for many purposes. Or you can use a 16 00:01:21,680 --> 00:01:26,560 true random number generator, which it's almost wrong to say that they generate random numbers. 17 00:01:26,640 --> 00:01:28,220 What they really do is they sample random numbers. 18 00:01:29,480 --> 00:01:36,880 By taking a chaotic physical system, and measuring variation in that system, and then using that to generate the numbers. 19 00:01:38,080 --> 00:01:43,260 No matter what you do, it is very easy to make a mistake in your design, and very hard to find it. 20 00:01:43,400 --> 00:01:45,620 So you have to always doubt yourself at every step. 21 00:01:47,900 --> 00:01:53,740 Now, among true random number generators, there are two sorts. And I'm going to start by describing non-quantum true random number generators. 22 00:01:54,300 --> 00:01:58,220 These sample a complex and chaotic system. 23 00:01:58,240 --> 00:02:01,100 I use chaos and entropy interchangeably. 24 00:02:03,000 --> 00:02:07,900 And use that measured entropy to generate random numbers. 25 00:02:08,960 --> 00:02:12,560 Now, these are not that hard to design if you think very carefully. 26 00:02:13,060 --> 00:02:16,620 For instance, you can use minor differences in user input timing. 27 00:02:17,100 --> 00:02:20,660 You can sample air pressure or temperature over very small timescales. 28 00:02:21,520 --> 00:02:25,300 But fundamentally, what you're doing is you're sampling a system that has a lot of inputs. 29 00:02:25,540 --> 00:02:26,600 And you have to ask yourself 30 00:02:26,600 --> 00:02:34,060 whether the complexity of the output is the same thing or as good as random output. 31 00:02:34,360 --> 00:02:40,160 Because since you have many inputs, it's very difficult to prove what all of them are. 32 00:02:40,320 --> 00:02:45,580 Let alone whether some of them are defined by an algorithm or biased in some way. 33 00:02:47,660 --> 00:02:54,400 And if you have a quantum true random number generator, the main difference is that you've sampled a very simple system of high entropy. 34 00:02:54,720 --> 00:02:56,580 Such as the behavior of symmetry. 35 00:02:56,600 --> 00:02:57,900 Or single particles or photons. 36 00:02:59,640 --> 00:03:05,320 Now, this is interesting specifically for a sealed radioactive source. 37 00:03:05,500 --> 00:03:07,980 Because it has no inputs and still has outputs. 38 00:03:08,320 --> 00:03:10,420 And that's great because it makes it very difficult to attack. 39 00:03:11,820 --> 00:03:16,140 Now, these type of sources, you typically end up with low bandwidth. 40 00:03:16,280 --> 00:03:18,680 Because you don't like dealing with things that emit a lot of radiation. 41 00:03:21,200 --> 00:03:25,400 And it's also very difficult to detect subatomic particles or single photons. 42 00:03:25,400 --> 00:03:27,400 Using equipment that you have around your house. 43 00:03:28,000 --> 00:03:31,440 However, if you overcome these obstacles, the output should be truly random. 44 00:03:31,640 --> 00:03:34,560 And I say should because there's a lot of mistakes you might make. 45 00:03:34,720 --> 00:03:36,020 And I'm going to go over a couple of these. 46 00:03:36,980 --> 00:03:41,500 The first most tempting mistake to make is to use more than one detector for your entropy source. 47 00:03:41,980 --> 00:03:45,440 And have one of the detectors output zeros and the other one output ones. 48 00:03:47,740 --> 00:03:49,400 Now, on paper this is nice. 49 00:03:49,520 --> 00:03:54,880 But in practice, the detection efficiency of your detectors and where they are located relative to the source. 50 00:03:54,880 --> 00:03:58,860 Will make it such that one of them is going to be more likely to detect things than the other. 51 00:03:59,820 --> 00:04:02,400 So you will have some sort of bias involved. 52 00:04:03,920 --> 00:04:07,700 And the person who came up with this method also described a correct method of doing that. 53 00:04:07,740 --> 00:04:09,240 I should just say, because his paper was very nice. 54 00:04:11,380 --> 00:04:13,840 The second mistake to make, which is probably worse. 55 00:04:14,240 --> 00:04:20,360 Is to use a counter on some microcontroller or computer. 56 00:04:21,160 --> 00:04:24,760 And then use the particle detector. 57 00:04:24,880 --> 00:04:26,480 Or a particle detector I should say. 58 00:04:26,640 --> 00:04:28,080 As a CPU interrupt. 59 00:04:28,400 --> 00:04:30,400 And then it outputs whatever number the counter is at. 60 00:04:30,620 --> 00:04:34,340 Now the problem with that is that when you deal with particle detection statistics. 61 00:04:34,780 --> 00:04:40,960 The time between detections is defined not by a random distribution but by a Poisson distribution. 62 00:04:41,500 --> 00:04:47,440 And this means that there's some average value of time between the particle detection events. 63 00:04:47,940 --> 00:04:50,240 Which is more likely than other times. 64 00:04:50,480 --> 00:04:54,120 So the numbers you output, the difference between them is defined by a Poisson distribution. 65 00:04:54,880 --> 00:04:55,180 Which is very bad. 66 00:04:57,280 --> 00:05:03,280 Now the last thing you should not try to do is try to calculate the expected time between particle detection events. 67 00:05:04,320 --> 00:05:06,260 Because it's going to vary over time. 68 00:05:06,980 --> 00:05:09,280 And you don't know exactly how many atoms there are. 69 00:05:09,460 --> 00:05:12,140 And you don't know your detector efficiency with absolute precision. 70 00:05:12,440 --> 00:05:15,080 So not only will you have a bias, you will no longer know what it is. 71 00:05:16,760 --> 00:05:19,800 Now our design doesn't have that many groundbreaking developments. 72 00:05:20,240 --> 00:05:22,000 It has two things which are very convenient however. 73 00:05:22,500 --> 00:05:24,560 It has a solid state particle detector. 74 00:05:24,880 --> 00:05:25,920 So it lets you use same voltages. 75 00:05:26,680 --> 00:05:29,300 Like it's much easier to deal with in vacuum tubes. 76 00:05:30,100 --> 00:05:31,620 Like Geiger-Muller tubes I should say. 77 00:05:32,300 --> 00:05:35,200 And secondly it has a dedicated microcontroller that does the sampling. 78 00:05:35,400 --> 00:05:41,420 So you don't have to worry about complex timing issues in a multitasking operating system you might connect this to. 79 00:05:42,220 --> 00:05:44,180 So you can just plug it in, sample it and it works fine. 80 00:05:45,600 --> 00:05:48,560 This is a circuit diagram which you may not be able to see very well. 81 00:05:49,640 --> 00:05:53,240 Basically the first part to the left is the primary detector circuit. 82 00:05:53,240 --> 00:05:55,520 Which I'll describe more later. 83 00:05:55,640 --> 00:05:59,400 It has to be enclosed in a Faraday cage to block out external noise. 84 00:05:59,580 --> 00:06:01,540 Which would completely drown out the signal otherwise. 85 00:06:02,320 --> 00:06:06,620 Then you have two more operational amplifiers that make the signal a usable voltage. 86 00:06:06,880 --> 00:06:11,160 There is a potentiometer that compensates for DC bias. 87 00:06:11,840 --> 00:06:15,020 However this is a bad design decision and I regret doing it. 88 00:06:15,660 --> 00:06:16,740 However it does work. 89 00:06:18,140 --> 00:06:21,720 Finally you have pulse shaping and sampling stages afterwards. 90 00:06:23,240 --> 00:06:26,380 The circuits I made out of flex PCB because it's great for rapid prototyping. 91 00:06:26,560 --> 00:06:31,540 And I've included here a couple of nice pictures of some boards just because they're very pretty. 92 00:06:33,880 --> 00:06:36,500 Now the core of the particle detector is a pin photodiode. 93 00:06:36,580 --> 00:06:37,980 And this is like a small solar panel. 94 00:06:38,140 --> 00:06:42,640 If you apply something of enough energy to one end you knock loose a few electrons. 95 00:06:42,880 --> 00:06:45,260 And you can detect this as a voltage difference between the two ends. 96 00:06:45,580 --> 00:06:49,480 So you use a differential, what's called a transimpedance amplifier. 97 00:06:50,940 --> 00:06:52,540 Which is basically an op amp. 98 00:06:53,620 --> 00:06:58,380 To amplify that difference to a usable signal which you can see as an oscilloscope trace on the screen. 99 00:06:58,480 --> 00:07:00,420 You have a spike and then a logarithmic decay. 100 00:07:04,200 --> 00:07:04,800 There we go. 101 00:07:05,340 --> 00:07:09,440 Afterwards when you have this usable voltage you do a little bit of pulse shaping to make it easier to sample. 102 00:07:09,640 --> 00:07:11,340 And for this I just use a Schmitt trigger hex inverter. 103 00:07:11,800 --> 00:07:15,240 So you see that when there's a spike which would be hard for the microcontroller to catch. 104 00:07:15,400 --> 00:07:17,960 It translates into a bit bigger logic pulse. 105 00:07:18,820 --> 00:07:22,640 And I have a nicer, this is what it looks like on a bigger sample. 106 00:07:23,240 --> 00:07:23,540 Very pretty. 107 00:07:24,860 --> 00:07:28,340 Now the sampling algorithm is where things get, you have to pay more attention. 108 00:07:30,540 --> 00:07:35,720 Basically what it does here is it measures the time between two particle detection events. 109 00:07:36,020 --> 00:07:37,120 And then it does that again. 110 00:07:37,300 --> 00:07:39,660 So you have two times between particle detection events. 111 00:07:39,880 --> 00:07:40,900 And you compare them together. 112 00:07:41,580 --> 00:07:44,120 And if the first time is larger you output a one. 113 00:07:44,260 --> 00:07:46,060 If the second time is larger you output a zero. 114 00:07:46,280 --> 00:07:47,500 I didn't come up with this myself. 115 00:07:47,800 --> 00:07:49,100 Several other people have done this before. 116 00:07:49,360 --> 00:07:50,420 It works very well. 117 00:07:50,420 --> 00:07:56,220 And the reason is the time between particle detection events is defined by a Poisson distribution. 118 00:07:57,020 --> 00:08:03,080 But the time between two particle detection events have a very, very similar Poisson distribution. 119 00:08:03,300 --> 00:08:05,600 So you can compare the two to get a nice random distribution. 120 00:08:07,760 --> 00:08:12,700 The demonstration won't be happening because the microcontroller died on its journey here. 121 00:08:12,860 --> 00:08:15,680 However if you'd like to play with the detector later that will be possible. 122 00:08:18,680 --> 00:08:20,260 Now once you have output. 123 00:08:20,260 --> 00:08:24,400 You need to analyze it otherwise you might find out that it's meaningless. 124 00:08:25,380 --> 00:08:29,700 And you start by creating basic frequency charts to make sure you have no missing numbers. 125 00:08:30,940 --> 00:08:38,460 And you can also try to recreate the binomial distribution by plotting the frequency of averages of sets of numbers. 126 00:08:39,780 --> 00:08:45,600 And while doing these things you have to keep in mind that proving randomness is impossible using traditional hypothesis testing statistics. 127 00:08:46,020 --> 00:08:48,880 What you're really doing is looking for problems that you expect to have. 128 00:08:48,880 --> 00:08:50,520 And then fixing them if they come up. 129 00:08:51,540 --> 00:08:57,900 This is a frequency chart for the first 60,000 random numbers generated with the generator. 130 00:08:58,200 --> 00:09:00,080 And we didn't see anything unexpected. 131 00:09:01,140 --> 00:09:03,960 Then I took 10,000 means of six digits. 132 00:09:04,220 --> 00:09:07,860 And graphed them and we get approximately the binomial distribution. 133 00:09:09,740 --> 00:09:14,720 So everything seems to be working fine in terms of simple distributional problems. 134 00:09:16,000 --> 00:09:18,760 So I subjected it to a more advanced analysis. 135 00:09:18,880 --> 00:09:21,540 Using the NIST test suite 2.0. 136 00:09:21,580 --> 00:09:23,120 Which is very nice and well documented. 137 00:09:23,760 --> 00:09:25,320 And easy to use I should add. 138 00:09:25,960 --> 00:09:31,100 And I subjected 100 megabits of random number generator output to these tests. 139 00:09:31,240 --> 00:09:33,560 With an alpha value of .01 which we'll get to later. 140 00:09:34,600 --> 00:09:36,940 Although I couldn't get the last test working. 141 00:09:37,280 --> 00:09:38,540 The 188th test. 142 00:09:38,680 --> 00:09:40,840 So I just sort of ignored that. 143 00:09:42,180 --> 00:09:47,600 Now the thing about alpha values is when you're talking about hypothesis testing statistics. 144 00:09:47,600 --> 00:09:51,900 It's the chance of random data. 145 00:09:55,000 --> 00:09:56,460 Let me start that one over. 146 00:09:56,660 --> 00:09:57,900 Because it's an important point. 147 00:09:58,260 --> 00:10:00,400 If you have an alpha value of .01. 148 00:10:00,600 --> 00:10:08,440 It means there's a 1% chance of in this case true random data failing that particular test for non-randomness. 149 00:10:08,880 --> 00:10:12,640 And so you actually have an expected failure rate for random data. 150 00:10:13,100 --> 00:10:17,360 And so given 187 tests. 151 00:10:17,360 --> 00:10:20,660 Run 100 times on 1 megabit each. 152 00:10:20,760 --> 00:10:23,060 We expect 187 failures. 153 00:10:23,320 --> 00:10:24,680 And we observe 205. 154 00:10:24,880 --> 00:10:26,720 Which is not a significantly different number. 155 00:10:27,060 --> 00:10:28,920 So things seem to be okay on that point. 156 00:10:29,180 --> 00:10:30,360 But much more importantly. 157 00:10:30,580 --> 00:10:33,480 The failures didn't cluster on any specific test. 158 00:10:33,680 --> 00:10:37,980 So there seems to be no specific problem with the output as measured by this test suite. 159 00:10:39,720 --> 00:10:41,760 Now I was originally going to talk about this a bit more. 160 00:10:41,960 --> 00:10:45,280 But I only found out recently that the people from NIST are actually just down the hall. 161 00:10:45,440 --> 00:10:46,660 And they have a really cool system. 162 00:10:46,660 --> 00:10:47,780 That's a bit better than this. 163 00:10:49,800 --> 00:10:51,120 And if you haven't seen it yet. 164 00:10:51,160 --> 00:10:51,780 You must go. 165 00:10:51,920 --> 00:10:52,480 It's really neat. 166 00:10:53,600 --> 00:10:58,300 However, I still think there's a possibility for hobbyists to build a quantum true random number generator. 167 00:10:58,500 --> 00:11:00,480 Based on single photon detection. 168 00:11:01,820 --> 00:11:02,900 Using photomultiplier tubes. 169 00:11:03,240 --> 00:11:05,220 Which unfortunately are vacuum tubes. 170 00:11:05,720 --> 00:11:07,540 So they, well, okay, slash fortunately. 171 00:11:07,720 --> 00:11:08,520 If you like that sort of thing. 172 00:11:10,700 --> 00:11:13,440 But it requires high voltages. 173 00:11:13,880 --> 00:11:15,180 And some tricky electronics. 174 00:11:15,680 --> 00:11:16,640 But you should be able to do it. 175 00:11:16,640 --> 00:11:20,660 You should be able to detect single photons with an efficiency of about 30% if you choose your tube carefully. 176 00:11:23,000 --> 00:11:26,060 And other advantages are that you can increase the bandwidth drastically. 177 00:11:26,760 --> 00:11:30,740 The bandwidth of the device I built, if you tune it well, is about 75 bytes per second. 178 00:11:31,080 --> 00:11:37,820 The one they have in the room a couple of doors down is 6.2 orders of magnitude faster. 179 00:11:38,140 --> 00:11:39,860 So this is a very attractive method. 180 00:11:40,480 --> 00:11:41,760 It's more expensive, though. 181 00:11:43,220 --> 00:11:43,820 All right. 182 00:11:43,940 --> 00:11:44,480 Well, finally. 183 00:11:44,480 --> 00:11:47,360 I'd like to thank, I'm from Fulab, the Montreal hacker space. 184 00:11:47,600 --> 00:11:51,840 And I'd like to thank them for providing a space to work in and friends to work with. 185 00:11:52,040 --> 00:11:58,020 And finally, my friend there, FX, who helped me design a driver for the true random number generator. 186 00:11:58,160 --> 00:12:00,720 As well as some data management scripts that saved me many hours of work. 187 00:12:01,760 --> 00:12:08,740 If you want to make one of these yourself, I'm trying to make a board that is suited to experimenting with this sort of thing. 188 00:12:09,180 --> 00:12:14,320 I'm going to try to make it available at, or at least information about it available at this website within about a month. 189 00:12:18,900 --> 00:12:19,420 So you can go look for it! 190 00:12:19,420 --> 00:12:21,420 Yeah, it is blue on black. 191 00:12:21,540 --> 00:12:22,200 That's very unfortunate. 192 00:12:23,380 --> 00:12:24,700 I thought it would look better. 193 00:12:24,760 --> 00:12:25,120 It doesn't. 194 00:12:25,460 --> 00:12:28,180 It should say legion heavy industries dot com. 195 00:12:29,480 --> 00:12:31,760 But the presentation is available for download. 196 00:12:33,120 --> 00:12:35,500 My references are similarly difficult to see. 197 00:12:35,580 --> 00:12:36,520 But they're very interesting. 198 00:12:36,640 --> 00:12:39,840 And you should go check them out because they'll provide literally minutes of entertainment. 199 00:12:40,540 --> 00:12:44,460 Specifically the photo diode datasheet is particularly interesting. 200 00:12:44,460 --> 00:12:57,740 interesting. Thank you very much. And for the remainder of the time left, I'll field 201 00:12:57,740 --> 00:13:01,160 any questions until they kick me out. Yes, over there. 202 00:13:07,160 --> 00:13:19,920 Oops, can you speak up just a little bit? Are you asking whether, I can't quite, can 203 00:13:19,920 --> 00:13:30,920 you speak up a bit more? Yeah. He's asking whether, 204 00:13:31,160 --> 00:13:35,960 when detecting single photons, you would have problems with electronic interference from 205 00:13:35,960 --> 00:13:41,040 nearby devices. And yes, you would. But you actually have even more complicated problems 206 00:13:41,040 --> 00:13:44,880 when you deal with detecting single photons, because there's a background noise that you 207 00:13:44,880 --> 00:13:52,420 can't eliminate, which I don't understand very well. But at the very least, you'd have 208 00:13:52,420 --> 00:13:56,980 to build everything in a Faraday cage again. Yes, over there. 209 00:13:57,180 --> 00:14:00,000 So you can propose the source of these particles? 210 00:14:00,360 --> 00:14:01,000 Oh, okay. 211 00:14:01,160 --> 00:14:03,740 I thought somebody might ask that. Would you like to guess? 212 00:14:05,260 --> 00:14:11,920 Okay, it's the Amorous 241 from a smoke detector. Yeah, it's, yeah. No special license required. 213 00:14:12,700 --> 00:14:13,440 Yes, over there. 214 00:14:15,240 --> 00:14:18,200 Oh, thank you. Do we have any other questions? 215 00:14:20,220 --> 00:14:24,960 Okay. Well, if anybody would like to join me to play with the particle detector, which 216 00:14:24,960 --> 00:14:29,980 does work, I will meet you outside this room and we'll find somewhere we can sit down. 217 00:14:30,080 --> 00:14:30,880 I brought my oscilloscope. 218 00:14:31,160 --> 00:14:31,180 Okay. 219 00:14:31,180 --> 00:14:32,560 And you can see what the output looks like. 220 00:14:33,440 --> 00:14:34,380 Where's the NIST one? 221 00:14:34,540 --> 00:14:35,340 The NIST one? 222 00:14:35,560 --> 00:14:37,840 Uh, it's on your map. 223 00:14:41,000 --> 00:14:41,440 . 224 00:14:48,980 --> 00:14:49,420 Good? 225 00:14:50,380 --> 00:14:50,820 Excellent. 226 00:14:51,140 --> 00:14:51,580 Thank you. 227 00:14:51,660 --> 00:14:52,400 Thank you.