JavaScript for Cyborgs
CC Attribution 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Moe, Katy
Cyborgs are all around us, and they're becoming self-aware. This talk uses NFC as a demonstration of opportunities and pitfalls of open hardware for the human body. Our live-coding journey will take us through an intro to NFC protocols by building an app for the NFC transponder implanted into my hand.
 Okay. Good afternoon, everyone. My name is Katie Moe. This talk is called JavaScript for Cyborgs. You'll find out why in a moment. So I decided to call this talk JavaScript for Cyborgs because I consider myself a Cyborg. I have an NFC chip implanted into my left hand between the thumb and the forefinger. I'm considering implanting magnets into my fingertips with the scalpel. Not sure whether I want to do that yet. Maybe you guys can help me decide. And I'm also someone who considers biohacking and grinding as it's called the new forefront in human evolution. Okay. So what does this all mean? This little thing on the lower left corner of the screen is the chip. It's actually 12 millimeters by 2 millimeters wide. I blend it up there. The thing on the right is my hand. And this is the little packet it came in. So the NFC chip, I bought it from something called Dangerous Things. It arrived in a customs marked box saying this package must not contain any dangerous items. The branding somewhat sort of offset that. So this is where it gets a little bit more gory. It came in a 10G syringe and that was inserted into my hand. I'm going to show you the short sort of animation of the procedure here. Anyone who's fainted should be taken out. Great. Okay. So what is the sidewalk? And what am I talking about? Biotchics are people who are biohackers, people who have implanted things into their body, but they're also people who have pacemakers. People who have bionic limbs or have augmented their body or improved their body in a way that involves meshing with technology in some way. So I have a kind of two-part definition of what a cyborg is. And I'm going to give you the first part now and the second part later. The first part is a cyborg is someone who has augmented their body's capabilities using technology. So I like to say that someone's become a machine and mensch if you understood my German. Thank you. Cyborgs are not a new thing. People have been augmenting their bodies with technology for centuries, perhaps millennia, but the internet and wireless communication has enabled a new acceleration in the capabilities of the human body. I can effectively, though not directly, connect myself to the internet using this technology and we're going to show you how later. In fact, this talk has a small interactive component. So if any of you have a laptop and you know how to make an HTTP post request, then you may want to have your curl or your postman client open just in case you want to participate in the demo in a bit. So I don't have my speaker notes for this, but luckily it's on the screen. So I mean, I like this quote from Sadie Plant, zeroes and ones, which is a book about cyborgs a few years ago, because it really talks about how the future is going to involve people who already accept that we are in mesh with technology and that technology is something that has already taken control of our lives and something that we should take control of in a more direct way as well. So this talk is kind of my preliminary research into an area which I've seen in scattered corners of the internet but haven't really seen brought together. And it's an idea of an API for the human body itself. It's also about how we can use JavaScript, because that's what this conference is about, to interact physically with something that is inside my body. JavaScript has been used to interact with Internet of Things and Arduino hardware for a few years. You may be familiar with Johnny 5 if you came to the round table discussion yesterday, but I think this is something a little bit new. So I'm going to give you a quick introduction to what NFC is. NFC is the technology which is involved in the little one-centimeter pill in my hand. It stands for NeoFIL communication. So it's radio communication. It's radio waves at 13.56 megahertz. The range is very small. It's one to four centimeters. So in the UK, we have these things called oyster cards, which you use to touch on the reader when you're trying to get on the tube. And they're heralded as a contactless form of payment. In fact, you can just hover your card one centimeter above the reader, and it will register it as a reader. In reality, sometimes you have to touch it on the reader, and later when you see me use this device to connect to the hand, you'll notice that I have to bring it quite close. This may assuage some of the security concerns when it comes to actually storing data on this thing, but in effect, I don't think it's really a secure medium, but I'm going to go into that a bit later. So the tags are passive. This is really important because it means I don't have to put a battery inside my body. People have done, people have made devices which involve LEDs and vibrations and things like that. Sometimes these have to be powered by batteries that only going to last a few years. While I deeply respect these people and what they're doing, I wanted to have something that was going to be, if not permanent, maybe something that was going to not have the kind of obsolescence that we're used to with technology like a laptop that will expire after three years. I expect this will last hopefully a little bit longer than that. They have hard-coded, unique IDs, and there are these things called end-def records. So each tag, when it's manufactured, is given a unique ID which can't be changed by the user. That's the intention. In reality, sometimes you can clone tags, you can get doggie chips from China which are able to change their unique IDs. The manufacturers of NFC chips tend to counter this by signing them cryptographically or using other forms of sort of higher-level security. End-def records are the NFC data exchange formats. So what that means is that when you store the data on this thing, you need to have some sort of way of agreeing on how you're going to read and write the data. The data is stored on the chip, but unless you know how you've encoded it, then you don't really have much hope of being able to understand it. So I'm going to go into end-def records later because they're the kind of universally agreed standard for how you should store multiple bits of data on one NFC tag. So the uses of NFC. I've already described you oyster cards in London. We contact this payment as another one. So I'm not sure if you have this in Germany, but you can have a credit card which you just tap on the reader to pay for anything under £30. I see you nodding. That's great because it's a really great technology. I mean, it's kind of great until you discover that people have been sneaking up to other people on the tube and using a card reader to kind of quickly skim £20 from each person. So this is one reason why I didn't go down the avenue of actually storing money on this. There is a guy who has, I believe, made a Bitcoin payment with the chip in his hand. The chip probably stores the private key and is used as an extra authorization step in a Bitcoin flow involving a separate app. The important thing to know here, I guess, is that the chip can't perform any processing. It's merely a passive data storage medium. Great. Okay. So let's get a bit more practical. This is the PN532 breakout board, which I bought from Adafruit. It's actually this big. So those of you at the back may have some difficulty seeing a bit of the demo, but the code will be on the screen, so it should make sense. What is this? It's an NFC antenna, so it can read and write. I think also emulate NFC tags. NFC tags have three, well, NFC devices have three modes. Read or write a mode like this. This is the fully capable device. This is powered and it's able to issue effectively commands and send data over the wire. There are the passive tags like the one in my hand, and there are emulation modes, so this could pretend to be a passive tag. That's not as interesting, I guess. Great. Okay. So I want to talk about the demo that I'm going to do today. I have a couple of things that I've been doing as part of my research. So one of them is the demo I'm going to show you. So the difficult thing about reading NFC on a device like a laptop is that you don't really have, there's no native NFC antenna in this thing. I don't know of any laptops that really have one. So I had to connect this PN532 to the laptop. So it doesn't look too bad. I mean, it's just a USB cable, but the actual form of communication used is over an FDTI cable, which uses serial. So the computer has to have a serial driver in order to use that. And doing that on JavaScript, whether or not that was a wise idea, I guess you can judge for yourselves, will require some special libraries and require a little bit of fiddling around, which I'm going to show you the results of, at least maybe not the whole journey, because that would take too long. Okay. So JavaScript, I'm going to show you the little ecosystem I've used to build up some of my demos. Not all of them are in the demo that we're going to see right now. But yeah, so I just thought I'd show you my stack. Yeah. I mean, some of these are fake, but this is modern JavaScript. Okay. Right. Okay. Let's go to JavaScript. Okay. I'm going to resize this until it's about right. Can anyone not see that? Okay. Great. So I've just got the kind of shell of what we're doing here. Okay. Let's start live coding. So the aim of this demo, this first part of the demo is to read from the NFC chip in my hand using some code in JavaScript running on the computer. That's the kind of parameters of what we're doing here. So we're node the moment. So let's go and require some libraries. That's the first thing we want to do. So the first thing we're going to grab is this serial port constructor from a library called node serial port. This is incredibly useful because as you can see, that was easy to require. And now we have all the capabilities of the low level drivers that we need in order to communicate over this FDTI cable with the PN532, which as you recall is the board I got from Adafruit. There's another library we're going to use. I'm going to grab the constructor from that, which is the one for this particular board. So PN532 also has a node library kind of written by someone doing something similar to me without the biohacking component. And finally, we're going to use an NDEF library. So if you remember from before, NDEF is the data format that we encode the things on the NFC tag in. This is just simple sort of buffer to string conversion along with a lot of futzing around with arrays. So hopefully that will work fine and we won't have to delve deeper into the NDEF format at the kind of by each level. So these two lines here that I've pre-written are the address of the device as it is seen by my machine. So if I go to, in fact, let's do this. I'm not sure if you can see this. Sorry. Well, if I write, if I ls my dev, these are all my dev devices, you might not be able to see that. But what there is one that you probably won't see on your device, which is this USB serial with serial number there. That's what I got to pin into this constant here. The board rate, if you've done a bit of electronics, you'll know what that is. If not, it's basically the kind of rate of symbols traveling across the wire. It's just a constant that we have to set in order to correctly listen to the signals coming from the serial port. Great. So let's initialize the object that is going to give us access to the PN532. Excuse me. I mean this. Okay. So all we need to do is give it the device and the board rate. Now we've got the serial port and the PN532 library, really easy to use. We now all we have to do is wrap the serial port in that. Okay. So let's do something that actually runs the code. Okay. So we use this kind of event handler like API in order to establish that the board is ready. So the first thing you need to do is check it's connected to the computer. So excellent. Nothing is happening. I like to think of live coding more as sort of, yeah, you're right. I like to think of live coding more as sort of high stakes, pair programming. Sorry? Yeah. Yeah. Great. Okay. So now it says ready. Okay. So what we established is that this thing with the red light on it is actually connected to the computer. What we established before that wasn't that nothing was happening but that there were no errors. Okay. Cool. So now what we want to do is detect a tag. So here are a couple I made earlier. They're not actually in my hand and I want to show you that I've got different tags with different IDs on them. This is the first thing to establish because if they all have the same ID then there's no way we can identify me by the tag that's particularly in my hand. So when it's text tag, we have, we get this tag object. And what we're going to do with that is we're just going to log it. Just see what it looks like. Okay. So the board is ready. I'm going to scan it on my hand. Great. So we've got an object. This is not a particularly pretty object but the important thing to see is the UID here. So this is the unique ID of the tag that is inside my hand. I hope there's no other tag in the world that has this ID, at least not one made by the same manufacturer. And if there is, then my two-factor authentication demo probably won't work but I'll show you that in a minute. Okay. Great. So now we've got the tag. What we want to do now is read the data off it. And so it could be this easy. So what we want to do now is read the end of data. I mean, the end of library and the serial port and PN532 library is a great. There's a kind of mix of API styles. We've got a promise going on. And just pass it this and imagine we're using callbacks. Okay. So let's have a look at the data on this thing. So what data is actually on the hand? Sorry. I don't know why I have to keep zooming in. Great. So we've got to load data. This is really a buffer representation which if you've done a bit of Node or anything at a slightly lower level, you'll recognize as something that is not as easy to read as something that isn't encoded. So let's try to decode this thing. So what we need to do is use the end of library. This is the function of the end of library. So this is the buffer that's on the device. And now we need to try to decode it according to the rules defined in the end def specification. Which all sounds very complicated, but thankfully we've got the library to do it for us. So let's decode the message. We need to sort of futz around a bit with this. That's just the form I expect the data in. So let's actually look at that now. Great. Okay. We have something that says JavaScript for Cyborgs, but we also have a load of other stuff. We have a TNF, a type ID payload, all this stuff. There are actually two records on this chip. So on the chip in the hand, there are these two objects in the array. It's rather hard to see. And each of them contains this payload of bytes and the actual value of the record. So end def records can be of various different types. You can have a URL record, a text record, contact record, all sorts of things. It used to really cool applications like having to be able to have your business card on your hand. The first guy I met with one of these, I tapped my Android phone on his hand and his contact info just came up and I thought that was such magic, but I wanted to get my own one. I never realized it would lead me to this JavaScript journey, but here we go. So what I'm going to do finally is just map that so that we can just see the value of the data. We don't need to see the payload. We don't need to see the TNF, the type, or that kind of thing. The demo I want to show you today is just that we can write to the chip and read from the chip. Sorry, I'm getting ahead of myself. Read from the chip. Okay, so, yeah, message is fine. So actually what we want is, forgive my JavaScript variable naming. No, we don't want that. Okay. So we just want to see the value of each one and that's what it's called, right? Great. Let's just check that. Yeah, great. Okay, so now we've got an array with two objects in it with just two values. Okay. So we can read from the tag. We can read from the data that's in my hand. There's not very interesting data in there at the moment. All it is is a URL and a value. If you tapped your phone on this, the URL would come up. So my website would come up in your phone and the browser would immediately try to load it with no permissions or anything like that. That's an awesome way of bypassing the control people think they have over their phone. Okay, cool. So now let's move to the right demo. Okay. I've got another demo here. And what I want to show you now is that we can write data to the tag. So this is where I wanted you to have your curl client or your postman client ready because what we're going to do is you're going to curl or post to an endpoint and it's going to end up inside the hand. So whatever you post, hopefully I've sanitized it enough that you can't actually break anything, but we'll see. We'll end up inside the hand. It's kind of last come, first serve. So the last person to post to that endpoint will end up with the data inside my hand and then everyone can read it later. So it's a kind of reverse race. I'm going to just put the URL at the top of the screen here. So you want to post to... So just post a raw message body to that. It doesn't need JSON or anything. If you do it JSON, it will be stringified anyway. So if you send a post request to that, then we'll see what's on there in a bit. But let's get on with the demo while you're doing that. Cool. So I've required a lot more libraries here. I didn't feel the need to write this out again while live coding. So all we've got that's different from last time is that we've got the request library. We're going to use this to make a request to this, which when I make a get request to it, set the server... Not yet. I set the server to just repeat to me what was last sent to that endpoint. Just kind of echoing it. Great. So as before, we've got these event handlers. So when the PN532 is ready, it will log PN532 ready. And on tag, it will log the tag with the UID. So let's just check that this works. PN532 is ready. Sorry. Tag detected with UID. Great. So I'm just going to prove to you that this isn't a fake demo. We've got a different tag there. It's got a different ID and another one. So the N tag 216 is just the exact tag that is the type of tag that is in my hand. Great. So I'm not going to put in the stuff about the endpoint yet. Let's just get it in with encoding all the data that we need to do. Okay, great. So let's just call it message to write. Great. So we're going to try to write this data onto the tag. So what we could do is we could just say... So we could attempt to send the data to the tag like this and we could say... That's probably not going to work. And it's definitely not going to work because we haven't actually encoded the data into the right format. So let's actually define a message array where the first member is a URL record. I'm doing this so that when someone actually scans my hand with their phone, it comes up with a URL which I think is cool, rather than just coming up with the text. Oh, URL record. Great. Right. And the final record, the last record, will be the message that we want to write. So it will be a text record. So as you can see, we've got these types defined in here already. These just correspond to the types in the end def spec. Great. So what we need to do is actually encode these messages into the right format. So that's as easy as end def dot encode message. And then we want to call this. And now we want to write the encoded messages to the tag. So I've learned while developing in this way that the best way to test these things out is probably not in the chip inside my hand. I'm slightly worried occasionally about breaking it somehow or finding some way to write corrupt data onto it. While I can't find any way of doing that, I don't particularly trust my own node skills. So we're just going to write this data to this tag. Cool. What I've forgotten to do as this is live coding is actually get some sort of verification that we've written the data. So again, this is a promise-based API. And there's a response, but it's usually undefined. So let's just assume it's going to be fine. And true JavaScript error handling style. Great. The write was successful. So what we can do is we can check using the read script if we don't actually trust that we've written it on properly. So let's just quickly run the script. Great. So the value is hello, enter JS. Because we haven't actually requested it from the endpoint yet. Great. Okay. So I'm going to go on to the write code. Okay. So we're almost at the end of this demo, and the final thing I want to do is just see if anyone's posted to this endpoint and see what kind of data that ends up on my hand. I'm quite excited to see what kind of things people have put on there. Hello is sufficient. Okay. So the message we actually want to write comes from that endpoint, and we just need to send a get request, which is easy with request. And it's just, yeah. So we make a get request to that. There's a load of parameters and a body. So actually what we want. Okay. The body is the most important thing, which is why I don't think the other parameters need to be logged. So we can log what's in the body, but what I want to do is actually set it to be the message to write to the tag. So let's stick all this code in here and actually set the message to write to be the body. Which I mean that. It's not long the body. Okay. So now what we've got is we've got a request going off to an endpoint. Somewhere on the Internet. We're going to get some data from the Internet. We're going to grab it and run some JavaScript through the drivers and everything to get it into the hand. So I think the implications of this are quite interesting because, for example, there's a number which is illegal to store. Well, I don't think it's illegal to store, but it's illegal to share this number because it was used in DVD encodings in the 90s. I want to know what the implications would be legally or otherwise of putting that number inside my hand. Smuggling it into the U.S. Smuggling it into any sort of facility which would just involve me walking into the facility. I think this is really interesting. So if someone's put something illegal on there, then we're going to find out maybe very soon what the implications of that would be. But let's just see what it is. So we're going to write this data to a tag. That seems successful. We're going to write the data to my hand. Okay. The write was successful. Let's see what it is. So, we finished writing the data. Let's go and read some data. JavaScript. Excellent post request. Thank you. Great. So I'll probably monitor this throughout the day and see what else happens. Okay. Great. So I'm going to go back to my presentation now as I'm probably running out of time. So, and I still don't have any speaker notes. Hey, I haven't finished. So, thank you. I have another demo here. It's not a live coding demo, so it won't take as long. But I'm just going to really rush through it because I have five minutes left to this presentation. So two-factor authentication is a method of authentication where instead of the user just entering a password, they enter a password plus they do something else. They enter a code that you've got on your phone or they enter a code that was sent to them in some other way or they respond to a push notification. What if the second factor in this two-factor authentication flow were the ID of the chip in my hand? So I built this demo. Basically, don't curl this endpoint yet because I'm not monitoring the... you scan the tag and then it will receive a reply as to whether or not the person who scanned the tag was me and the way it tells is just by the ID of the chip. So this suffers from all the things we had before. I mean, I made a web sequence diagram, but other people's web sequence diagrams... I mean, hell is other people's web sequence diagrams, really. So the future I want to see in this kind of research. So this, as I say, is just the beginning of the research I'm doing into this area. There are a number of open questions which I think we should all think about whether or not we decide to become sidewalks ourselves. So you may have noticed in the two-factor authentication demo and the other demo, indeed, but these are all particular to me unless you've also got a chip in your hand with exactly the same specifications or at least that obeys the same specifications, you can't participate in this. I think it's interesting and a reflection of the wider internet of things situation that we have was essentially World Gardens and a way of stopping devices from communicating with other devices over the internet, which was indeed the idea to begin with. So I'm going to skip the rest of this. Another interesting implication here is that I now have something in my hand apart from my fingerprints, which is uniquely identifies me. So if I go somewhere, then I'm going to find that the... and someone scans the tag, then someone knows I've been there. This is important to me, it may be some sort of privacy concern, but what I think is interesting is that the chip is not really any more identifiable than my fingerprints and not really any more likely to be left at a location. So as I say, the read range of the chip is less than four centimeters. So what happens is someone shakes my hand or something, they scan the chip, they get the data off it, you can encrypt the data on it with a 32-bit password, but unfortunately it's... oh, I think those are my speaker notes. Thank you. The final thing I want to say, thank you. I actually... yeah. Thank you. No, that's fine. I really appreciate that because I have a really good example from this last slide. As you can see, I had a lot to say. So I was at the tape modern the other day and I met an artist called Chloe Spicer. What she does is she explores the possibilities of embodied data. She focuses on books. Books are her focus as a librarian. So she wears books, she consumes books, she eats books, she wants to become data embodied in a book. I thought this was really interesting and kind of relevant for me as well. So you may say that 888 bytes of data isn't a lot, maybe the human brain can store terabytes of data though in a slightly different format than a computer. DNA can encode data, but like thoughts, I can't directly access them. I can't have the same thought twice and I can't access the data encoded in my DNA. So to have a persistent data storage device in my hand which can store an exact amount of data and will do so for the foreseeable future is, I think, a capability that my body didn't have before. And that's what's interesting about this. I think although it's a small step, it's a step towards augmenting our bodies and transcending our previously human limitations. Thank you. Thank you. Thank you. Thank you.
 Okay.  Good afternoon, everyone.  My name is Katie Moe.  This talk is called JavaScript for Cyborgs.  You'll find out why in a moment.  So I decided to call this talk JavaScript for Cyborgs because I consider myself a Cyborg.  I have an NFC chip implanted into my left hand between the thumb and the forefinger.  I'm considering implanting magnets into my fingertips with the scalpel.  Not sure whether I want to do that yet.  Maybe you guys can help me decide.  And I'm also someone who considers biohacking and grinding as it's called the new forefront  in human evolution.  Okay.  So what does this all mean?  This little thing on the lower left corner of the screen is the chip.  It's actually 12 millimeters by 2 millimeters wide.  I blend it up there.  The thing on the right is my hand.  And this is the little packet it came in.  So the NFC chip, I bought it from something called Dangerous Things.  It arrived in a customs marked box saying this package must not contain any dangerous  items.  The branding somewhat sort of offset that.  So this is where it gets a little bit more gory.  It came in a 10G syringe and that was inserted into my hand.  I'm going to show you the short sort of animation of the procedure here.  Anyone who's fainted should be taken out.  Great.  Okay.  So what is the sidewalk?  And what am I talking about?  Biotchics are people who are biohackers, people who have implanted things into their body,  but they're also people who have pacemakers.  People who have bionic limbs or have augmented their body or improved their body in a way  that involves meshing with technology in some way.  So I have a kind of two-part definition of what a cyborg is.  And I'm going to give you the first part now and the second part later.  The first part is a cyborg is someone who has augmented their body's capabilities using  technology.  So I like to say that someone's become a machine and mensch if you understood my German.  Thank you.  Cyborgs are not a new thing.  People have been augmenting their bodies with technology for centuries, perhaps millennia,  but the internet and wireless communication has enabled a new acceleration in the capabilities  of the human body.  I can effectively, though not directly, connect myself to the internet using this technology  and we're going to show you how later.  In fact, this talk has a small interactive component.  So if any of you have a laptop and you know how to make an HTTP post request, then you  may want to have your curl or your postman client open just in case you want to participate  in the demo in a bit.  So I don't have my speaker notes for this, but luckily it's on the screen.  So I mean, I like this quote from Sadie Plant, zeroes and ones, which is a book about cyborgs  a few years ago, because it really talks about how the future is going to involve people  who already accept that we are in mesh with technology and that technology is something  that has already taken control of our lives and something that we should take control  of in a more direct way as well.  So this talk is kind of my preliminary research into an area which I've seen in scattered  corners of the internet but haven't really seen brought together.  And it's an idea of an API for the human body itself.  It's also about how we can use JavaScript, because that's what this conference is about,  to interact physically with something that is inside my body.  JavaScript has been used to interact with Internet of Things and Arduino hardware for  a few years.  You may be familiar with Johnny 5 if you came to the round table discussion yesterday, but  I think this is something a little bit new.  So I'm going to give you a quick introduction to what NFC is.  NFC is the technology which is involved in the little one-centimeter pill in my hand.  It stands for NeoFIL communication.  So it's radio communication.  It's radio waves at 13.56 megahertz.  The range is very small.  It's one to four centimeters.  So in the UK, we have these things called oyster cards, which you use to touch on the  reader when you're trying to get on the tube.  And they're heralded as a contactless form of payment.  In fact, you can just hover your card one centimeter above the reader, and it will register  it as a reader.  In reality, sometimes you have to touch it on the reader, and later when you see me use  this device to connect to the hand, you'll notice that I have to bring it quite close.  This may assuage some of the security concerns when it comes to actually storing data on  this thing, but in effect, I don't think it's really a secure medium, but I'm going  to go into that a bit later.  So the tags are passive.  This is really important because it means I don't have to put a battery inside my body.  People have done, people have made devices which involve LEDs and vibrations and things  like that.  Sometimes these have to be powered by batteries that only going to last a few years.  While I deeply respect these people and what they're doing, I wanted to have something  that was going to be, if not permanent, maybe something that was going to not have the kind  of obsolescence that we're used to with technology like a laptop that will expire after three  years.  I expect this will last hopefully a little bit longer than that.  They have hard-coded, unique IDs, and there are these things called end-def records.  So each tag, when it's manufactured, is given a unique ID which can't be changed by the  user.  That's the intention.  In reality, sometimes you can clone tags, you can get doggie chips from China which  are able to change their unique IDs.  The manufacturers of NFC chips tend to counter this by signing them cryptographically or  using other forms of sort of higher-level security.  End-def records are the NFC data exchange formats.  So what that means is that when you store the data on this thing, you need to have some  sort of way of agreeing on how you're going to read and write the data.  The data is stored on the chip, but unless you know how you've encoded it, then you don't  really have much hope of being able to understand it.  So I'm going to go into end-def records later because they're the kind of universally agreed  standard for how you should store multiple bits of data on one NFC tag.  So the uses of NFC.  I've already described you oyster cards in London.  We contact this payment as another one.  So I'm not sure if you have this in Germany, but you can have a credit card which you just  tap on the reader to pay for anything under £30.  I see you nodding.  That's great because it's a really great technology.  I mean, it's kind of great until you discover that people have been sneaking up to other  people on the tube and using a card reader to kind of quickly skim £20 from each person.  So this is one reason why I didn't go down the avenue of actually storing money on this.  There is a guy who has, I believe, made a Bitcoin payment with the chip in his hand.  The chip probably stores the private key and is used as an extra authorization step in  a Bitcoin flow involving a separate app.  The important thing to know here, I guess, is that the chip can't perform any processing.  It's merely a passive data storage medium.  Great.  Okay.  So let's get a bit more practical.  This is the PN532 breakout board, which I bought from Adafruit.  It's actually this big.  So those of you at the back may have some difficulty seeing a bit of the demo, but the  code will be on the screen, so it should make sense.  What is this?  It's an NFC antenna, so it can read and write.  I think also emulate NFC tags.  NFC tags have three, well, NFC devices have three modes.  Read or write a mode like this.  This is the fully capable device.  This is powered and it's able to issue effectively commands and send data over the wire.  There are the passive tags like the one in my hand, and there are emulation modes, so  this could pretend to be a passive tag.  That's not as interesting, I guess.  Great.  Okay.  So I want to talk about the demo that I'm going to do today.  I have a couple of things that I've been doing as part of my research.  So one of them is the demo I'm going to show you.  So the difficult thing about reading NFC on a device like a laptop is that you don't really  have, there's no native NFC antenna in this thing.  I don't know of any laptops that really have one.  So I had to connect this PN532 to the laptop.  So it doesn't look too bad.  I mean, it's just a USB cable, but the actual form of communication used is over an FDTI  cable, which uses serial.  So the computer has to have a serial driver in order to use that.  And doing that on JavaScript, whether or not that was a wise idea, I guess you can judge  for yourselves, will require some special libraries and require a little bit of fiddling  around, which I'm going to show you the results of, at least maybe not the whole journey,  because that would take too long.  Okay.  So JavaScript, I'm going to show you the little ecosystem I've used to build up some of my  demos.  Not all of them are in the demo that we're going to see right now.  But yeah, so I just thought I'd show you my stack.  Yeah.  I mean, some of these are fake, but this is modern JavaScript.  Okay.  Right.  Okay.  Let's go to JavaScript.  Okay.  I'm going to resize this until it's about right.  Can anyone not see that?  Okay.  Great.  So I've just got the kind of shell of what we're doing here.  Okay.  Let's start live coding.  So the aim of this demo, this first part of the demo is to read from the NFC chip in my  hand using some code in JavaScript running on the computer.  That's the kind of parameters of what we're doing here.  So we're node the moment.  So let's go and require some libraries.  That's the first thing we want to do.  So the first thing we're going to grab is this serial port constructor from a library  called node serial port.  This is incredibly useful because as you can see, that was easy to require.  And now we have all the capabilities of the low level drivers that we need in order to  communicate over this FDTI cable with the PN532, which as you recall is the board I  got from Adafruit.  There's another library we're going to use.  I'm going to grab the constructor from that, which is the one for this particular board.  So PN532 also has a node library kind of written by someone doing something similar  to me without the biohacking component.  And finally, we're going to use an NDEF library.  So if you remember from before, NDEF is the data format that we encode the things on the  NFC tag in.  This is just simple sort of buffer to string conversion along with a lot of futzing around  with arrays.  So hopefully that will work fine and we won't have to delve deeper into the NDEF format  at the kind of by each level.  So these two lines here that I've pre-written are the address of the device as it is seen  by my machine.  So if I go to, in fact, let's do this.  I'm not sure if you can see this.  Sorry.  Well, if I write, if I ls my dev, these are all my dev devices, you might not be able  to see that.  But what there is one that you probably won't see on your device, which is this USB serial  with serial number there.  That's what I got to pin into this constant here.  The board rate, if you've done a bit of electronics, you'll know what that is.  If not, it's basically the kind of rate of symbols traveling across the wire.  It's just a constant that we have to set in order to correctly listen to the signals coming  from the serial port.  Great.  So let's initialize the object that is going to give us access to the PN532.  Excuse me.  I mean this.  Okay.  So all we need to do is give it the device and the board rate.  Now we've got the serial port and the PN532 library, really easy to use.  We now all we have to do is wrap the serial port in that.  Okay.  So let's do something that actually runs the code.  Okay.  So we use this kind of event handler like API in order to establish that the board is ready.  So the first thing you need to do is check it's connected to the computer.  So excellent.  Nothing is happening.  I like to think of live coding more as sort of, yeah, you're right.  I like to think of live coding more as sort of high stakes, pair programming.  Sorry?  Yeah.  Yeah.  Great.  Okay.  So now it says ready.  Okay.  So what we established is that this thing with the red light on it is actually connected  to the computer.  What we established before that wasn't that nothing was happening but that there were  no errors.  Okay.  Cool.  So now what we want to do is detect a tag.  So here are a couple I made earlier.  They're not actually in my hand and I want to show you that I've got different tags with  different IDs on them.  This is the first thing to establish because if they all have the same ID then there's  no way we can identify me by the tag that's particularly in my hand.  So when it's text tag, we have, we get this tag object.  And what we're going to do with that is we're just going to log it.  Just see what it looks like.  Okay.  So the board is ready.  I'm going to scan it on my hand.  Great.  So we've got an object.  This is not a particularly pretty object but the important thing to see is the UID here.  So this is the unique ID of the tag that is inside my hand.  I hope there's no other tag in the world that has this ID, at least not one made by the  same manufacturer.  And if there is, then my two-factor authentication demo probably won't work but I'll show you  that in a minute.  Okay.  Great.  So now we've got the tag.  What we want to do now is read the data off it.  And so it could be this easy.  So what we want to do now is read the end of data.  I mean, the end of library and the serial port and PN532 library is a great.  There's a kind of mix of API styles.  We've got a promise going on.  And just pass it this and imagine we're using callbacks.  Okay.  So let's have a look at the data on this thing.  So what data is actually on the hand?  Sorry.  I don't know why I have to keep zooming in.  Great.  So we've got to load data.  This is really a buffer representation which if you've done a bit of Node or anything at  a slightly lower level, you'll recognize as something that is not as easy to read as  something that isn't encoded.  So let's try to decode this thing.  So what we need to do is use the end of library.  This is the function of the end of library.  So this is the buffer that's on the device.  And now we need to try to decode it according to the rules defined in the end def specification.  Which all sounds very complicated, but thankfully we've got the library to do it for us.  So let's decode the message.  We need to sort of futz around a bit with this.  That's just the form I expect the data in.  So let's actually look at that now.  Great.  Okay.  We have something that says JavaScript for Cyborgs, but we also have a load of other  stuff.  We have a TNF, a type ID payload, all this stuff.  There are actually two records on this chip.  So on the chip in the hand, there are these two objects in the array.  It's rather hard to see.  And each of them contains this payload of bytes and the actual value of the record.  So end def records can be of various different types.  You can have a URL record, a text record, contact record, all sorts of things.  It used to really cool applications like having to be able to have your business card on your  hand.  The first guy I met with one of these, I tapped my Android phone on his hand and his contact  info just came up and I thought that was such magic, but I wanted to get my own one.  I never realized it would lead me to this JavaScript journey, but here we go.  So what I'm going to do finally is just map that so that we can just see the value of  the data.  We don't need to see the payload.  We don't need to see the TNF, the type, or that kind of thing.  The demo I want to show you today is just that we can write to the chip and read from  the chip.  Sorry, I'm getting ahead of myself.  Read from the chip.  Okay, so, yeah, message is fine.  So actually what we want is, forgive my JavaScript variable naming.  No, we don't want that.  Okay.  So we just want to see the value of each one and that's what it's called, right?  Great.  Let's just check that.  Yeah, great.  Okay, so now we've got an array with two objects in it with just two values.  Okay.  So we can read from the tag.  We can read from the data that's in my hand.  There's not very interesting data in there at the moment.  All it is is a URL and a value.  If you tapped your phone on this, the URL would come up.  So my website would come up in your phone and the browser would immediately try to load  it with no permissions or anything like that.  That's an awesome way of bypassing the control people think they have over their phone.  Okay, cool.  So now let's move to the right demo.  Okay.  I've got another demo here.  And what I want to show you now is that we can write data to the tag.  So this is where I wanted you to have your curl client or your postman client ready because  what we're going to do is you're going to curl or post to an endpoint and it's going  to end up inside the hand.  So whatever you post, hopefully I've sanitized it enough that you can't actually break anything,  but we'll see.  We'll end up inside the hand.  It's kind of last come, first serve.  So the last person to post to that endpoint will end up with the data inside my hand and  then everyone can read it later.  So it's a kind of reverse race.  I'm going to just put the URL at the top of the screen here.  So you want to post to...  So just post a raw message body to that.  It doesn't need JSON or anything.  If you do it JSON, it will be stringified anyway.  So if you send a post request to that, then we'll see what's on there in a bit.  But let's get on with the demo while you're doing that.  Cool.  So I've required a lot more libraries here.  I didn't feel the need to write this out again while live coding.  So all we've got that's different from last time is that we've got the request library.  We're going to use this to make a request to this, which when I make a get request to  it, set the server...  Not yet.  I set the server to just repeat to me what was last sent to that endpoint.  Just kind of echoing it.  Great.  So as before, we've got these event handlers.  So when the PN532 is ready, it will log PN532 ready.  And on tag, it will log the tag with the UID.  So let's just check that this works.  PN532 is ready.  Sorry.  Tag detected with UID.  Great.  So I'm just going to prove to you that this isn't a fake demo.  We've got a different tag there.  It's got a different ID and another one.  So the N tag 216 is just the exact tag that is the type of tag that is in my hand.  Great.  So I'm not going to put in the stuff about the endpoint yet.  Let's just get it in with encoding all the data that we need to do.  Okay, great.  So let's just call it message to write.  Great.  So we're going to try to write this data onto the tag.  So what we could do is we could just say...  So we could attempt to send the data to the tag like this and we could say...  That's probably not going to work.  And it's definitely not going to work because we haven't actually encoded the data into  the right format.  So let's actually define a message array where the first member is a URL record.  I'm doing this so that when someone actually scans my hand with their phone, it comes up  with a URL which I think is cool, rather than just coming up with the text.  Oh, URL record.  Great.  Right.  And the final record, the last record, will be the message that we want to write.  So it will be a text record.  So as you can see, we've got these types defined in here already.  These just correspond to the types in the end def spec.  Great.  So what we need to do is actually encode these messages into the right format.  So that's as easy as end def dot encode message.  And then we want to call this.  And now we want to write the encoded messages to the tag.  So I've learned while developing in this way that the best way to test these things out  is probably not in the chip inside my hand.  I'm slightly worried occasionally about breaking it somehow or finding some way to write corrupt  data onto it.  While I can't find any way of doing that, I don't particularly trust my own node skills.  So we're just going to write this data to this tag.  Cool.  What I've forgotten to do as this is live coding is actually get some sort of verification  that we've written the data.  So again, this is a promise-based API.  And there's a response, but it's usually undefined.  So let's just assume it's going to be fine.  And true JavaScript error handling style.  Great.  The write was successful.  So what we can do is we can check using the read script if we don't actually trust that  we've written it on properly.  So let's just quickly run the script.  Great.  So the value is hello, enter JS.  Because we haven't actually requested it from the endpoint yet.  Great.  Okay.  So I'm going to go on to the write code.  Okay.  So we're almost at the end of this demo, and the final thing I want to do is just see if  anyone's posted to this endpoint and see what kind of data that ends up on my hand.  I'm quite excited to see what kind of things people have put on there.  Hello is sufficient.  Okay.  So the message we actually want to write comes from that endpoint, and we just need to send  a get request, which is easy with request.  And it's just, yeah.  So we make a get request to that.  There's a load of parameters and a body.  So actually what we want.  Okay.  The body is the most important thing, which is why I don't think the other parameters  need to be logged.  So we can log what's in the body, but what I want to do is actually set it to be the  message to write to the tag.  So let's stick all this code in here and actually set the message to write to be the body.  Which I mean that.  It's not long the body.  Okay.  So now what we've got is we've got a request going off to an endpoint.  Somewhere on the Internet.  We're going to get some data from the Internet.  We're going to grab it and run some JavaScript through the drivers and everything to get  it into the hand.  So I think the implications of this are quite interesting because, for example, there's  a number which is illegal to store.  Well, I don't think it's illegal to store, but it's illegal to share this number because  it was used in DVD encodings in the 90s.  I want to know what the implications would be legally or otherwise of putting that number  inside my hand.  Smuggling it into the U.S.  Smuggling it into any sort of facility which would just involve me walking into the facility.  I think this is really interesting.  So if someone's put something illegal on there, then we're going to find out maybe very soon  what the implications of that would be.  But let's just see what it is.  So we're going to write this data to a tag.  That seems successful.  We're going to write the data to my hand.  Okay.  The write was successful.  Let's see what it is.  So, we finished writing the data.  Let's go and read some data.  JavaScript.  Excellent post request.  Thank you.  Great.  So I'll probably monitor this throughout the day and see what else happens.  Okay.  Great.  So I'm going to go back to my presentation now as I'm probably running out of time.  So, and I still don't have any speaker notes.  Hey, I haven't finished.  So, thank you.  I have another demo here.  It's not a live coding demo, so it won't take as long.  But I'm just going to really rush through it because I have five minutes left to this  presentation.  So two-factor authentication is a method of authentication where instead of the user just  entering a password, they enter a password plus they do something else.  They enter a code that you've got on your phone or they enter a code that was sent to  them in some other way or they respond to a push notification.  What if the second factor in this two-factor authentication flow were the ID of the chip  in my hand?  So I built this demo.  Basically, don't curl this endpoint yet because I'm not monitoring the... you scan the tag  and then it will receive a reply as to whether or not the person who scanned the tag was  me and the way it tells is just by the ID of the chip.  So this suffers from all the things we had before.  I mean, I made a web sequence diagram, but other people's web sequence diagrams... I  mean, hell is other people's web sequence diagrams, really.  So the future I want to see in this kind of research.  So this, as I say, is just the beginning of the research I'm doing into this area.  There are a number of open questions which I think we should all think about whether  or not we decide to become sidewalks ourselves.  So you may have noticed in the two-factor authentication demo and the other demo, indeed,  but these are all particular to me unless you've also got a chip in your hand with exactly  the same specifications or at least that obeys the same specifications, you can't participate  in this.  I think it's interesting and a reflection of the wider internet of things situation that  we have was essentially World Gardens and a way of stopping devices from communicating  with other devices over the internet, which was indeed the idea to begin with.  So I'm going to skip the rest of this.  Another interesting implication here is that I now have something in my hand apart from  my fingerprints, which is uniquely identifies me.  So if I go somewhere, then I'm going to find that the... and someone scans the tag, then  someone knows I've been there.  This is important to me, it may be some sort of privacy concern, but what I think is interesting  is that the chip is not really any more identifiable than my fingerprints and not really any more  likely to be left at a location.  So as I say, the read range of the chip is less than four centimeters.  So what happens is someone shakes my hand or something, they scan the chip, they get  the data off it, you can encrypt the data on it with a 32-bit password, but unfortunately  it's... oh, I think those are my speaker notes.  Thank you.  The final thing I want to say, thank you.  I actually... yeah.  Thank you.  No, that's fine.  I really appreciate that because I have a really good example from this last slide.  As you can see, I had a lot to say.  So I was at the tape modern the other day and I met an artist called Chloe Spicer.  What she does is she explores the possibilities of embodied data.  She focuses on books.  Books are her focus as a librarian.  So she wears books, she consumes books, she eats books, she wants to become data embodied  in a book.  I thought this was really interesting and kind of relevant for me as well.  So you may say that 888 bytes of data isn't a lot, maybe the human brain can store terabytes  of data though in a slightly different format than a computer.  DNA can encode data, but like thoughts, I can't directly access them.  I can't have the same thought twice and I can't access the data encoded in my DNA.  So to have a persistent data storage device in my hand which can store an exact amount  of data and will do so for the foreseeable future is, I think, a capability that my body  didn't have before.  And that's what's interesting about this.  I think although it's a small step, it's a step towards augmenting our bodies and transcending  our previously human limitations.  Thank you.  Thank you.  Thank you.  Thank you.
enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_0_131.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_132_1271.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_1272_2435.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_2436_2627.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_2628_4859.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_4860_5639.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_5640_6719.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_6720_12599.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_12600_13847.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_13848_15383.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_15384_15659.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_15660_15803.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_15804_15995.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_15996_17255.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_17256_19067.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_19068_19115.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_19116_19271.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_19272_19427.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_19428_19523.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_19524_21635.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_21636_25031.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_25032_25187.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_25188_28559.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_28560_31931.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_31932_33587.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_33588_33635.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_33636_34247.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_34248_34499.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_34500_36971.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_36972_38435.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_38436_38699.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_38700_39011.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_39012_40667.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_40668_41555.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_41556_41603.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_41604_42623.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_42624_42767.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_42768_42815.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_42816_42983.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_42984_43175.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_43176_43571.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_43572_44615.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_44616_48143.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_48144_48203.png enterJS_2016_-_Katy_Moe___JavaScript_for_Cyborgs_J17k2k6sPUU_48204_48218.png