<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arik Sosman on Medium]]></title>
        <description><![CDATA[Stories by Arik Sosman on Medium]]></description>
        <link>https://medium.com/@arikaleph?source=rss-760c2decf367------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HQc59cxq1y3UDKOULi3N-Q.png</url>
            <title>Stories by Arik Sosman on Medium</title>
            <link>https://medium.com/@arikaleph?source=rss-760c2decf367------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:51:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arikaleph/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Compiling C code as Android shared libraries]]></title>
            <link>https://medium.com/arik-s-blog/compiling-c-code-as-android-shared-libraries-6924803c00db?source=rss-760c2decf367------2</link>
            <guid isPermaLink="false">https://medium.com/p/6924803c00db</guid>
            <category><![CDATA[shared-libraries]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-ndk]]></category>
            <dc:creator><![CDATA[Arik Sosman]]></dc:creator>
            <pubDate>Tue, 09 Feb 2021 01:41:22 GMT</pubDate>
            <atom:updated>2021-02-09T17:33:22.315Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide will take you through the process of taking C files that depend on the Android JNI, compiling them for all four prevailing Android architectures, and integrating them in an Android project using Android Studio.</p><p>Let’s start with the first step, a C file containing a function we wish to expose to Android. Let’s call this file medium_example.c.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/387ec3068eff5c382e6d10f3ec26c280/href">https://medium.com/media/387ec3068eff5c382e6d10f3ec26c280/href</a></iframe><p>From the example above, it’s easy to tell that this function, when called, will return the string Hello from C! However, the name may cause a bit more confusion.</p><p>Firstly, all C methods exposed to the JNI need to start with Java_.</p><p>In our case, we want this method exposed in a class called NativeLibrary, which is contained in a package called medium_example whose domain name prefix is io.arik for arik.io. That means that the class’s fully resolved identifier would be</p><pre>io.arik.medium_example.NativeLibrary</pre><p>For naming the C functions, all periods (.) are replaced with underscores (_), and underscores are replaced with _1, hence the function name prefix</p><pre>Java_io_arik_medium_1example_NativeLibrary</pre><p>Lastly, we wanna name the actual function greeting, hence the greeting suffix.</p><h3>Step 2: Installing the Android NDK (Native Development Kit)</h3><p>To compile libraries for Android, we need the actual compilers that are capable of doing that. Thankfully, Google has pre-built binaries that let us do just that. Just head over to the NDK downloads page here, and download a package compatible with your operating system (you probably want the latest stable version). The NDK downloads page link is as follows:</p><p><a href="https://developer.android.com/ndk/downloads">https://developer.android.com/ndk/downloads</a></p><p>The compressed folder you downloaded, let’s call its location &lt;NDK&gt;, when extracted, will have the following structure:</p><pre>&lt;NDK&gt;/toolchains/llvm/prebuilt/&lt;host_architecture&gt;</pre><p>Assuming you have a typical Linux machine, the value of &lt;host_architecture&gt; will be linux-x86_64, and on Mac OS it is darwin-x86_64.</p><p>Inside that folder, there should be two folders of relevance to us: bin and sysroot. The former contains the various compiler binaries we talked about in the first section.</p><h3>Step 3: Compiling the C file using the NDK’s Clang binaries</h3><p>There are four prevailing Android architectures: arm64, armv7, x86, and x86_64. We need to compile the C file for each one of them. This will generate four different shared library files (extension .so), and then we will have to tell Android which is which.</p><p>To that end, let’s use a little script to simplify changes a little bit; we’ll call the file compile_medium_example.sh.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11e4e645ef70a5af35e542a2d1f45888/href">https://medium.com/media/11e4e645ef70a5af35e542a2d1f45888/href</a></iframe><p>In the file above, there are two variables, highlighted in &lt;<em>italic</em>&gt;, that you, the reader, will need to adjust depending on the NDK download location and host architecture.</p><p>You will note that we are creating an output folder, tutorial_out, inside of which we are auto-generating folder names for each of the generated shared library files, which are all named libmediumexample.so. Once you run the script, your folder structure should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lox7QQs7G85q84MTVBV1g.png" /></figure><h3>Step 4: Putting it all together with Android Studio</h3><p>We have our libraries compiled, so let’s create an Android module to integrate them. The starting point for this is that you already have an existing project. In my case, that project’s name is “AndroidLab” because I’ve been doing some other experimenting with it.</p><p>The first thing we wanna do is create a new module, and we’re gonna pick the module type “Android Library.” As discussed in Step 1, we have decided that we’re naming this module medium_example, with the package name, in my case, therefore being io.arik.medium_example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NPI9jg2C1RRbMBYW1H35CQ.png" /></figure><p>Also, as discussed in Step 1, we will create a Java class inside our library called NativeLibrary, and we add the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6deec2aef2a0f0edba21d5b02d06ab20/href">https://medium.com/media/6deec2aef2a0f0edba21d5b02d06ab20/href</a></iframe><p>You will note the loadLibrary call, whose argument is simply mediumexample. The JNI automatically prepends the lib prefix and the .so suffix, so the file name we have for the shared libraries, libmediumexample.so, will work automatically.</p><p>However, while we do have Java expecting the library, it doesn’t actually know where to look yet. To that end, go to the location of the Android module (right-click in Android Studio’s project explorer view, and click “Reveal in Finder” or your operating system’s equivalent). Then, navigate to the subdirectory src/main, and create a folder named jniLibs. Copy the folders inside tutorial_out from Step 3 to the jniLibs folder you just created, such that the module’s folder structure looks as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xbm415owgvwTVHnoiH-2CQ.png" /></figure><h3>Step 5: Let’s try it out!</h3><p>Finally, let’s put everything we just built to the test. There are a couple things that need to be done to verify that everything works. First of all, the library module we just created needs to be declared as a dependency of the main app that is typically run in the simulator.</p><p>To do that, open project structure settings in Android Studio (⌘ + ; on a Mac), go to the Dependencies tab, highlight the main app, press the + button, and pick Module Dependency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NqhnV1f9ounJIiJKIb_UQ.png" /></figure><p>Then, in one of the app’s files, call NativeLibrary.greeting() and print it to the console or add a debugger breakpoint. In my case, I have an application with a tab bar, so in ui.home.HomeViewModel.kt, I added the following lines (in bold):</p><pre>package io.arik.android_lab.ui.home</pre><pre>import androidx.lifecycle.LiveData<br>import androidx.lifecycle.MutableLiveData<br>import androidx.lifecycle.ViewModel<br><br><strong>import io.arik.medium_example.NativeLibrary;</strong></pre><pre>class HomeViewModel : ViewModel() {</pre><pre>    private val _text = MutableLiveData&lt;String&gt;().apply {<br>        <strong>val nativeGreeting = NativeLibrary.greeting();<br>        value = &quot;Native response: &quot; + nativeGreeting</strong><br>    }</pre><pre>    val text: LiveData&lt;String&gt; = _text<br>}</pre><p>The result speaks for itself:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*cm-u1TMpvzBEV0lwP3Clxg.png" /></figure><p>I hope this walkthrough was helpful. Thanks for reading, and good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6924803c00db" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arik-s-blog/compiling-c-code-as-android-shared-libraries-6924803c00db">Compiling C code as Android shared libraries</a> was originally published in <a href="https://medium.com/arik-s-blog">Arik’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BitGo Public Key Pinning]]></title>
            <link>https://medium.com/@arikaleph/bitgo-public-key-pinning-1f22f9176958?source=rss-760c2decf367------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f22f9176958</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[ssl]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[Arik Sosman]]></dc:creator>
            <pubDate>Fri, 13 Jan 2017 15:15:35 GMT</pubDate>
            <atom:updated>2017-01-13T16:00:37.699Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*igpKR09fR9rO0IEPJzbajg.png" /></figure><p>We wanted to share some of our thinking that led to enhancements in protocol design, which is now shipping in the latest version of the BitGo SDK. This post focuses on aspects of the SDK that enhance web traffic protection and validation, improving communication security for our customers.</p><p>One of the biggest problems with web applications is content integrity checks. As there is no simple way to verify content authenticity, most sites defer to using HTTPS, which is a good start towards encrypting and signing traffic. However, HTTPS does stream integrity checks at the transport layer, rather than at the application layer. Thus, the channel ends up being encrypted, but the application content integrity is not validated. Considering that obtaining a trusted certificate is very cheap, neither the encryption nor the signing HTTPS provides is sufficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-VGNMEGreNXelq50nLGp7Q.png" /><figcaption>A Mac running Sierra 10.12.2 has 169 trusted root certificate authorities.</figcaption></figure><p>As shown in the picture above, there are 169 trusted root certificate authorities on a typical Mac. Getting just one of them to issue a certificate is sufficient for a hacker to execute a completely undetected man-in-the-middle attack. In a scenario with untrusted networks, anybody could be doing a certificate replacement, particularly in public open networks like at a Starbucks or in a hotel room. Further, service providers may deliberately be subjecting their traffic to man-in-the-middle-attacks using automated SSL service providers such as Cloudflare. With these considerations in mind, the reassuring green lock in the browser bar may in fact be deceptive and lull people into a false sense of security.</p><p>The best solution is certificate pinning, but in an environment wherein both the certificate and the data are transmitted over the same channel, such a solution can never be optimal. The security mechanism that comes closest is HSTS, which BitGo has been using for years, but which relies on browser support and therefore provides only marginal utility to those of our users who use the BitGo SDK or BitGo Express rather than our web interface.</p><p>To fix that, we have been working on a public key pinning mechanism that is more reliable and works both within and outside browsers, making sure that all our customers are equally well-protected. It allows both server and client to verify each other’s requests and responses against a fixed key pair whose public key is embedded in the BitGo SDK, and it prevents access tokens from ever being sent across the wire explicitly.</p><p>The mechanism relies on ECDH and HMACs. When a user logs in, the server encrypts the new access token with a symmetric ECDH key calculated based on the user’s public key and server’s private key. To decrypt the access token, the client calculates the same symmetric key with the public and private roles reversed. The picture below shows an example login server response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KOxxNzoyzE2xC_5dxjHPVQ.png" /><figcaption>A browser network inspector showing a response from www.bitgo.com.</figcaption></figure><p>All authenticated API calls and responses, including the initial authentication response, attach an <em>HMAC</em> header of the transmitted data using the access token as the HMAC key. For subsequent authenticated calls, only the access token’s hash is ever transmitted over the wire in plain form. An additional benefit of this protocol is that even if somebody were to eavesdrop on the connection, due to the fact that the HMAC changes with every request, they would not be able to fake authenticated calls. Additionally, the <em>Auth-Timestamp</em> request header prevents replay attacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGYLanvy-bKm6jyQUilqKQ.jpeg" /><figcaption>Request headers sent on an authenticated request to www.bitgo.com.</figcaption></figure><p>The response <em>HMAC</em> header (pictured below) allows clients to validate that the data transmitted from BitGo has not been modified. The <em>HMAC </em>and <em>Timestamp</em> headers can be seen in any common browser network inspector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K3VZ4R9A5vrHPh-V3-cMOg.jpeg" /><figcaption>Response headers from www.bitgo.com to authenticated requests.</figcaption></figure><p>In contrast, one need look no further than any popular banking website or social networking platform, and see that for most sites, the authentication mechanism is static cookies. Writing this blog post, I did not deem showing the raw cookie information safe, which is why in contrast to the screenshots of the BitGo request streams, I blacked out parts of the picture below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_2osJAoSlnbQHLmUplEkjQ.png" /><figcaption>Request headers sent on an authenticated request to a popular website.</figcaption></figure><p>We at BitGo feel that this new protocol is an essential security feature, and urge all of our customers to take advantage of it. To use this new authentication mechanism, simply update your clients (BitGoJS) to their most recent versions. If you are using our web client or the BitGo Chrome extension, you are already being secured by this feature. If you are an existing API customer, your existing long-lived tokens will continue working; however, we do recommend that you generate new long-lived tokens and update your BitGo SDK to take advantage of the additional safety measures.</p><p>Going forward, we will continue to improve the communication protocols used at BitGo. While HTTPS is sufficient for many sites, we believe this additional layer of protection will prove critical for BitGo customers in the coming years. We look forward to helping others, including the Internet at large, adopting similar improvements for all web communications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f22f9176958" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Verifying WhatsApp’s End-To-End Encryption]]></title>
            <link>https://medium.com/arik-s-blog/whatsapp-s-end-to-end-encryption-is-a-lie-c7f65bb43d32?source=rss-760c2decf367------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7f65bb43d32</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[whatsapp]]></category>
            <category><![CDATA[encryption]]></category>
            <dc:creator><![CDATA[Arik Sosman]]></dc:creator>
            <pubDate>Wed, 06 Apr 2016 11:18:20 GMT</pubDate>
            <atom:updated>2016-04-06T13:26:31.910Z</atom:updated>
            <content:encoded><![CDATA[<p>A few days ago, WhatsApp announced that with the latest update, all their conversations would be end-to-end encrypted. I very briefly examined a conversation which WhatsApp was showing me was encrypted.</p><p>I asked the other party to send me a message, but I closed (force quit) WhatsApp first. As I’m running iOS, where apps cannot create daemons, it served the following purposes:</p><ul><li>The app would be unable to maintain any open TCP connections.</li><li>The app would be unable to schedule local notifications.</li><li>The app would be unable to do client-side decryption in the background</li><li>The WhatsApp server would be forced to send me a push notification in order for me to get any notification at all.</li><li>The app would be unable to process that notification, because due to force quitting, <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/index.html?hl=ar#//apple_ref/occ/intfm/UIApplicationDelegate/application:didReceiveRemoteNotification:fetchCompletionHandler:">application:didReceiveRemoteNotification:fetchCompletionHandler: does not get called</a>.</li></ul><p>That means that any notification would have to be a push notification, sent by WhatsApp’s servers to Apple, who would then send it to me.</p><p>The push notification contained the message in plain text. Therefore, WhatsApp, and then later Apple, had access to the message in its decrypted form. I don’t know if an encrypted version of the message exists, but as long as any server has access to a decrypted copy, the encryption is worthless.</p><p><strong>UPDATE</strong>: As multiple people have pointed out, WhatsApp could be using PushKit, which can wake up a VoIP-enabled app even if it has previously been force-quit by the user. Testing it would require access to a device with iOS 7, which I didn’t. But there is another way of testing it. When restarting an iPhone, its file system is encrypted until it’s first unlocked. That means that regular push notifications would still be shown, but if a notification were to require a local decryption first, the system wouldn’t work due to the inaccessibility of the private key.</p><p>I restarted my iPhone, and it automatically connected to the cellular network. It couldn’t connect to the WiFi because the password was encrypted until I unlocked it. When a friend sent me a message using Facebook’s Messenger, it instantly appeared. I did not, however, receive any push notifications from WhatsApp, even though he was sending messages.</p><p>When I unlocked the phone, WhatsApp notifications still weren’t arriving. It wasn’t until I first opened the application after the restart and then quit it again that notifications started working.</p><p>Thus, it appears that not only does WhatsApp end-to-end encrypt messages, but it does a better job at usability than any other end-to-end-encrypted messenger I know.</p><p>Big thanks to Harshil Shah, Frederik Riedel, and Mert Dümenci for pointing out PushKit for VoIP apps and helping me test.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7f65bb43d32" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arik-s-blog/whatsapp-s-end-to-end-encryption-is-a-lie-c7f65bb43d32">Verifying WhatsApp’s End-To-End Encryption</a> was originally published in <a href="https://medium.com/arik-s-blog">Arik’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Facebook M — The Anti-Turing Test]]></title>
            <link>https://medium.com/arik-s-blog/facebook-m-the-anti-turing-test-74c5af19987c?source=rss-760c2decf367------2</link>
            <guid isPermaLink="false">https://medium.com/p/74c5af19987c</guid>
            <category><![CDATA[facebook-m]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Arik Sosman]]></dc:creator>
            <pubDate>Mon, 09 Nov 2015 23:50:07 GMT</pubDate>
            <atom:updated>2015-11-11T20:44:34.570Z</atom:updated>
            <content:encoded><![CDATA[<p>Facebook has recently launched a limited beta of its ground-breaking AI called M. M’s capabilities far exceed those of any competing AI. Where some AIs would be hard-pressed to tell you the weather conditions for more than one location (god forbid you go on a trip), M will tell you the weather forecast for every point on your route at the time you’re expected to get there, and also provide you with convenient gas station suggestions, account for traffic in its estimations, and provide you with options for food and entertainment at your destination.</p><p>As many people have pointed out, there have been press releases stating that M is human-aided. However, the point of this article is not to figure out whether or not there are humans behind it, but to indisputably prove it.</p><p>When communicating with M, it insists it’s an AI, and that it lives right inside Messenger. However, its non-instantaneous nature and the sheer unlimited complexity of tasks it can handle suggest otherwise. The opinion is split as to whether or not it’s a real AI, and there seems to be no way of proving its nature one way or the other.</p><p>The biggest issue with trying to prove whether or not M is an AI is that, contrary to other AIs that pretend to be human, M insists it’s an AI. Thus, what we would be testing for is humans pretending to be an AI, which is much harder to test than the other way round, because it’s much easier for humans to pretend to be an AI than for an AI to pretend to be a human. In this situation, a Turing test is futile, because M’s objective is precisely to not pass a Turing test. So what we want to prove is not the limitations of the AI, but the limitlessness of the (alleged) humans behind it. What we need therefore is a different test. An “Anti-Turing” test, if you will.</p><p>As it happens, I did find a way of proving M’s nature. But good storytelling mandates that first, I describe my laborious path to the result, and the inconclusive experiments I had to conduct before I finally got a definitive answer.</p><p>When I first got M, our conversation started like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XA-4M0gTsz7eNgvxx3DQCg.png" /><figcaption>Dinner? Oh, and are you human?</figcaption></figure><p>“I use artificial intelligence, but people help train me,” was M’s response to my question regarding its nature. That can mean many things, because using AI is not the same as being a completely autonomous AI. So I kept bugging it about its nature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*cN5Fd1M9TaElHa319HKAiA.png" /></figure><p>Some people opined that what M refers to as AI is that there are people typing out all the responses, but the tool that helps them do that is based on machine learning. However, directly asking about that didn’t yield any new insights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*frAuLgInxY_Q4Mx8wfr_Sw.png" /></figure><p>M’s assertiveness regarding its nature is set in stone. Nonetheless, there were some minor tells that arguably betrayed the underlying human nature of this chatbot. To test its limit, I have asked it to perform a set of complicated tasks for me that no other AI out there could pull off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V5I7oiwEt4pxyCwHs2Za6w.png" /></figure><p>I told it where I work, and then slightly modified my request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wbZiNCu2gx8o9gfPKDEUBg.png" /></figure><p>And indeed, it responded!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZXdLRzaMFCA3TXnND3X8JA.png" /></figure><p>The most noteworthy aspect of this reply is that “Google Maps” wasn’t capitalized, suggesting that maybe, just maybe, a human typed it out in a hurry. And indeed, even with some other requests, its responses have proven not to be as impeccable as the ones we’re used to from Siri. For instance, when I asked it to find some nice wallpapers for me taken from the Berkeley stadium depicting the Bay Area at night, preferably with the Bay Bridge, the Transamerica Pyramid, and the Sather Tower being in the picture, M did manage to find some very nice wallpapers for me, but it said that it couldn’t find any with the Campanile. As consolation, though, it said it would let me know if it found any that fit my criteria more precisely:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DyL1BcRsGNOG6grI274eNA.png" /></figure><p>Now, the first issue with the above response is that the wallpapers it sent me <em>did</em> have the Transamerica Pyramid, and M knew they did. What they didn’t have was the Sather Tower, so why is it saying it’s going to let me know about pictures with the Transamerica Pyramid?</p><p>The second issue is that it’s called the “Transamerica Pyramid,” not the “Transamerican Pyramid.” And lastly, note the two “with”s and the “I’l”. It has made two typos! And indeed, that was not the only time it did:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Q7C2T4p-HZU_iqGGxORGQ.png" /><figcaption>Though to be fair, I made one, too. Yet again, I freely admit to being human.</figcaption></figure><p>While a lot of humans struggle with the distinction between “its” and “it’s,” for an AI, that should not have been an issue. Even so, it might have been trained wrong, so as such, these lapses are not sufficiently conclusive. Even the delayed responses I mentioned earlier could have been deliberate, including the fact that there’s a typing indicator shown when M is preparing a response, rather than sending the whole string instantaneously as a regular AI would. The results and indications so far didn’t satisfy me, so I was still looking for a way to prove that there are real humans behind M. Just how could I make them come out, make them show themselves?</p><p>As it happens, the answer came to me at a time when I wasn’t actively looking for it. The movie in Cupertino ended rather late, and I asked M whether there was any place I could get dinner at afterwards that would still be open at that time. There were only two places open, but I wasn’t sure whether their kitchen would still be open, too. Thus, I asked M whether it could call them and figure that out. And indeed, it said it could!</p><p>So I asked M whether it could call my friends (nope). Whether it could call me (nope). Apparently, it could only call businesses for me, but not individuals. So what do I do? I make up a business and ask M to call it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LIju_1SDfyO0vbHCxHEAFQ.png" /></figure><p>So M asked me for the phone number, and I simply gave it mine. About five minutes later, I receive a call with no caller ID. When I pick up, I hear some rumbling noises in the background, say “hello,” and then the other end hangs up. Immediately afterward, the following exchange happens with M:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lOEz2HXd6U2P-e-BFhWbNg.png" /></figure><p>Unfortunately, I didn’t have a landline phone number, so I was a bit disappointed that not even this experiment could prove M’s nature.</p><p>A few days later, I had to get some work done during the weekend, and while at the office, I realized that the company <em>did</em> have one. The experiment had to be repeated!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IHAw-62cYZfwWgX1uZUpKQ.png" /></figure><p>About three minutes later, we get a phone call in the conference room. When I pick up, a distinctively human, female voice says, “Hello?” As it happens, I had accidentally set the phone to mute before that, so she didn’t hear me saying the company name. Still, the voice was most definitely human. And because the reader shouldn’t be taking me at face value, I made a recording of that whole encounter:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fic4gQJilZk4%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dic4gQJilZk4%26feature%3Dyoutu.be&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fic4gQJilZk4%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d1b053d7c908839ee66e4d8d753c24f/href">https://medium.com/media/7d1b053d7c908839ee66e4d8d753c24f/href</a></iframe><p>Immediately afterward, M sends a reply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zcxBBP0Ik_cy5mvGWtrpdg.png" /></figure><p>What’s more, it appears to me that they forgot to block the caller ID for that particular call, because I got to see the phone number they were calling from.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8iW8oX0aBqKXABUip_Xbjw.jpeg" /></figure><p>So there, very clearly, M was calling from +1 (650) 796–2402. As can be seen on the photo, the automatic reverse-lookup matched that number to Facebook. Thus, here we are. We have definitive proof that M is powered by humans. The next question is: Is it only humans, or is there at least some AI-driven component behind it? As to this problem, I’ll leave it as a homework assignment for the reader to figure out. In the meantime, I shall enjoy having my own free personal (human) assistant.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74c5af19987c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arik-s-blog/facebook-m-the-anti-turing-test-74c5af19987c">Facebook M — The Anti-Turing Test</a> was originally published in <a href="https://medium.com/arik-s-blog">Arik’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I abandoned Core Data]]></title>
            <link>https://medium.com/@arikaleph/why-i-abandoned-core-data-a8866334d005?source=rss-760c2decf367------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8866334d005</guid>
            <dc:creator><![CDATA[Arik Sosman]]></dc:creator>
            <pubDate>Fri, 28 Mar 2014 21:33:19 GMT</pubDate>
            <atom:updated>2014-08-01T10:30:41.397Z</atom:updated>
            <content:encoded><![CDATA[<p>When I set out to develop my first big iOS app, I had only had about two months of prior experience with Objective-C. In addition to that, I had not previously spent a lot of time writing big client-side applications. Pretty much all the work I had done before was developed in PHP, and I seldom gave much thought about how to store data — MySQL had always been the obvious choice.</p><p>Until that app. My first ideas were rather primitive, vacillating somewhere between saving a huge file containing some JSON, or another huge file which would contain the output of an NSKeyedArchiver, whose input would be a gigantic NSDictionary. An even more stupid idea had been not to store any local data, and always reload it whenever starting the app, downloading all the relevant server content anew. My experience with web projects was showing, but it was not applicable. Within a few hours, the realization hit me that a local database was necessary.</p><p>A quick Google search yielded immense praise for Core Data. It looked highly promising: automatically managed objects, convenient relationship management, easily modifiable columns, integration with iCloud — who in their right mind would refuse such a convenient framework?</p><p>The alleged convenience came with a price, though. The app I was building relied (and still does) rather heavily on encryption and decryption. There is a lot of data, and it is all encrypted separately — that is, there is not one huge chunk that only has to be processed once, but a lot of very tiny fragments. While AES encryption is fast, it is not the size of the file that has the biggest impact on the duration, but the amount of distinct decryptions. (That can be easily seen when looking at AES decryption time in relation to the size of the data.) In order to not block the UI thread, I moved the encryption parts to background threads. That way, data would be received from the server, then sent to a background thread, decrypted, sent back to the main thread and saved using Core Data.</p><p>Core Data does not like being called from a background thread, however. Doing that would lead to occasional freezes. There were no errors per se, and a breakpoint set to all exceptions did not yield any results. The app would simply freeze, even in debugging.</p><p>So I created a multitude of NSManagedObjectContexts, each in its own thread, and then merge them. The app stopped crashing, but the saving process also stopped being deterministic. If data was sent from the server modifying one attribute of an object, while the user modified another, only one of the two values would be saved. That error arose when an object was fetched in both threads before changes were done in either.</p><p>It was even worse when several background threads changed different properties. When the program, rather than the user, had to process several changes, it did not even help to fetch the respective object immediately before changing the attribute and saving it, due to a time difference of some 70ms when merging changes from different threads.</p><p>So I moved to FMDB. Suddenly, multiple threads just <em>worked</em>. They worked pretty much the same way Core Data never had, but should have. All database operations were added to a thread-safe queue, and were processed in order. Additionally, complex queries could be saved in SQLite views and easily accessed where previously rudimentary queries had to be built with Core Data’s own, weird, query syntax, to be post-processed with numerous lines of code.</p><p>The app has neither been freezing, nor neglecting to properly save data ever since. That I know of.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8866334d005" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>