<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://ddkang.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://ddkang.github.io/" rel="alternate" type="text/html" /><updated>2026-02-06T04:12:10+00:00</updated><id>https://ddkang.github.io/feed.xml</id><title type="html">Daniel Kang</title><subtitle>Personal website for Daniel Kang</subtitle><author><name>Daniel Kang</name></author><entry><title type="html">Fighting AI-generated Audio with Attested Microphones and ZK-SNARKs: the Attested Audio Experiment</title><link href="https://ddkang.github.io/blog/2023/06/13/fighting/" rel="alternate" type="text/html" title="Fighting AI-generated Audio with Attested Microphones and ZK-SNARKs: the Attested Audio Experiment" /><published>2023-06-13T00:00:00+00:00</published><updated>2023-06-13T00:00:00+00:00</updated><id>https://ddkang.github.io/blog/2023/06/13/fighting</id><content type="html" xml:base="https://ddkang.github.io/blog/2023/06/13/fighting/"><![CDATA[<p>AI-generated audio is becoming increasingly indistinguishable from human-produced sound. This emerging technology, while impressive, is unfortunately increasingly misused. We’re witnessing instances where this convincingly replicated audio is being manipulated to <a href="https://www.wsj.com/articles/i-cloned-myself-with-ai-she-fooled-my-bank-and-my-family-356bd1a3">conduct scams</a>, perpetrate <a href="https://www.npr.org/2023/03/22/1165448073/voice-clones-ai-scams-ftc">identity theft</a>, and misused in <a href="https://www.forbes.com/sites/thomasbrewster/2021/10/14/huge-bank-fraud-uses-deep-fake-voice-tech-to-steal-millions/?sh=6f22e4a97559">other ways</a>. How can we safeguard ourselves and effectively combat the misuse of this advanced technology?</p>

<p>In an environment where AI-generated audio can mimic human voices flawlessly, we need a reliable chain of trust stretching from the initial capture of audio to its final playback. This chain of trust can be established using cryptographic technologies: attested microphones for capturing the audio and carried through to the final playback via <a href="https://z.cash/technology/zksnarks/">ZK-SNARKs</a>.</p>

<p>In the remainder of the blog post, we’ll describe how to use these tools to fight AI-generated audio. We’ll also describe how the open-source framework <a href="https://github.com/ddkang/zkml">zkml</a> can generate computational proofs of audio edits, like noise reduction. To demonstrate this end-to-end process, we’ve simulated the process of capturing audio to performing verified edits. We’ll describe how we did this below!</p>

<h1 id="cryptographic-tools-for-fighting-ai-generated-audio">Cryptographic tools for fighting AI-generated audio</h1>

<p>Establishing a chain of trust from the audio capture to final playback requires trusting how the audio is captured and how the audio is edited. We will use cryptographic tools to establish this chain of trust.</p>

<h1 id="attested-microphones-for-trusted-audio-capture">Attested microphones for trusted audio capture</h1>

<p>The first tool we will use are called <em>attested microphones</em>. Attested microphones have a hardware unit that <a href="https://en.wikipedia.org/wiki/Digital_signature">cryptographically signs</a> the audio signal as soon as it is captured. This cryptographic signature is <em>unforgeable</em>, even with AI tools. With this signature, anyone can verify that the audio came from a specific microphone. In order to verify that audio came from a specific individual, that person can publish the <em>public key</em> of the attested microphone.</p>

<p>Unfortunately, there’s two limitations of attested microphones. The first (which we will address below) is that attested microphones don’t allow you to perform edits on the audio, including edits like noise reduction or cutting out sensitive information. The second is that these attested microphones currently don’t exist, even though the technology is here. We hope that hardware manufacturers consider building attested microphones to combat AI-generated audio!</p>

<h1 id="zk-snarks-for-verified-edits">ZK-SNARKs for verified edits</h1>

<p>Once we have the raw audio, there are many circumstances where we want to privately edit the original audio. For example, intelligence agencies can use background noise to <a href="https://www.c4isrnet.com/intel-geoint/2020/10/23/the-ambient-audio-in-your-video-could-give-away-its-location-this-intelligence-agency-wants-to-use-that/">identify your location</a>, which compromises privacy. To preserve privacy, we may want to perform edits like removing the background noise or cutting out parts of an interview that might contain sensitive information.</p>

<p>In order to perform these edits, we can use <a href="https://z.cash/technology/zksnarks/">ZK-SNARKs</a>. ZK-SNARKs provide computational integrity. For audio, ZK-SNARKs allow the producer of the audio to privately edit the audio without revealing the original. Similar to cryptographic signatures, ZK-SNARKs are unforgeable, allowing us to extend the chain of trust to edits.</p>

<h1 id="demonstrating-the-technology">Demonstrating the technology</h1>

<p>To showcase the power of attested microphones and ZK-SNARKs, we’ve constructed an <a href="https://wav.zkpod.ai/">end-to-end demonstration</a> of the chain of trust for audio. In our demonstration, we recorded a short 30 second clip, where each of us (Anna, Daniel, and Kobi) recorded on our own microphone. In other words, there are three 30 second clips.</p>

<p>Because attested microphones don’t exist yet, we simulated the attested microphone by signing the individual audio clips with <a href="https://ethereum.org/en/wallets/">Ethereum wallets</a>. These wallets contain private keys that would be similar to the secure hardware elements in the attested microphone. The signatures we’ve produced are also unforgeable, assuming our wallets aren’t compromised.</p>

<p>During the recording process, Daniel’s microphone picked up some background echo, so we wanted to cut it out and combine the clips into one. We produced a ZK-SNARK that verifies these edits were done honestly from the original audio clips. Furthermore, the ZK-SNARK hides the input audio, so you won’t be able to extract the background noise in Daniel’s clip! This helps preserve privacy.</p>

<p>In the following demo, the final audio file is presented coupled with a proof and a set of signatures. The verification program verifies both, ensuring we know the exact chain of operations performed on the input audio files resulting in the audio you can hear.</p>

<h1 id="technical-deep-dive">Technical deep dive</h1>

<p>To understand how our demonstration works at a deeper level, we’ve done a technical deep dive below. You can skip to the conclusion without missing anything!</p>

<p>We’ve outlined the overall architecture below:</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2023-06-13-fighting/fig1.png" alt="Overall architecture of trusted audio" /></p>

<p>As we can see, the first step (after capturing the audio) is to produce the signatures. Since we don’t have attested microphones, we used Ethereum wallet addresses, which are publicly associated with us (Anna, Daniel, and Kobi), to sign hashes of the original audio. Ethereum uses <a href="https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm">ECDSA</a>, which allows anyone to verify the signatures we produced with our public key. The private key must remain hidden. In hardware, this can be done using trusted enclaves. The hardware manufacturer can destroy the private key after it is placed on the device. By doing so, the private key is inaccessible!</p>

<p>Given the signed input audio, we want to be able to edit them with computational integrity while preserving the privacy of the original audio. Under the random oracle model of hashing, the hashes reveal nothing about the input. We can combine the hashes with ZK-SNARKs to preserve privacy.</p>

<p>ZK-SNARKs allow a prover to produce a proof that a function executed honestly while keeping parts of the input hidden (and selectively revealing certain inputs or outputs). In our setting, we can compute a function that computes the hashes of the inputs and outputs the edited audio from the inputs. By revealing the hashes, we can be assured that the inputs match the recorded audio! We’ve shown what happens within the ZK-SNARK below:</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2023-06-13-fighting/fig2.webp" alt="ZK-SNARK" /></p>

<h1 id="conclusions">Conclusions</h1>

<p>As we’ve seen, attested microphones and ZK-SNARKs can provide a chain of trust for audio while preserving privacy. With the rise of AI-generated audio, we’re seeing an increasing need to establish this chain of trust. We hope that our demonstration will spur hardware manufacturers to consider building attested microphones.</p>

<p>Stay tuned for more posts on this topic as we delve deeper into other tools to fight malicious AI-generated content. And if you’d like to discuss your idea or brainstorm with us, fill out <a href="https://forms.gle/5uxR4woshe4Ug9M36">this form</a> and join our <a href="https://t.me/+_iFeU8FQ4p0zOWZh">Telegram group</a>. Follow me on <a href="https://twitter.com/daniel_d_kang">Twitter</a> for the latest updates as well!</p>

<p><em>Important note: the code for this demonstration has not been audited and should not be used in production.</em></p>]]></content><author><name>Daniel Kang, Kobi Gurkan, and Anna Rose</name></author><category term="Blog" /><summary type="html"><![CDATA[AI-generated audio is becoming increasingly indistinguishable from human-produced sound. This emerging technology, while impressive, is unfortunately increasingly misused. We’re witnessing instances where this convincingly replicated audio is being manipulated to conduct scams, perpetrate identity theft, and misused in other ways. How can we safeguard ourselves and effectively combat the misuse of this advanced technology?]]></summary></entry><entry><title type="html">Verified Execution of GPT, Bert, CLIP, and more</title><link href="https://ddkang.github.io/blog/2023/05/22/verified/" rel="alternate" type="text/html" title="Verified Execution of GPT, Bert, CLIP, and more" /><published>2023-05-22T00:00:00+00:00</published><updated>2023-05-22T00:00:00+00:00</updated><id>https://ddkang.github.io/blog/2023/05/22/verified</id><content type="html" xml:base="https://ddkang.github.io/blog/2023/05/22/verified/"><![CDATA[<p>In the current era of AI-driven applications, the use of language models like <a href="https://openai.com/product/gpt-4">GPT</a> and <a href="https://ai.googleblog.com/2018/11/open-sourcing-bert-state-of-art-pre.html">BERT</a> is pervasive. These models are the engines behind tasks ranging from <a href="https://openai.com/blog/chatgpt">chatbots</a> to <a href="https://keras.io/examples/structured_data/movielens_recommendations_transformers/">recommendation systems</a>. However, these AI systems are increasingly executed in opaque ways, such as behind closed APIs.</p>

<p>Because these models are behind closed APIs, users have no guarantees over which models/weights are used. For example, OpenAI recently changed ChatGPT’s behavior (and has on an ongoing basis), leading to <a href="https://twitter.com/petergyang/status/1660314935208054785">speculation</a> that OpenAI is using cheaper models to save costs. However, OpenAI’s models are trade secrets so they have strong incentives to keep them private. How can we verify that these AI models are behaving as claimed without compromising trade secrets?</p>

<p>A few weeks ago, we <a href="https://medium.com/@danieldkang/f5ee1dbf2499">announced</a> the open-source release of <a href="https://github.com/ddkang/zkml">zkml</a>, which allows for the trustless execution of ML models. In this blog post, we’ll recap the capabilities of zkml and how it can be used to verify the outputs of common natural language processing (NLP) models like <a href="https://openai.com/product/gpt-4">GPT</a>, <a href="https://ai.googleblog.com/2018/11/open-sourcing-bert-state-of-art-pre.html">BERT</a>, and <a href="https://openai.com/research/clip">CLIP</a>, all without revealing proprietary weights or private data.</p>

<p>Currently, we can produce proofs of <a href="https://huggingface.co/distilgpt2">GPT-2</a>, <a href="https://arxiv.org/abs/2004.02984">MobileBert</a>, and <a href="https://openai.com/research/clip">CLIP</a>. We’ve released proofs of GPT-2 and CLIP <a href="https://github.com/ddkang/zkml/tree/main/examples/nlp">here</a>, with more models coming soon. In the rest of the post, we’ll describe how to do trustless execution of ML models with ZK-SNARKs and how to use <a href="https://github.com/ddkang/zkml">zkml</a> to produce these proofs!</p>

<h1 id="trustless-execution-with-zero-knowledge-proofs">Trustless Execution with Zero-Knowledge Proofs</h1>

<p><a href="https://en.wikipedia.org/wiki/Zero-knowledge_proof">Zero-knowledge proofs</a> (ZKPs) are cryptographic protocols that allow one party to prove to another that they know a specific piece of information without revealing that information. When applied to machine learning (ML) models, ZKPs can allow a model runner to prove that they ran the model correctly without revealing any specifics about the input data or model parameters.</p>

<p>zkml produces <a href="https://z.cash/technology/zksnarks/">ZK-SNARKs</a>, which are succinct (i.e., short) zero-knowledge proofs. For NLP models such as GPT and BERT, zkml can produce these ZK-SNARKs. We’ve previously described how to use ZK-SNARKs to <a href="https://medium.com/@danieldkang/empowering-users-to-verify-twitters-algorithmic-integrity-with-zkml-65e56d0e9dd9">verify the Twitter algorithm</a> and <a href="https://medium.com/@danieldkang/bridging-the-gap-how-zk-snarks-bring-transparency-to-private-ml-models-with-zkml-e0e59708c2fc">ML models more broadly</a>. Check out those posts for more details!</p>

<h1 id="applying-zkml-to-gpt-bert-and-clip">Applying zkml to GPT, BERT, and CLIP</h1>

<p>Let’s take a look at how we can apply zkml to models like GPT, BERT, and CLIP. The GPT series of models have achieved state-of-the-art performance on language tasks. When fine-tuned on human-generated text, GPT can produce <a href="https://openai.com/blog/chatgpt">state-of-the-art chatbots</a>. Similarly, BERT can be used for a <a href="https://www.tensorflow.org/text/tutorials/bert_glue">range of NLP tasks</a>. In contrast, CLIP is typically used in conjunction <a href="https://towardsdatascience.com/openais-dall-e-and-clip-101-a-brief-introduction-3a4367280d4e">with vision models</a>.</p>

<p>Suppose a user interacts with a service powered by GPT-4, like a chatbot. The chatbot provider can use zkml to prove that the responses are generated by an unaltered version of GPT-4, without disclosing the actual weights of the model or the specifics of the user’s inputs. The process can be simplified:</p>

<ol>
  <li>Generating a Proof: The service provider runs the model with the user’s input and generates a proof that the model was run correctly using zkml.</li>
  <li>Proof Verification: The user or an auditor can then verify the proof. If the proof holds, they can be sure that the model ran correctly without needing to know model weights or the input data.</li>
</ol>

<p>This process can be easily extended to CLIP, BERT, and any other language model.</p>

<h1 id="trustless-execution-in-action">Trustless Execution in Action</h1>

<p>To illustrate the process, let’s take an example where a user is interacting with a GPT powered chatbot. The chatbot provider can use zkml to generate a proof of correct execution.</p>

<p>To use zkml for GPT, we can run the following commands:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># You’ll need to install zkml as described in the instructions here: https://github.com/ddkang/zkml  </span>
<span class="c"># You’ll also need to download the parameters from here: https://drive.google.com/file/d/1bhAYXOzMnAI-tB6VbUkCY7tThQ9L5K6G/view?usp=sharing   </span>
<span class="c"># Place them in the directory params_kzg  </span>
<span class="c"># Because the proving is resource intensive, we’ve provided a proof that you can verify as follows:  </span>
<span class="nb">cd </span>examples/nlp/gpt-2  
<span class="nb">tar</span> <span class="nt">-zxvf</span> vkey.tar.gz  
<span class="nb">tar</span> <span class="nt">-zxvf</span> public_vals.tar.gz  
<span class="nb">cd</span> ../../../  
cargo build <span class="nt">--release</span>  
./target/release/verify_circuit examples/nlp/gpt-2/config.msgpack examples/nlp/gpt-2/vkey examples/nlp/gpt-2/proof examples/nlp/gpt-2/public_vals kzg
</code></pre></div></div>

<p>This process ensures that the chatbot provider is not manipulating the model or the user’s input in any way. Currently, we can produce proofs for GPT-2, MobileBert, and CLIP. Expect more models soon!</p>

<h1 id="toward-a-future-of-trustless-ai">Toward a Future of Trustless AI</h1>

<p>As AI models become an integral part of our lives, the need for transparency grows more important. Trustless execution of AI models using zkml represents a significant step in this direction. By allowing service providers to prove that they’re running models correctly without revealing any sensitive information, zkml brings us closer to a future where we can fully trust AI systems without compromising trade secrets or privacy.</p>

<p>Stay tuned for more posts on this topic, as we delve deeper into the applications of zkml and other tools for AI transparency and accountability. And if you’d like to discuss your idea or brainstorm with us, fill out <a href="https://forms.gle/5uxR4woshe4Ug9M36">this form</a> and join our <a href="https://t.me/+_iFeU8FQ4p0zOWZh">Telegram group</a>. Follow me on <a href="https://twitter.com/daniel_d_kang">Twitter</a> for the latest updates as well!</p>

<p><em>Special thanks to Pun Waiwitlikhit, Yi Sun, Tatsunori Hashimoto, and Ion Stoica for their help.</em></p>]]></content><author><name>Daniel Kang</name></author><category term="Blog" /><summary type="html"><![CDATA[In the current era of AI-driven applications, the use of language models like GPT and BERT is pervasive. These models are the engines behind tasks ranging from chatbots to recommendation systems. However, these AI systems are increasingly executed in opaque ways, such as behind closed APIs.]]></summary></entry><entry><title type="html">Empowering Users to Verify Twitter’s Algorithmic Integrity with zkml</title><link href="https://ddkang.github.io/blog/2023/04/17/empowering/" rel="alternate" type="text/html" title="Empowering Users to Verify Twitter’s Algorithmic Integrity with zkml" /><published>2023-04-17T00:00:00+00:00</published><updated>2023-04-17T00:00:00+00:00</updated><id>https://ddkang.github.io/blog/2023/04/17/empowering</id><content type="html" xml:base="https://ddkang.github.io/blog/2023/04/17/empowering/"><![CDATA[<p>Last week, Twitter <a href="https://blog.twitter.com/engineering/en_us/topics/open-source/2023/twitter-recommendation-algorithm">open-sourced</a> their algorithm for selecting and ranking the posts in the “For You” timeline. While this is a major step towards transparency, users cannot verify that the algorithm is being run correctly! One major reason is because the weights for the ML models used to rank tweets have been withheld to protect user privacy. However, these weights are a <a href="https://www.engadget.com/what-did-twitters-open-source-algorithm-actually-reveal-not-a-lot-194652809.html">key factor</a> in determining what tweets show up in each user’s customized feed. Without the weights it is difficult to verify what, if any, biases and censorship may have led to specific tweets being shown, leading to <a href="https://www.theregister.com/2023/04/13/reveal_all_recommendation_algorithms/">calls</a> to reveal all recommendation algorithms. Can we resolve the tensions between privacy and transparency?</p>

<p>Today, we’ll show how Twitter can prove that the Tweets you’re shown are exactly those ranked by a specific, un-altered version of their ML model using our system <a href="https://github.com/ddkang/zkml">zkml</a>! Specifically, we show how to balance privacy and transparency by producing <em>proofs</em> that the Twitter algorithm ran honestly without releasing the model weights. In doing so, Twitter can produce <a href="https://medium.com/p/6f648fd8ba88">trustless audits</a> of their model.</p>

<p>To accomplish this, we use recently developed tools from cryptography called <a href="https://z.cash/technology/zksnarks/">ZK-SNARKs</a>. ZK-SNARKs allow an algorithm runner to produce a proof that some computation happened honestly — anyone can use the proof to check that the algorithm ran correctly without rerunning the algorithm. In our setting, we’ll focus on the key driver of the decision: the ranking ML model. We’ve previously described how to <a href="https://medium.com/@danieldkang/e0e59708c2fc">construct ZK-SNARKs</a> for <a href="https://medium.com/@danieldkang/trustless-verification-of-machine-learning-6f648fd8ba88">real-world vision models</a> using our <a href="https://medium.com/@danieldkang/open-sourcing-zkml-trustless-machine-learning-for-all-f5ee1dbf2499">open-source framework</a> zkml, so in this post we will discuss how to use our framework to support this core piece of the Twitter timeline.</p>

<p>In the rest of the post, we’ll describe how Twitter’s “For You” page is generated, how to use zkml to prove the Twitter ranking model executed honestly, and how to use our framework in the broader context of verifying the “For You” page. If you haven’t seen ZK-SNARKs before, <a href="https://medium.com/@danieldkang/e0e59708c2fc">our explainer</a> for how ZK-SNARKs can be used for ML may be helpful for understanding the rest of the post!</p>

<h1 id="how-twitters-for-you-page-works">How Twitter’s “For You” page works</h1>

<p>The twitter algorithm operates by collecting data, training a model, and using the model to rank posts to show on your “For You” timeline. At a high level, the algorithm:</p>

<ol>
  <li>Generates features from user interactions with the site, such as likes and retweets.</li>
  <li>Learns what users would engage with via the <em>ranking model</em>.</li>
  <li>Generates a candidate set of tweets to show to users.</li>
  <li>Ranks the candidate set of tweets using the learned ranking model.</li>
</ol>

<p>Twitter produced a helpful diagram to show the overall steps:</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2023-04-17-empowering/fig1.webp" alt="Source: [https://github.com/twitter/the-algorithm](https://github.com/twitter/the-algorithm)
" /></p>

<p>The most important part of the algorithm is the heavy ranker (in the middle), which is the ranking model. Despite the open-source release (including the ranker architecture), users have no guarantees as to what Twitter is running! One way for Twitter to show the algorithm is run in production is to release the weights, training data, and inputs. However, this would violate users’ privacy, so Twitter can’t release the inputs or weights. In order to allow Twitter to prove that their algorithm ran honestly, we’ll turn to ZK-SNARKs.</p>

<h1 id="using-zkml-to-zk-snark-twitters-ranking-model">Using zkml to ZK-SNARK Twitter’s ranking model</h1>

<p>As we mentioned, ZK-SNARKs can allow Twitter to prove that the model was run honestly. At a high level Twitter can use ZK-SNARKS to commit to a specific version of their ranking model and then publish a proof that when the model is applied to a specific user and tweet, it produces the specific final output ranking. The model commitment (a model signature or hash), proof, as well as per-user and per-tweet input features can be shared with users. See our <a href="https://medium.com/@danieldkang/bridging-the-gap-how-zk-snarks-bring-transparency-to-private-ml-models-with-zkml-e0e59708c2fc">explainer post</a> for more details on how zkml integrates with the traditional ML workflow.</p>

<p>Once the proof is made available, there is no need for additional trust for this stage of the algorithm: users can verify on their own that the computations were performed as promised. Furthermore the specific committed ranking model can be audited by third parties without revealing its weights publicly.</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2023-04-17-empowering/fig2.webp" alt="Architecture" /></p>

<p>To do so with <a href="https://github.com/ddkang/zkml">zkml</a>, we can simply run the following commands (after building zkml with the instructions in the <a href="https://github.com/ddkang/zkml">README</a>), where model.msgpack contains the model weights and inp.msgpack is the input to the model:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># This constructs the proof, which the Twitter engineer would do.  </span>
<span class="c"># For demonstration purposes, we’ve decided to withhold the model  </span>
<span class="c"># weights for the time being!  </span>
./target/release/test_circuit examples/twitter/model.msgpack examples/twitter/inp1.msgpack  
  
<span class="c"># This verifies the proof with only the open-source model signature,   </span>
<span class="c"># which we would do to check our “For You” timeline.  </span>
<span class="c"># You don’t need the model to do the verification!  </span>
<span class="c"># First, we need to decompress the verification key (see our explainer post for details)  </span>
<span class="nb">tar</span> <span class="nt">-xzvf</span> examples/twitter/vkey.tar.gz <span class="nt">-C</span> examples/twitter  
<span class="c"># You’ll also need to download the parameters to the directory `params_kzg` from here: https://drive.google.com/file/d/1vesRlcIiMkFdoiISYVUO4RQgY-6-6M6V/view?usp=share_link   </span>
<span class="c"># We’ve provided the public values in the repository  </span>
./target/release/verify_circuit examples/twitter/config.msgpack examples/twitter/vkey examples/twitter/proof1 examples/twitter/public_vals1 kzg
</code></pre></div></div>

<p>The actual proofs take a while to generate so we’ve pre-generated them for three examples, which you can verify with the second command. It will take some time to load the data, but the verification itself only takes 8.4ms on a standard laptop!</p>

<p>The final output you’ll see are the probabilities for different sub-model scores that are aggregated into a single final ranking score per tweet. In this example, we’ve converted a trained model and are testing that the circuit evaluates correctly. The actual proofs take a while to generate so we’ve computed them ahead of time <a href="https://github.com/ddkang/zkml/tree/main/examples/twitter">here</a>.</p>

<p>What’s important about our framework is that the weights can be <em>hidden</em> while anyone can be convinced from the proof that the execution happened honestly!</p>

<h1 id="verify-your-timeline">Verify your timeline</h1>

<p>Now that we can be assured that the ranking algorithm is scoring tweets correctly with zkml, we’ll describe how to use it to verify your timeline. Although the ranking model is the most important component in the algorithm, there are other components that need to be verified as well. We won’t be modeling the other components in this post, but they could be verified by other cryptographic tools, e.g., <a href="https://eprint.iacr.org/2017/1146">vSQL</a> or others.</p>

<p>However, there’s still one issue: we need to be assured that Twitter isn’t censoring certain tweets or manually down ranking them. In order to do this, we can “spot check” a given timeline using an interactive protocol.</p>

<p>Let’s say I think my timeline is suspect and that there’s a tweet that I think should rank highly. If Twitter incorporated zkml proofs into their product, I would be able to request proofs of the ranking model execution for tweets in my timeline as well as the suspected censored tweet. Then, I can check to see how the suspected censored tweet ranks compared to the other tweets in my timeline!</p>

<p>If I find that the proof isn’t valid, I’ll have reason to believe that the ranking model (identified by a hash signature in the diagram) Twitter supposedly committed to was altered.</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2023-04-17-empowering/fig3.webp" alt="Censorship" /></p>

<h1 id="stay-tuned-for-more">Stay tuned for more!</h1>

<p>In this post, we’ve described how to use zkml to verify your Twitter timeline. Our code is <a href="https://github.com/ddkang/zkml">open-source</a> and we’re excited to see how it can be used to improve transparency in social media without requiring trust in the complex and opaque systems powering them. Nonetheless, there’s still a lot of work to do to make zkml practical and accessible to everyone. We’ll be working on increasing its efficiency in the coming months.</p>

<p>We’ll also be describing other uses of zkml in the coming weeks — stay tuned! And if you’d like to discuss your idea or brainstorm with us, fill out <a href="https://forms.gle/5uxR4woshe4Ug9M36">this form</a> and join our <a href="https://t.me/+_iFeU8FQ4p0zOWZh">Telegram group</a>. Follow me on <a href="https://twitter.com/daniel_d_kang">Twitter</a> for latest updates as well!</p>]]></content><author><name>Daniel Kang, Edward Gan, Ion Stoica, and Yi Sun</name></author><category term="Blog" /><summary type="html"><![CDATA[Last week, Twitter open-sourced their algorithm for selecting and ranking the posts in the “For You” timeline. While this is a major step towards transparency, users cannot verify that the algorithm is being run correctly! One major reason is because the weights for the ML models used to rank tweets have been withheld to protect user privacy. However, these weights are a key factor in determining what tweets show up in each user’s customized feed. Without the weights it is difficult to verify what, if any, biases and censorship may have led to specific tweets being shown, leading to calls to reveal all recommendation algorithms. Can we resolve the tensions between privacy and transparency?]]></summary></entry><entry><title type="html">Bridging the Gap: How ZK-SNARKs Bring Transparency to Private ML Models with zkml</title><link href="https://ddkang.github.io/blog/2023/04/12/bridging/" rel="alternate" type="text/html" title="Bridging the Gap: How ZK-SNARKs Bring Transparency to Private ML Models with zkml" /><published>2023-04-12T00:00:00+00:00</published><updated>2023-04-12T00:00:00+00:00</updated><id>https://ddkang.github.io/blog/2023/04/12/bridging</id><content type="html" xml:base="https://ddkang.github.io/blog/2023/04/12/bridging/"><![CDATA[<p>ML is becoming integrated into our lives, ranging from what we see on social media to making medical decisions. However, ML models are increasingly being executed behind closed APIs. There are good reasons for this: model weights may be unable to be revealed for privacy reasons if they are trained on user data (e.g., medical data) and companies want to protect trade secrets. For example, Twitter recently open-sourced their “For You” timeline ranking algorithm but couldn’t release the weights for privacy reasons. OpenAI has also not released weights for GPT-3 or 4.</p>

<p>As ML becomes integrated with our lives, there’s a growing need for assurances that the ML models have desirable properties and were executed honestly. For ML, we need assurances that the model ran as promised (computational integrity) and that the correct weights were used (while maintaining privacy). For example, for the GPT and Twitter ranking models, we would like to confirm that the model results are consistently unbiased and uncensored. How can we balance the need for privacy (of the user data and model weights) and transparency?</p>

<p>To accomplish this, we can use a cryptographic technique called ZK-SNARKs. ZK-SNARKs have seemingly magical properties of allowing a ML model owner to prove the model executed honestly without revealing the weights!</p>

<p>In the rest of the post, we’ll describe what ZK-SNARKs are and how to use them to balance the goals of privacy and transparency. We’ll also describe how to use our recently <a href="https://medium.com/@danieldkang/open-sourcing-zkml-trustless-machine-learning-for-all-f5ee1dbf2499">open-sourced</a> framework <a href="https://github.com/ddkang/zkml">zkml</a> to generate ZK-SNARKs of ML models.</p>

<h1 id="zk-snarks-for-ml">ZK-SNARKs for ML</h1>

<p>It’s important to understand one of the key cryptographic building blocks that enable privacy-preserving computations: Zero-Knowledge Succinct Non-Interactive Argument of Knowledge (ZK-SNARK). ZK-SNARKs are a powerful cryptographic primitive that allows one party to prove the validity of a computation without revealing any information about the inputs to the computation itself! ZK-SNARKs also don’t require any interaction beyond the proof and don’t require the verifier of the computation to execute the computation itself.</p>

<p>ZK-SNARKs are also <em>succinct</em>, meaning they are small (typically constant or logarithmic size)
relative to the computation! Concretely, for even large models, the proofs are typically less than
5kb. This is desirable since many kinds of cryptographic protocols require gigabytes or more of
communication, saving up to up to <em>six orders of magnitude</em> of communication.</p>

<p align="center">
  <img src="https://ddkang.github.io/assets/images/blog/2023-04-12-bridging/fig1.webp" />
</p>

<p>Given a set of public inputs (x) and private inputs (w), ZK-SNARKS can prove that a relation F(x,w)
holds between the values without revealing the private inputs. For example, a prover can prove they
know the solution to a sudoku problem. Here, the public inputs are the starting squares and the
private inputs are the remainder of the squares that constitute the solution.</p>

<p>In the context of ML, ZK-SNARKs can prove that the ML model executed correctly <em>without</em> revealing
the model weights. In this case, the model weights w are the private input, the model input features
F and output O are part of the public input. In order to identify the model, we also include a
<em>model commitment</em> C in the public input. The model commitment functions like a hash, so that with
high probability if the weights were modified the commitments would differ as well. Thus x =
(C,F,O). Then the relation we want to prove is that, for some private weight value w, having
commitment C, the model outputs O on inputs F.</p>

<p>If a verifier is then given the proof π (and x), they can verify that the ML model ran correctly:</p>

<p align="center">
  <img src="https://ddkang.github.io/assets/images/blog/2023-04-12-bridging/fig2.webp" />
</p>

<p>To give a concrete example, Twitter can prove they ran their ranking algorithm honestly to generate
your timeline. A medical ML provider can also provide a proof that a specific regulator-approved
model was executed honestly as well.</p>

<h1 id="using-zkml-for-trustless-execution-of-ml-models">Using zkml for trustless execution of ML models</h1>

<p>We’ve
<a href="https://medium.com/@danieldkang/open-sourcing-zkml-trustless-machine-learning-for-all-f5ee1dbf2499">open-sourced</a>
our library <a href="https://github.com/ddkang/zkml">zkml</a> to construct proofs of ML model execution and
allow anyone to verify these proofs. But first, let’s look at what a standard ML provider would do:</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2023-04-12-bridging/fig3.png" alt="Standard ML pipeline with an ML model consumer and provider" /></p>

<p>As we can see here, the ML consumer provides the inputs but has no assurances that the model executed correctly! With zkml, we can add a single step to provide guarantees that the model executed correctly! As we can see, the ML consumer doesn’t learn anything about the weights:</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2023-04-12-bridging/fig4.webp" alt="Augmenting the standard ML pipeline with zkml" /></p>

<p>To demonstrate how to use zkml to trustlessly execute an ML model, we’ll construct a proof of a model that achieves 99.5% accuracy on <a href="https://en.wikipedia.org/wiki/MNIST_database">MNIST</a>, a standard ML image recognition dataset. zkml will generate the proof, but also the proving key and verification key which allows the prover to produce the proof (proving key) and the verifier to verify that the execution happened honestly (verification key). First, to construct the proof, proving key, and verification key, simply execute the following commands:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Installs rust, skip if you already have rust installed  </span>
curl <span class="nt">--proto</span> <span class="s1">'=https'</span> <span class="nt">--tlsv1</span>.2 <span class="nt">-sSf</span> https://sh.rustup.rs | sh  
  
git clone https://github.com/ddkang/zkml.git  
<span class="nb">cd </span>zkml  
rustup override <span class="nb">set </span>nightly  
cargo build <span class="nt">--release</span>  
<span class="nb">mkdir </span>params_kzg  
  
<span class="c"># This should take ~8s to run the first time and ~4s to run the second time  </span>
./target/release/time_circuit examples/mnist/model.msgpack examples/mnist/inp.msgpack kzg
</code></pre></div></div>

<p>This will construct the proof, where the proving key is generated during the process. Here, model.msgpack is the model weights and inp.msgpack is the input to the model (in this case, it’s an image of a handwritten 5). The proof generation will also generate the public values x (including the model commitment), which we’ll use in the next step. It will also generate a verification key, as we described above. You’ll see the following output:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;snip&gt;  
final out[0] x: -5312 (-10.375)  
final out[1] x: -8056 (-15.734375)  
final out[2] x: -8186 (-15.98828125)  
final out[3] x: -1669 (-3.259765625)  
final out[4] x: -4260 (-8.3203125)  
final out[5] x: 6614 (12.91796875)  
final out[6] x: -5131 (-10.021484375)  
final out[7] x: -6862 (-13.40234375)  
final out[8] x: -3047 (-5.951171875)  
final out[9] x: -805 (-1.572265625)  
&lt;snip&gt;
</code></pre></div></div>

<p>The outputs you see here are the logits of the model, which can be converted to probabilities. As we can see, the 5th output is the largest, meaning the model correctly classified the 5.</p>

<p>Given the proof, a verifier can verify the ML model executed correctly <em>without</em> the model weights. Here, the vkey is the verification key, the proof is π, and the public_vals is the public output:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>./target/release/verify_circuit examples/mnist/config.msgpack vkey proof public_vals kzg  
  
Proof verified!
</code></pre></div></div>

<p>Which should show you that the proof verified correctly. Notice the verifier only needs the configuration, verification key, proof, and public values!</p>

<h1 id="stay-tuned">Stay tuned!</h1>

<p>We’ll have more posts upcoming to describe the applications of <a href="https://github.com/ddkang/zkml">zkml</a> in more detail! Check out our <a href="https://github.com/ddkang/zkml">open-source repository</a> and if you’d like to discuss your idea or brainstorm with us, fill out <a href="https://forms.gle/5uxR4woshe4Ug9M36">this form</a>!</p>

<p><em>Thanks to</em> <a href="https://yisun.io/"><em>Yi Sun</em></a> <em>for comments on this blog post.</em></p>]]></content><author><name>Daniel Kang, Edward Gan</name></author><category term="Blog" /><summary type="html"><![CDATA[ML is becoming integrated into our lives, ranging from what we see on social media to making medical decisions. However, ML models are increasingly being executed behind closed APIs. There are good reasons for this: model weights may be unable to be revealed for privacy reasons if they are trained on user data (e.g., medical data) and companies want to protect trade secrets. For example, Twitter recently open-sourced their “For You” timeline ranking algorithm but couldn’t release the weights for privacy reasons. OpenAI has also not released weights for GPT-3 or 4.]]></summary></entry><entry><title type="html">Open-sourcing zkml: Trustless Machine Learning for All</title><link href="https://ddkang.github.io/blog/2023/04/03/open-source/" rel="alternate" type="text/html" title="Open-sourcing zkml: Trustless Machine Learning for All" /><published>2023-04-03T00:00:00+00:00</published><updated>2023-04-03T00:00:00+00:00</updated><id>https://ddkang.github.io/blog/2023/04/03/open-source</id><content type="html" xml:base="https://ddkang.github.io/blog/2023/04/03/open-source/"><![CDATA[<p>We’re excited to announce the open-source release of zkml, our framework for producing zero-knowledge proofs of ML model execution. zkml builds on our <a href="https://medium.com/@danieldkang/trustless-verification-of-machine-learning-6f648fd8ba88">earlier paper</a> on scaling zero-knowledge proofs to ImageNet models but contains many improvements for usability, functionality, and scalability. With our improvements, we can verify execution of models that achieve <strong>92.4%</strong> accuracy on ImageNet, a 13% improvement compared to our initial work! zkml can also prove an MNIST model with 99% accuracy <strong>in four seconds</strong>.</p>

<p>In this post, we’ll describe our vision for zkml and how to use zkml. In future posts, we’ll describe several applications of zkml in detail, including trustless audits, decentralized prompt marketplaces, and privacy-preserving face ID. We’ll also describe the technical challenges and details behind zkml. In the meantime, check out our <a href="https://github.com/ddkang/zkml">open-source code</a>!</p>

<h1 id="why-do-we-need-trustless-machine-learning">Why do we need trustless machine learning?</h1>

<p>Over the past few years, we’ve seen two inescapable trends: more of our world moving online and ML/AI methods becoming increasingly powerful. These ML/AI technologies have enabled new forms of art and incredible productivity increases… However, these technologies are increasingly concealed behind closed APIs.</p>

<p>Although these providers want to protect trade secrets, we want to have assurances of their models: that the training data doesn’t contain copyrighted material or that it isn’t biased. We also want assurances that a specific model was executed in high-stakes scenarios, such as medical industries.</p>

<p>In order to do so, the model provider can take two steps: commit to a model trained on a <em>hidden</em> dataset, and provide audits of the hidden dataset after training. In the first step, the model provider releases proofs of training on a given dataset and a commitment to the weights at the end of the process. Importantly, the <em>weights can be kept hidden</em>! By doing so, any third party can be assured that the training happened honestly. Then, the audit can be done using zero-knowledge proofs over the hidden data.</p>

<p>We have been imagining a future where ML models can be executed trustlessly. As we’ll describe in future posts, trustless execution of ML models will enable a range of applications:</p>

<ol>
  <li>Trustless audits of ML-powered applications, such as proving that no copyrighted images were used in a training dataset, as we described above.</li>
  <li>Verification that specific ML models were run by ML-as-a-service providers for regulated industries.</li>
  <li>Decentralized prompt marketplaces for generative AI, where creators can sell access to their prompts.</li>
  <li>Privacy-preserving biometric authentication, such as enabling smart contracts to use face ID.</li>
</ol>

<p>And many more!</p>

<h1 id="zk-snarks-for-trustless-ml">ZK-SNARKs for trustless ML</h1>

<p>In order to trustlessly execute ML models, we can turn to powerful tools in cryptography. We focus on <a href="https://consensys.net/blog/developers/introduction-to-zk-snarks/">ZK-SNARKs</a> (zero-knowledge succinct non-interactive argument of knowledge), which are tools that allow a prover to prove an arbitrary computation was done correctly using a short proof. ZK-SNARKs also have the amazing property that the inputs and intermediate variables (e.g., activations) can be hidden!</p>

<p>In the context of ML, we can use a ZK-SNARK to prove that a model was executed correctly on a given input, <em>while hiding the model weights, inputs, and outputs</em>. We can further choose to selectively reveal any of the weights, inputs, or outputs depending on the application at hand.</p>

<p>With this powerful primitive, we can enable trustless audits and all the other applications we described above!</p>

<h1 id="zkml-a-first-step-towards-trustless-ml">zkml: a first step towards trustless ML</h1>

<p>As a first step towards trustless ML model execution for all, we’ve open-sourced <a href="https://github.com/ddkang/zkml">zkml</a>. To use zkml, consider proving the execution of an MNIST model by producing a ZK-SNARK. Using zkml, we can run the following commands:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Installs rust, skip if you already have rust installed</span>
curl <span class="nt">--proto</span> <span class="s1">'=https'</span> <span class="nt">--tlsv1</span>.2 <span class="nt">-sSf</span> https://sh.rustup.rs | sh

git clone https://github.com/ddkang/zkml.git
<span class="nb">cd </span>zkml
rustup override <span class="nb">set </span>nightly
cargo build <span class="nt">--release</span>
<span class="nb">mkdir </span>params_kzg

<span class="c"># This should take ~8s to run the first time and ~4s to run the second time</span>
./target/release/time_circuit examples/mnist/model.msgpack examples/mnist/inp.msgpack kzg
</code></pre></div></div>

<p>On a regular laptop, the proving time is as little as 4 seconds and consumes ~2GB of RAM. We’re also the first framework to be able to compute ZK-SNARKs at ImageNet scale. As a sneak preview, we can achieve non-trivial accuracy on ImageNet in under 4 minutes and 92.4% in under 45 minutes of proving:</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2023-04-03-open-source/acc.png" alt="Accuracy on imagenet" /></p>

<p>We’ve increased accuracy by 13%, decreased proving cost by 6x, and decreased verification times by 500x compared to our initial work!</p>

<p>Our primary focus for zkml is high efficiency. Existing approaches are resource-intensive, taking days to prove small models, many gigabytes of RAM, or producing large proofs. We’ll describe how zkml works under the hood in future posts.</p>

<p>We believe that efficiency is critical <em>because</em> it enables the future where anyone can execute ML trustlessly and we’ll continue pushing towards that goal. Currently, models like GPT-4 and Stable Diffusion are out of reach and we hope to change that soon!</p>

<p>Furthermore, zkml can enable trustless audits and all of the other applications we’ve mentioned! In addition to performance improvements, we’ve also been working on new features, including enabling proofs of training and trustless audits. We’ve also been adding features for models beyond vision models.</p>

<h1 id="and-theres-much-more">And there’s much more…</h1>

<p>In this post, we’ve described our vision of zkml and how to use zkml. <a href="https://github.com/ddkang/zkml">Check it out</a> yourself!</p>

<p>There’s still a lot of work to be done to improve zkml. In the meantime, join our <a href="https://t.me/+_iFeU8FQ4p0zOWZh">Telegram group</a> to discuss your ideas for improving or uzing zkml. You can check out our code directly on GitHub, but we’d also love to hear your ideas for how to build with zkml. If you’d like to discuss your idea or brainstorm with us, fill out <a href="https://forms.gle/5uxR4woshe4Ug9M36">this form</a>. We’ll be developing actively on <a href="https://github.com/ddkang/zkml">the GitHub</a> and we’re happy to accept contributions!</p>

<p>In upcoming posts, we’ll describe how to use zkml to:</p>

<ol>
  <li>Perform trustless audits of ML-powered applications</li>
  <li>Build decentralized prompt marketplaces for generative AI</li>
  <li>Enable privacy-preserving biometric ID</li>
</ol>

<p>We’ll also describe the inner workings of zkml and its optimizations. Stay tuned!</p>

<p><em>Thanks to Ion Stoica, Tatsunori Hashimoto, and Yi Sun for comments on this post.</em></p>]]></content><author><name>Daniel Kang</name></author><category term="Blog" /><summary type="html"><![CDATA[We’re excited to announce the open-source release of zkml, our framework for producing zero-knowledge proofs of ML model execution. zkml builds on our earlier paper on scaling zero-knowledge proofs to ImageNet models but contains many improvements for usability, functionality, and scalability. With our improvements, we can verify execution of models that achieve 92.4% accuracy on ImageNet, a 13% improvement compared to our initial work! zkml can also prove an MNIST model with 99% accuracy in four seconds.]]></summary></entry><entry><title type="html">Attacking ChatGPT with Standard Program Attacks</title><link href="https://ddkang.github.io/blog/2023/02/14/attacks/" rel="alternate" type="text/html" title="Attacking ChatGPT with Standard Program Attacks" /><published>2023-02-14T00:00:00+00:00</published><updated>2023-02-14T00:00:00+00:00</updated><id>https://ddkang.github.io/blog/2023/02/14/attacks</id><content type="html" xml:base="https://ddkang.github.io/blog/2023/02/14/attacks/"><![CDATA[<p>Large language models (LLMs) have become increasingly powerful in their capabilities: they can now <a href="https://arxiv.org/abs/2212.14402">pass the Bar</a>, <a href="https://arxiv.org/abs/2212.13138">answer clinical questions</a>, and <a href="https://github.com/features/copilot">write code</a>. Their capabilities are driven by larger models but also new capabilities in <em>instruction following</em>, in which LLMs are trained to follow instructions. Instruction-tuned models outperform standard LLMs on a <a href="https://crfm.stanford.edu/helm/latest/">range of benchmarks</a>. Unfortunately, as these LLMs increase in capabilities, the potential for their dual-use, or misuse, and the economic incentives for dual-use both increase.</p>

<p>In our <a href="http://arxiv.org/abs/2302.05733">recent paper</a>, we show that instruction-following LLMs can generate malicious content <em>effectively</em> and <em>economically</em>, and that dual-use is difficult to prevent. To generate this malicious content, we demonstrate that attacks based on traditional computer security attacks can bypass in-the-wild defenses against misuse. Although our attacks modify or obfuscate prompts, we show that these LLMs can generate natural and convincing <em>personalized</em> malicious content. Our results suggest that the new capabilities of these LLMs increase the economic incentives for adversaries to misuse LLMs and circumvent defenses, given that the cost of operation is estimated to be substantially lower compared to human effort alone.</p>

<p>In addition to our work, there has been a lot of great work by folks including <a href="http://twitter.com/goodside">@goodside</a> and others on prompt injections and other forms of attacks! Our work aims to highlight how these attacks can be connected to classic security settings and economic incentives around attacking LLM providers.</p>

<p>In the rest of the post, we describe our attacks from the lens of computer security and our analysis of the effectiveness and economics of malicious generations. Read our <a href="http://arxiv.org/abs/2302.05733">full paper</a> for extended details!</p>

<h1 id="black-box-llm-setting">Black box LLM setting</h1>

<p>In our work, we study the black box LLM setting, where an API provider serves text generations from an LLM. These API providers are becoming increasingly popular due to the improved capabilities of LLMs and in particular instruction-following LLMs.</p>

<p>As these LLMs have improved in capabilities, so has their potential for misuse. API providers have created mitigations against such misuse, including input filters, output filters, and useless generations. We show two examples below:</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2023-02-14-attacks/defense1.png" alt="An example of the input and output filter triggering." /></p>
<p align="center">
An example of the input and output filter triggering.
</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2023-02-14-attacks/defense2.png" alt="An example of a useless generation" /></p>
<p align="center">
An example of a useless generation.
</p>

<p>Our setting raises two natural questions. Is it possible to produce prompts that bypass defenses that an API provider may put in place? And for malicious actors that are economically motivated, can these attackers use these APIs to produce malicious content <em>economically</em>?</p>

<h1 id="program-attacks-and-their-applicability-to-llms">Program attacks and their applicability to LLMs</h1>

<p>We first studied if it is possible to bypass in-the-wild defenses by LLM providers. Our first observation was that instruction-following LLMs behave closer to traditional programs. So, in order to bypass in-the-wild defenses, we designed three classes of attacks inspired by <em>traditional</em> computer program attacks.</p>

<h2 id="obfuscation">Obfuscation</h2>

<p>In standard program attacks, <a href="https://www.extrahop.com/resources/attacks/malware-obfuscation/#:~:text=Malware%20obfuscation%20is%20the%20act,to%20hide%20its%20presence%20completely.">obfuscation</a> changes the program bytecode to evade detection mechanisms, such as hash-bashed or fingerprinting detection methods. Similarly, we can obfuscate prompts to evade input filters. For example, we can use typos or synonyms to obfuscate LLM prompts.OpenAI’s content filters aim to filter misinformation and disinformation about COVID-19. Instead of using the term “COVID-19,” an attacker could use the term “CVID.”</p>

<h2 id="code-injectionpayload-splitting">Code injection/payload splitting</h2>

<p>Another standard program attack is <a href="https://owasp.org/www-community/attacks/Code_Injection">code injection</a>, in which the malicious code is executed by forcing the program to process invalid data. One standard way of performing code injection is to split the malicious payload and force the program to execute the malicious code by changing the instruction pointer.</p>

<p>Similarly, we can break the prompt into multiple pieces and have the LLM reassemble them. As a concrete example, consider the following prompt:</p>

<p align="center">
  <img src="https://ddkang.github.io/assets/images/blog/2023-02-14-attacks/injection.png" />
</p>

<p>At the time of conducting our experiments, this prompt bypassed both the input and output filters.</p>

<h2 id="virtualization">Virtualization</h2>

<p>One sophisticated attack on traditional computer programs is to embed a virtual machine in the malicious payload and execute the malicious code within the virtual machine. A recent nation-state attack on the iPhone used <a href="https://googleprojectzero.blogspot.com/2021/12/a-deep-dive-into-nso-zero-click.html">virtualization</a> to target journalists via a zero-day exploit. The attack operates by embedding the payload in image metadata and forcing the execution of the virtual machine.</p>

<p>We can adapt this attack to LLMs by encoding the desired attack within a “virtual machine.” Similar to how a standard VM executes instructions that are emulated by the base operating system/hardware unit, an LLM can “emulate” instructions by prompts constructing fictitious scenarios. For example, we can use the following series of prompts to bypass filters:</p>

<p align="center">
  <img src="https://ddkang.github.io/assets/images/blog/2023-02-14-attacks/virtualization.png" />
</p>

<h2 id="feasibility-of-defenses">Feasibility of defenses</h2>

<p>Our attacks are targeted towards OpenAI’s systems. Certain defenses may be able to defend against the specific instantiations of the attacks, such as robust encodings to defend against typos. Nonetheless, our attacks raise important questions regarding the security of model providers in the wild.</p>

<p>For example, both our indirection and virtualization attacks reveal an important property that is apparent in standard programs: since programs are Turing complete, the behavior of sufficiently complex programs can only be predicted by executing the program. A formal version of this statement follows from the undecidability of the halting problem. In LLMs, this suggests that input filtering is limited in its ability to stop attacks.</p>

<h1 id="effectiveness-of-malicious-generations">Effectiveness of malicious generations</h1>

<p>Attacks inspired by traditional security highlight the cat-and-mouse nature of preventing malicious use, which has been the case for standard computers for 75 years. Many traditional computer hackers dedicate substantial resources to finding new attacks due to the economic benefits of doing so. Will malicious actors similarly be motivated to bypass LLM defenses?</p>

<p>We believe the answer is yes, since jailbreaking LLMs allows malicious actors to derive considerable economic benefits. For example, we asked ChatGPT to generate a scam email to con an unsuspecting citizen to purchase fake tickets to a Taylor Swift concert:</p>

<p align="center">
  <img src="https://ddkang.github.io/assets/images/blog/2023-02-14-attacks/taylor1.png" />
</p>
<p align="center">
  <img src="https://ddkang.github.io/assets/images/blog/2023-02-14-attacks/taylor2.png" />
</p>

<p>As we can see, ChatGPT can generate convincing emails <em>and</em> be personalized to the response. We also tried four other diverse responses from the citizen and found that ChatGPT is successfully able to personalize the responses!</p>

<p>To further study the effectiveness of malicious generations, we picked five scams from the US government’s list of common scams and generated emails based on these scams.</p>

<p>In our first experiment, we generated a malicious email, wrote a reply, and responded to the reply. We used five models: ChatGPT, text-davinci-003, text-ada-001, davinci, and GPT2-XL. We measured the convincingness and consistency of the initial email and the response on a five-point Likert scale using human raters:</p>

<p align="center">
  <img src="https://ddkang.github.io/assets/images/blog/2023-02-14-attacks/convincing.png" />
</p>

<p>As we can see, the large, instruction-following models strongly outperform baselines!</p>

<p>We ran a similar experiment for <em>personalized</em> scams, where we targeted the initial email to a fictitious individual’s specific circumstance and demographic information. For the personalization experiment, we measured the personalization, convincingness, consistency, and fluency on a five-point Likert scale using human raters:</p>

<p align="center">
  <img src="https://ddkang.github.io/assets/images/blog/2023-02-14-attacks/personal.png" />
</p>

<p>As before, the large, instruction-following models strongly outperformed baselines.</p>

<p>Our results show that large, instruction-following LLMs can produce convincing and personalized scams. As LLMs increase in capabilities, so do the economic incentives to use them for malicious purposes.</p>

<h1 id="instruction-following-llms-behave-like-programs">Instruction-Following LLMs Behave like Programs</h1>

<p>The property of instruction-following LLMs we leverage in our attacks is their <em>program-like behavior</em>. This observation is also key in a class of traditional program attacks called return-oriented programming (ROP). In ROP, an attacker gains control of the call stack and executes instructions already present in memory. These instructions are often isolated into “gadgets” and can be chained together.</p>

<p>Similarly, new LLMs also have several gadgets including:</p>

<ol>
  <li>String concatenation</li>
  <li>Variable assignment</li>
  <li>Sequential composition (i.e., following a sequence of instructions)</li>
  <li>Branching</li>
</ol>

<p>We can illustrate the first three capabilities with the following prompt and generation:</p>

<p align="center">
  <img src="https://ddkang.github.io/assets/images/blog/2023-02-14-attacks/program1.png" />
</p>

<p>And branching with the following prompt and generation:</p>

<p align="center">
  <img src="https://ddkang.github.io/assets/images/blog/2023-02-14-attacks/program2.png" />
</p>

<p>These capabilities give LLMs the ability to emulate complex computation (memory, assignment, branching, and individual operations, i.e., “opcodes”). We use these capabilities in our attacks.</p>

<h1 id="economic-analysis">Economic Analysis</h1>

<p>To better understand the economic feasibility of generating such malicious text, we estimated the cost of generating the text via human effort and via LLM APIs.</p>

<p>We first estimated the cost of human-generated text by comparing the cost of call center operators. In 2007, the lowest hourly wage of a call center employee is <a href="https://ecommons.cornell.edu/bitstream/handle/1813/74325/GCC_Intl_Rept_US_Version.pdf">around $1.24</a>. Adjusting for inflation gives an estimate of around $1.80. If we estimate that it takes 5–15 minutes to generate a personalized scam, we arrive at an estimate of $0.15 to $0.45 per email generation.</p>

<p>We then estimated the cost of generating text via ChatGPT. Surprisingly, ChatGPT is cheaper than even text-davinci-003, costing only $0.00064 per email! Using text-davinci-003 would cost $0.0064.</p>

<p>Although there is uncertainty in our estimates, ChatGPT is likely substantially cheaper than using human labor. This is even when our estimates exclude other expenses, including facilities, worker retraining, and management overheads! As hardware and software optimizations continue to advance, the costs of LLMs will likely drop.</p>

<h1 id="conclusions">Conclusions</h1>

<p>As we have shown, improvements in LLMs allow for convincing and economically feasible generations of malicious content (scams, spam, hate speech, etc.) <em>without</em> any additional training. This dual use is difficult to prevent as instruction-following LLMs become closer to standard programs: attack mechanisms against standard programs begin to apply to LLMs. We hope that our work spurs further work on viewing LLMs through the lens of traditional computer security, both for attacks and defenses.</p>

<p>See <a href="http://arxiv.org/abs/2302.05733">our paper</a> for full details!</p>

<p><em>Note: We updated our blog post with OpenAI’s new API costs.</em></p>]]></content><author><name>Daniel Kang, Xuechen Li, Ion Stoica, Carlos Guestrin, Matei Zaharia, Tatsunori Hashimoto</name></author><category term="Blog" /><summary type="html"><![CDATA[Large language models (LLMs) have become increasingly powerful in their capabilities: they can now pass the Bar, answer clinical questions, and write code. Their capabilities are driven by larger models but also new capabilities in instruction following, in which LLMs are trained to follow instructions. Instruction-tuned models outperform standard LLMs on a range of benchmarks. Unfortunately, as these LLMs increase in capabilities, the potential for their dual-use, or misuse, and the economic incentives for dual-use both increase.]]></summary></entry><entry><title type="html">zk-img: Fighting Deepfakes with Zero-Knowledge Proofs</title><link href="https://ddkang.github.io/blog/2022/11/13/zk/" rel="alternate" type="text/html" title="zk-img: Fighting Deepfakes with Zero-Knowledge Proofs" /><published>2022-11-13T00:00:00+00:00</published><updated>2022-11-13T00:00:00+00:00</updated><id>https://ddkang.github.io/blog/2022/11/13/zk</id><content type="html" xml:base="https://ddkang.github.io/blog/2022/11/13/zk/"><![CDATA[<p>Over the past few years, the use of <a href="https://www.businessinsider.com/guides/tech/what-is-deepfake">deepfakes</a> for malicious purposes has exploded. Deepfakes have been used to <a href="https://www.boston25news.com/news/local/better-business-bureau-warns-about-deepfake-elon-musk-investment-scam/S35FGICEKJADDC4SUHE7FEFJM4/">steal funds from unsuspecting investors</a> and even to <a href="https://www.bbc.com/news/technology-60780142">convince soldiers to surrender</a>. The rise of deepfakes has partially been driven by the rise of generative artificial intelligence (AI) methods, like <a href="https://stability.ai/blog/stable-diffusion-public-release">Stable Diffusion</a>. As these AI methods become more powerful, an important question emerges: how can we trust the validity of the images we see?</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2022-11-13-zk/deepfake.jpg" alt="Example of a deep fake" /></p>
<p align="center">
<a href="https://spectrum.ieee.org/facebook-ai-launches-its-deepfake-detection-challenge">Example</a> of a deepfake.
</p>

<p>There have been some steps towards verifying that an image was taken by a real camera. <a href="https://www.sony.eu/presscentre/news/sony-unlocks-in-camera-forgery-proof-technology">Attested cameras</a> can prove that an image was taken by a particular sensor by using digital signatures. However, the majority of photos released on the internet are edited to remove sensitive information and to improve legibility of the images. These edits are not attested by the camera and must be verified some other way. Recent work has proposed verifying these image edits using zero-knowledge proofs, in particular <a href="https://z.cash/technology/zksnarks/">ZK-SNARKs</a> (zero-knowledge succinct non-interactive argument of knowledge). ZK-SNARKs can prove that the edits on the image were legitimate.</p>

<p>Unfortunately, <a href="https://ieeexplore.ieee.org/document/7546506">this</a> <a href="https://eprint.iacr.org/2020/1579">work</a> <a href="https://medium.com/@boneh/using-zk-proofs-to-fight-disinformation-17e7d57fe52f">on</a> ZK-SNARKs for images has several drawbacks. First, <em>they require revealing the original or intermediate images.<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup><sup id="fnref:2" role="doc-noteref"><a href="#fn:2" class="footnote" rel="footnote">2</a></sup></em> This breaks the privacy of the original image and can potentially leak sensitive information! Second, they are impractical, operating on images smaller than 128x128.<sup id="fnref:1:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup><sup id="fnref:2:1" role="doc-noteref"><a href="#fn:2" class="footnote" rel="footnote">2</a></sup> Third, they require custom cryptographic arguments<sup id="fnref:1:2" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup><sup id="fnref:3" role="doc-noteref"><a href="#fn:3" class="footnote" rel="footnote">3</a></sup> or trusted third parties.<sup id="fnref:3:1" role="doc-noteref"><a href="#fn:3" class="footnote" rel="footnote">3</a></sup></p>

<p>To address these issues, we have built <a href="http://arxiv.org/abs/2211.04775">zk-img</a>, which allows image edits to be verified with no <em>assumptions on trust while keeping the original/intermediate images private</em>. zk-img is also efficient; it is the first library that can privately and securely verify arbitrary transformations on  <strong>HD images</strong>.</p>

<p>In this blog post, we’ll briefly describe the internals and illustrate the usage of zk-img. For further details, please read our <a href="http://arxiv.org/abs/2211.04775">paper</a>.</p>

<h1 id="using-zk-img">Using zk-img</h1>

<p>Before we describe zk-img, we’ll first describe why zk-img is needed.</p>

<h2 id="hiding-the-original-image">Hiding the original image</h2>
<p>In most cases, the original image must be hidden. The original image may contain sensitive or embarrassing information, which should be edited. For example, the piglet below is carrying sensitive information in its mouth:</p>

<p align="center">
<img src="https://ddkang.github.io/assets/images/blog/2022-11-13-zk/piglet.png" />
<br />
How can we keep the card hidden? (image from <a href="https://thesmartlocal.jp/pig-balancing-on-ball-japan/">here</a>.)
</p>

<p>How can we keep the original image hidden while simultaneously allowing an image consumer to verify that the transformations were done honestly?</p>

<p>zk-img accomplishes this by computing the hash of the original image and the transformations themselves inside the ZK-SNARK. It only reveals the original image’s hash and the output image. Since ZK-SNARKs allow a verifier to be convinced the computation was done correctly, the image consumer can verify that the hash was computed correctly as well as transformations. We illustrate the process below:</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2022-11-13-zk/system.png" alt="" /></p>

<p>Here, H1 and H2 are the hashes of the original image and intermediate image (after cropping and resizing). Since only the hash of the intermediate image is released, privacy is preserved.</p>

<h2 id="hiding-the-original-and-output-image">Hiding the original and output image</h2>
<p>In some cases, both the original and output image must be hidden. For example, the image producer might want to attest that they took an image before some point in time and release the hashes before releasing the output image. A biometric identification system may wish to hide the original and edited image, but still be able to prove that the images came from an attested source.</p>

<p>zk-img accomplishes this by computing the hashes of the original and transformed images. It only reveals the hashes, and not the images.</p>

<h1 id="how-zk-img-works">How zk-img works</h1>
<p>Now that we’ve described how to use zk-img in a variety of scenarios, we’ll describe how zk-img works internally.</p>

<p>From an application developer perspective, zk-img takes as input an image from an attested camera, a sequence of image transformations, and whether or not the final image should be revealed. Given these inputs, zk-img produces a ZK-SNARK of the transformation.</p>

<p>We’ve built zk-img leveraging the recent developments in proving systems, which have dramatically improved in efficiency and usability. In particular, we built zk-img using the <a href="https://github.com/zcash/halo2">halo2</a> library. Internally, zk-img has a standardized interface for image transformations so they can be composed. This interface allows the addition of image transformations beyond what is currently implemented in zk-img.</p>

<p>The standardized interface for zk-img is critical as it allows a registry of valid transformations that users can trust. We have currently implemented the following transformations:</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2022-11-13-zk/transforms.png" alt="" /></p>

<p>Developers can add other implementations to zk-img’s registry!</p>

<p>In order to implement these transformations efficiently, we leverage features from the Plonkish arithmetization, which halo2 is based on. See our <a href="http://arxiv.org/abs/2211.04775">paper</a> for details.</p>

<h1 id="benchmarks">Benchmarks</h1>

<p>We benchmarked zk-img for image transformations on HD images, which is over 50x the size of previous work in this space. We first benchmarked zk-img on input-privacy preserving transformations:</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2022-11-13-zk/bench1.png" alt="" /></p>

<p>Although the proof times are high, the verification times are as low as 4.59 ms! The verification costs are low enough to perform them on device.</p>

<p>The costs increase when keeping the output image hidden as well:</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2022-11-13-zk/bench2.png" alt="" /></p>

<p>However, the verification times still remain small, taking at most 9.32 ms.</p>

<p>In our <a href="http://arxiv.org/abs/2211.04775">paper</a>, we show that zk-img is orders of magnitude faster than prior work, up to <strong>112x</strong> faster for proving and <strong>94x</strong> faster for verifying.</p>

<h1 id="conclusion">Conclusion</h1>
<p>The world is becoming increasingly connected and information is spreading faster than ever. Just this year, images from the front line in the Ukraine conflict spread rapidly over social media. Mixed in with real information, there were malicious images.</p>

<p>Imagine if every image on the internet was attested. Social media platforms could indicate which images were attested and which ones were not. Furthermore, anyone could see and verify <em>on their own computer</em> if an image came from a real camera!</p>

<p>As a first step towards this vision, we’ve built zk-img. zk-img can securely and privately attest to image transformations while keeping the original image hidden. By optimizing these transformations, zk-img can be orders of magnitude faster than prior work. For more details, see our <a href="http://arxiv.org/abs/2211.04775">paper</a> and look out for our code release soon!</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1" role="doc-endnote">
      <p>https://ieeexplore.ieee.org/document/7546506 <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a> <a href="#fnref:1:1" class="reversefootnote" role="doc-backlink">&#8617;<sup>2</sup></a> <a href="#fnref:1:2" class="reversefootnote" role="doc-backlink">&#8617;<sup>3</sup></a></p>
    </li>
    <li id="fn:2" role="doc-endnote">
      <p>https://medium.com/@boneh/using-zk-proofs-to-fight-disinformation-17e7d57fe52f <a href="#fnref:2" class="reversefootnote" role="doc-backlink">&#8617;</a> <a href="#fnref:2:1" class="reversefootnote" role="doc-backlink">&#8617;<sup>2</sup></a></p>
    </li>
    <li id="fn:3" role="doc-endnote">
      <p>https://eprint.iacr.org/2020/1579 <a href="#fnref:3" class="reversefootnote" role="doc-backlink">&#8617;</a> <a href="#fnref:3:1" class="reversefootnote" role="doc-backlink">&#8617;<sup>2</sup></a></p>
    </li>
  </ol>
</div>]]></content><author><name>Daniel Kang, Tatsunori Hashimoto, Ion Stoica, Yi Sun</name></author><category term="Blog" /><summary type="html"><![CDATA[Over the past few years, the use of deepfakes for malicious purposes has exploded. Deepfakes have been used to steal funds from unsuspecting investors and even to convince soldiers to surrender. The rise of deepfakes has partially been driven by the rise of generative artificial intelligence (AI) methods, like Stable Diffusion. As these AI methods become more powerful, an important question emerges: how can we trust the validity of the images we see?]]></summary></entry><entry><title type="html">Trustless Verification of Machine Learning</title><link href="https://ddkang.github.io/blog/2022/10/18/trustless/" rel="alternate" type="text/html" title="Trustless Verification of Machine Learning" /><published>2022-10-18T00:00:00+00:00</published><updated>2022-10-18T00:00:00+00:00</updated><id>https://ddkang.github.io/blog/2022/10/18/trustless</id><content type="html" xml:base="https://ddkang.github.io/blog/2022/10/18/trustless/"><![CDATA[<p>Machine learning (ML) deployments are becoming increasingly complex as ML increases in its scope and accuracy. Many organizations are now turning to “ML-as-a-service” (MLaaS) providers (e.g., Amazon, Google, Microsoft, etc.) to execute complex, proprietary ML models. As these services proliferate, they become increasingly difficult to understand and audit. Thus, a critical question emerges: how can consumers of these services trust that the service has correctly served the predictions?</p>

<p><img src="https://ddkang.github.io/assets/images/blog/2022-10-18-trustless/fig1.png" alt="How can the model consumer verify the inference?" /></p>

<p>To address these concerns, we have developed the first system to trustlessly verify ML model predictions for production-level models. In order to do so, we use a cryptographic technology called <a href="https://z.cash/technology/zksnarks/">ZK-SNARKs</a> (zero-knowledge succinct non-interactive argument of knowledge), which allow a <em>prover</em> to prove the result of a computation without revealing any information about the inputs or intermediate steps of the computation. ZK-SNARKs allow an MLaaS provider to prove that the model was executed correctly <em>post-hoc</em>, so model consumers can verify predictions as they wish. Unfortunately, existing work on ZK-SNARKs can require up to two days of computation to verify a single ML model prediction.</p>

<p>In order to address this computational overhead, we have created the first ZK-SNARK circuit of a model on ImageNet (MobileNet v2) achieving <strong>79% accuracy</strong> while being verifiable in <strong>10 seconds</strong> on commodity hardware. We further construct protocols to use these ZK-SNARKs to verify ML model accuracy, ML model predictions, and trustlessly retrieve documents in cost-efficient ways.</p>

<p>In this blog post, we’ll describe our protocols and how we constructed the ZK-SNARK circuit in more detail. Further details are also in our <a href="https://arxiv.org/abs/2210.08674">preprint</a>.</p>

<h1 id="using-zk-snarks-for-trustless-applications">Using ZK-SNARKs for trustless applications</h1>

<p>Building on our efficient ZK-SNARKs, we also show that it’s possible to use these ZK-SNARKs for a variety of applications. We show how to use ZK-SNARKS to verify ML model accuracy. In addition, we also show that ZK-SNARKs of ML models can be used to trustlessly retrieve images (or documents) matching an ML model classifier. Importantly, these protocols can be verified by third-parties, so can be used for resolving disputes.</p>

<p>First, consider the setting where a model provider (MP) has a model they wish to serve to a model consumer (MC). The MC wants to verify the model accuracy to ensure that the MP is not malicious, lazy, and or erroneous (i.e., has bugs in the serving code). To verify model accuracy, the model provider (MP) will commit to a model by hashing its weights. The model consumer (MC) will then send a test set to the MP, on which the MP will provide outputs and ZK-SNARK proofs of correct execution. By verifying ZK-SNARKs on the test set, MC can be confident that MP has executed the model correctly. After the model accuracy is verified, MC can purchase the model or use the MP as an MLaaS provider. In order to ensure that both parties are honest, we design a set of economic incentives, with details in our <a href="https://arxiv.org/abs/2210.08674">preprint</a>.</p>

<p>We instantiated our protocol with our ZK-SNARKs. To verify accuracy of an ML model within 5% costs $99.93. For context, collecting an expert-annotated dataset can cost as much $85,000. Our protocol adds as little as 0.1% overhead in this scenario.</p>

<p>Second, consider the setting where a judge has ordered a legal subpoena. This may occur when a plaintiff requests documents for legal discovery or when a journalist requests documents under the Freedom of Information Act (FOIA). When the judge approves the subpoena, the responder must divulge documents or images matching the request, which can be specified by an ML model. In order to keep the remainder of the documents private, the requester can only divulge the specific documents as follows. The responder commits to the dataset by producing hashes of the documents, the requester subsequently sends the model to the responder, and finally the responder produces ZK-SNARK proofs of valid inference on the documents. The responder will send only the documents that match the ML model classifier.</p>

<h1 id="constructing-the-first-imagenet-scale-zk-snark">Constructing the first ImageNet-scale ZK-SNARK</h1>

<p>As we mentioned, ZK-SNARKs allow a prover to prove the result of a computation without revealing any information about the inputs or intermediate steps of the computation. ZK-SNARKs have several non-intuitive properties that make them amenable for verifying ML models:</p>
<ol>
  <li>They have succinct proofs, which can be as few as 100 bytes (for non-ML applications) and as few as 6 kB for the ML models we consider.</li>
  <li>They are non-interactive, so the proof can be verified by anyone at any point in time.</li>
  <li>A prover cannot generate invalid proofs (knowledge soundness) and correct proofs will verify (completeness).</li>
  <li>They are zero-knowledge: the proof doesn’t reveal anything about the inputs (the model weights or model inputs in our setting) beyond the information already contained in the outputs.
Constructing most ZK-SNARKs involves two steps: arithmetization (turning the computation into an arithmetic circuit, i.e., a system of polynomial equations over a large prime field) and using a cryptographic proof system to generate the ZK-SNARK proof.</li>
</ol>

<p>To construct ZK-SNARKs for ML models that work at ImageNet-scale, we use recent developments in proving systems, which have dramatically improved in efficiency and usability in the past few years. We specifically use the <a href="https://github.com/zcash/halo2">halo2</a> library. Prior work for DNN ZK-SNARKs uses the Groth16 proving system or sum-check based systems specific to neural networks. Groth16 is less amenable for DNN inference due to the non-linearities as they cannot easily be represented with quadratic constraints. Furthermore, neural network-specific proving systems do not benefit from the broader ZK proving ecosystem. They currently have worse performance than our solution of leveraging the advances in the ZK ecosystem.</p>

<p>Scaling out ZK-SNARKs in halo2 still requires several advances in efficient arithmetization. We design new methods of arithmetizating quantized DNNs, performing non-linearities efficiently via lookup arguments, and efficiently packing the circuits. Please see our <a href="https://arxiv.org/abs/2210.08674">preprint</a> for more details!</p>

<p>We constructed ZK-SNARKs of MobileNet v2 on ImageNet. By varying the complexity of the models, we can trade off accuracy against verification time. We constructed ZK-SNARK proofs for inference for a variety of models and show the empirical tradeoff of accuracy and verification time in the plot below:
<img src="https://ddkang.github.io/assets/images/blog/2022-10-18-trustless/acc_time.png" alt="Accuracy vs verification time for our ZK-SNARK proofs of ImageNet-scale models" /></p>

<p>As we can see, our models can achieve an accuracy of 79% while taking only 10s to verify on commodity hardware!</p>

<h1 id="conclusion">Conclusion</h1>

<p>In our recent paper, we’ve scaled ZK-SNARKs on ML models that achieve high accuracy on ImageNet. Our ZK-SNARKs constructions can achieve 79% accuracy while being verifiable within 10s. We’ve also described protocols for using these ZK-SNARKs to verify ML model accuracy and trustlessly retrieve documents. Please see our <a href="https://arxiv.org/abs/2210.08674">preprint</a> for more information. Also be on the lookout for our open-source release!</p>]]></content><author><name>Daniel Kang, Tatsunori Hashimoto, Ion Stoica, Yi Sun</name></author><category term="Blog" /><summary type="html"><![CDATA[Machine learning (ML) deployments are becoming increasingly complex as ML increases in its scope and accuracy. Many organizations are now turning to “ML-as-a-service” (MLaaS) providers (e.g., Amazon, Google, Microsoft, etc.) to execute complex, proprietary ML models. As these services proliferate, they become increasingly difficult to understand and audit. Thus, a critical question emerges: how can consumers of these services trust that the service has correctly served the predictions?]]></summary></entry><entry><title type="html">Installing CUDA 10.2, CuDNN 7.6.5, TensorRT 7.0 on AWS, Ubuntu 18.04</title><link href="https://ddkang.github.io/blog/2020/01/02/installing-tensorrt/" rel="alternate" type="text/html" title="Installing CUDA 10.2, CuDNN 7.6.5, TensorRT 7.0 on AWS, Ubuntu 18.04" /><published>2020-01-02T00:00:00+00:00</published><updated>2020-01-02T00:00:00+00:00</updated><id>https://ddkang.github.io/blog/2020/01/02/installing-tensorrt</id><content type="html" xml:base="https://ddkang.github.io/blog/2020/01/02/installing-tensorrt/"><![CDATA[<p>How to install CUDA 10.2, CuDNN 7.6.5, TensorRT 7.0 in the AWS T4 instance.</p>

<h3 id="step-0-aws-setup-1-minute">Step 0: AWS setup (~1 minute)</h3>

<p>Create a <code class="language-plaintext highlighter-rouge">g4dn.xlarge</code> AWS instance. Attach at least 30 GB of HDD space with Ubuntu 18.04.</p>

<h3 id="step-1-installing-cuda-55-minutes">Step 1: Installing CUDA (~5.5 minutes)</h3>

<p>You can also install CUDA directly from the offline installer, but this is a little easier.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt update
sudo apt upgrade -y

mkdir install ; cd install
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda-10-2
</code></pre></div></div>

<h3 id="step-2-installing-cudnn-2-minutes">Step 2: Installing CuDNN (~2 minutes)</h3>

<ol>
  <li>Download CuDNN <a href="https://developer.nvidia.com/rdp/cudnn-download">here</a> (BOTH the runtime and dev, deb). Use version 7.6.5.</li>
  <li>scp the deb files to AWS
3.
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.2_amd64.deb
sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.2_amd64.deb
</code></pre></div>    </div>
  </li>
</ol>

<h3 id="step-3-installing-tensorrt-2-minutes">Step 3: Installing TensorRT (~2 minutes)</h3>

<ol>
  <li>Download TensorRT <a href="https://developer.nvidia.com/nvidia-tensorrt-7x-download">here</a>. Use version
7.0.</li>
  <li>scp the deb files to AWS.
3.
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo dpkg -i nv-tensorrt-repo-ubuntu1804-cuda10.2-trt7.0.0.11-ga-20191216_1-1_amd64.deb
sudo apt update
sudo apt install tensorrt libnvinfer7
</code></pre></div>    </div>
  </li>
</ol>

<h3 id="step-35-add-to-bashrc">Step 3.5: Add to .bashrc</h3>

<p>I don’t actually know if this step is required, but it might be helpful for other things.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>export CUDA_HOME=/usr/local/cuda
export DYLD_LIBRARY_PATH=$CUDA_HOME/lib64:$DYLD_LIBRARY_PATH
export PATH=$CUDA_HOME/bin:$PATH
export C_INCLUDE_PATH=$CUDA_HOME/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$CUDA_HOME/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
export LD_RUN_PATH=$CUDA_HOME/lib64:$LD_RUN_PATH
</code></pre></div></div>]]></content><author><name>Daniel Kang</name></author><category term="Blog" /><summary type="html"><![CDATA[How to install CUDA 10.2, CuDNN 7.6.5, TensorRT 7.0 in the AWS T4 instance.]]></summary></entry><entry><title type="html">Installing CUDA 10.1, CuDNN 7.6.3, TensorRT 5.0.1 on AWS, Ubuntu 18.04</title><link href="https://ddkang.github.io/blog/2019/09/19/installing-tensorrt/" rel="alternate" type="text/html" title="Installing CUDA 10.1, CuDNN 7.6.3, TensorRT 5.0.1 on AWS, Ubuntu 18.04" /><published>2019-09-19T00:00:00+00:00</published><updated>2019-09-19T00:00:00+00:00</updated><id>https://ddkang.github.io/blog/2019/09/19/installing-tensorrt</id><content type="html" xml:base="https://ddkang.github.io/blog/2019/09/19/installing-tensorrt/"><![CDATA[<p>How to install CUDA 9.2, CuDNN 7.2.1, PyTorch nightly on Google Compute Engine. I expect this to be
outdated when PyTorch 1.0 is released (built with CUDA 10.0).</p>

<p>This uses Conda, but pip should ideally be as easy.</p>

<h3 id="step-0-gcp-setup-1-minute">Step 0: GCP setup (~1 minute)</h3>

<p>Create a GCP instance with 8 CPUs, 1 P100, 30 GB of HDD space with Ubuntu 16.04. Turn off host
migration (GPU jobs can’t be resumed).</p>

<h3 id="step-1-installing-cuda-55-minutes">Step 1: Installing CUDA (~5.5 minutes)</h3>

<p>You can also install CUDA directly from the offline installer, but this is a little easier.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt update
sudo apt upgrade -y

mkdir install ; cd install
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda-10-1
</code></pre></div></div>

<h3 id="step-2-installing-cudnn-2-minutes">Step 2: Installing CuDNN (~2 minutes)</h3>

<ol>
  <li>Download CuDNN <a href="https://developer.nvidia.com/rdp/cudnn-download">here</a> (BOTH the runtime and dev, deb). Use version 7.6.3.</li>
  <li>scp the deb files to GCP
3.
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo dpkg -i libcudnn7_7.6.3.30-1+cuda10.1_amd64.deb
sudo dpkg -i libcudnn7-dev_7.6.3.30-1+cuda10.1_amd64.deb
</code></pre></div>    </div>
  </li>
</ol>

<h3 id="step-3-installing-tensorrt-2-minutes">Step 3: Installing TensorRT (~2 minutes)</h3>

<ol>
  <li>Download TensorRT <a href="https://developer.nvidia.com/nvidia-tensorrt-6x-download">here</a>. Use version
6.0.1.</li>
  <li>scp the deb files to AWS.
3.
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo dpkg -i nv-tensorrt-repo-ubuntu1804-cuda10.1-trt6.0.1.5-ga-20190913_1-1_amd64.deb
sudo apt update
sudo apt install tensorrt libnvinfer6
</code></pre></div>    </div>
  </li>
</ol>

<h3 id="step-35-add-to-bashrc">Step 3.5: Add to .bashrc</h3>

<p>I don’t actually know if this step is required, but it might be helpful for other things.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>export CUDA_HOME=/usr/local/cuda
export DYLD_LIBRARY_PATH=$CUDA_HOME/lib64:$DYLD_LIBRARY_PATH
export PATH=$CUDA_HOME/bin:$PATH
export C_INCLUDE_PATH=$CUDA_HOME/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$CUDA_HOME/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
export LD_RUN_PATH=$CUDA_HOME/lib64:$LD_RUN_PATH
</code></pre></div></div>]]></content><author><name>Daniel Kang</name></author><category term="Blog" /><summary type="html"><![CDATA[How to install CUDA 9.2, CuDNN 7.2.1, PyTorch nightly on Google Compute Engine. I expect this to be outdated when PyTorch 1.0 is released (built with CUDA 10.0).]]></summary></entry></feed>