{"tags":["bulletproofs","privacy","cryptography","zero-knowledge-proofs"],"id":"40506709dca64369b4a133a2c91c27ae_2","article_id":"40506709dca64369b4a133a2c91c27ae","article_version":2,"title":"Building on Bulletproofs - Short Proofs for Confidential Transactions","content":"{\"markdown\":\"This article was original published by [Cathie Yun](https://medium.com/@cathieyun) on [Medium](https://medium.com/@cathieyun/building-on-bulletproofs-2faa58af0ba8) special thanks to Cathie for allowing us to import to Kauri\\n\\n## Preface\\nIn this post, I will explain how the Bulletproofs zero knowledge proof protocol works, as well as talk about the confidential asset protocol and confidential smart contract language we are building using Bulletproofs.\\nThis post is a condensed version of previous \\n[talks and blog posts](https://interstellar.com/protocol)\\n and our \\n[Bulletproofs library documentation](https://doc.dalek.rs/bulletproofs/index.html)\\n . It has also been featured in the MIT \\n[Digital Currency Review](https://mitcryptocurrencyresearch.substack.com/p/mit-dcis-cryptocurrency-research-350)\\n .\\n\\n## Background\\nZero-knowledge range proofs are a key building block for confidential transaction systems, such as Confidential Transactions for Bitcoin, Chain’s Confidential Assets, and many other protocols. Range proofs allow a verifier to ensure that secret values, such as asset amounts, are nonnegative. This prevents a user from forging value by secretly using a negative amount. Since every transaction involves one or more range proofs, their efficiency, both in terms of proof size and verification time, is key to transaction performance.\\nIn 2017, Bünz, Bootle, Boneh, Poelstra, Wuille, and Maxwell published \\n[Bulletproofs](https://crypto.stanford.edu/bulletproofs/)\\n , which dramatically improves proof performance both in terms of proof size and verification time. In addition, it allows for proving a much wider class of statements than just range proofs.\\n\\n## Definitions\\nCommitment — a commitment \\n`Com(m)`\\n to message \\n`m`\\n is hiding, which means it does not reveal \\n`m`\\n . It is also binding, which means that if you make a commitment to \\n`m`\\n , you cannot open it to a different message \\n`m’`\\n . In the context of Bulletproofs, commitment refers to a Pedersen commitment, which has the additional property of being additively homomorphic, which means that \\n`Com(a) + Com(b) = Com(c)`\\n only if \\n`a + b = c`\\n .\\nZero-knowledge proof — a proof that a certain statement is true, without revealing the secret that the statement is about. This is usually done by making a commitment to the secret that the statement is about, and sharing the commitment along with the proof.\\nZero-knowledge range proof — a proof that a secret value is in a certain range (from \\n`0`\\n to \\n`2^n — 1`\\n ). The proof is usually shared with a commitment to the secret value so that it can be verified.\\nInner product — the sum of an entry-wise multiplication of two vectors.\\nNotation: vectors are written in bold, such as \\n`a`\\n , \\n`2^n`\\n (which is an \\n`n`\\n length vector \\n`2^0, 2^1, ... , 2^{n-1}`\\n ), and \\n`0^n`\\n (which is an \\n`n`\\n length vector of \\n`0`\\n s). Inner products are written as \\n`c = `\\n , where \\n`a`\\n and \\n`b`\\n are vectors of the same length, and \\n`c`\\n is a scalar.\\n\\n## Range Proof\\n\\n![](https://api.kauri.io:443/ipfs/QmY2aD3SW4GP4tj9Cyiokpbu5U266eVCuK9Swk68gGgFi9)\\n\\nWe’d like to make a proof of the following statement: \\n`0 ≤ v < 2^n`\\n \\nWe know that if this is true, then \\n`v`\\n must be a binary number of length \\n`n`\\n . For example, if \\n`n=4`\\n and \\n`v=3`\\n (we’re checking if \\n`3`\\n is in range of \\n`0`\\n to \\n`2^4 — 1`\\n ), then this means that v must be able to be broken up into a bit representation that is \\n`4`\\n bits long, if it is actually in range:\\n\\n![](https://api.kauri.io:443/ipfs/QmZSBFVC4DUkdGv9Eb8e1kP3SB9NuRgc6NBZQKMSXh5KqT)\\n\\nWe would like to represent this claim in the form of an inner product because of the extremely efficient inner product proof that Bulletproof introduces, which we will talk about in the next section.\\nFirst, let’s name the bit representation of \\n`v`\\n : \\n`v_bits`\\n .\\n\\n![](https://api.kauri.io:443/ipfs/QmV7kWunAYa8BP1ox36ULbMyqVXEdb9KsMwd4Ppk39ibbp)\\n\\n \\n`v`\\n should be equal to the inner product of \\n`v_bits`\\n and the vector \\n`2^n`\\n (which is an \\n`n`\\n length vector \\n`2^0, 2^1, ... , 2^{n-1}`\\n ) if \\n`v_bits`\\n is actually the bit representation of \\n`v`\\n . We can do that by adding check 1 in the figure below.\\nAlso, we need to make sure that \\n`v_bits`\\n is actually composed only of bits (no other pesky numbers, like \\n`5`\\n or \\n`-1000`\\n … that would be bad!) We can do that by adding check 2 in the figure below.\\n\\n![](https://api.kauri.io:443/ipfs/QmWEuTnjF6wkfCyYH79fs6VQ7NEDNKBQX4DjLzbVt4cQXX)\\n\\nNext, we combine these two statements using challenge scalars, and add blinding factors to them. The math behind this is not difficult — just tedious — and ends up giving us an inner product statement in the form of \\n`c = `\\n . That is, we arrive at a statement where if the statement is true, then we know that \\n`v`\\n is in range of \\n`0`\\n and \\n`2^n`\\n . You can follow along with the step-by-step math for how that statement is created in our \\n[range proof notes](https://doc-internal.dalek.rs/bulletproofs/notes/index.html#range-proofs-from-inner-products)\\n .\\n\\n## Inner Product Proof\\nIn the range proof section, I mentioned that our goal was to create a statement in the form of an inner product, for efficiency reasons. Let’s go into more detail on what an inner product is, and how we can prove an inner product efficiently!\\nAn inner product proof is a proof that \\n`c`\\n is the inner product of vectors \\n`a`\\n and \\n`b`\\n . That is, \\n`c = `\\n .\\nThis may be a helpful visual for what an inner product is:\\n\\n![](https://api.kauri.io:443/ipfs/Qmf2J3gk51gm4HrhUu4JAoPnczXGuNVLGL1DJD5aQaYumK)\\n\\nNaively, a prover could prove this to the verifier by sending over \\n`a`\\n and \\n`b`\\n and \\n`c`\\n , and then the verifier could verify that \\n`c = `\\n by computing it themself. However, this would take \\n`O(n)`\\n space to send, and \\n`O(n)`\\n time to verify, where \\n`n`\\n is the length of \\n`a`\\n and \\n`b`\\n . The great thing about the bulletproofs inner product proof is that it allows us to do this proof in \\n`O(log(n))`\\n time and space instead!\\nThe intuition for how the inner product proof is achieves this efficiency, is that in each step it halves the size of the \\n`a`\\n and \\n`b`\\n vectors it is working with. Therefore, it requires \\n`log(n)`\\n steps since after that many steps, the lengths of \\n`a`\\n and \\n`b`\\n are \\n`1`\\n (the base case).\\nSo if we started with the original \\n`a`\\n and \\n`b`\\n vectors, and their product \\n`c`\\n , then we can divide each of the vectors into a \\n`hi`\\n and \\n`lo`\\n half:\\n\\n![](https://api.kauri.io:443/ipfs/QmdbiBHZ1Fgp6f82A3xqspvFPFU7SqRH514DDr6BgYhs2k)\\n\\nAnd then, we get a random challenge scalar \\n`x`\\n that we use to combine the \\n`hi`\\n and \\n`lo`\\n halves of \\n`a`\\n and \\n`b`\\n to create \\n`a’`\\n and \\n`b’`\\n , which also gives us a new \\n`c’ = `\\n .\\n\\n![](https://api.kauri.io:443/ipfs/QmVMtrjNthPCfuQWGv6HbLRBEim79DRmH7DUYr5QMmU8q1)\\n\\nWhen doing the math to expand \\n`c’`\\n , notice that the first two terms of \\n`c’`\\n are the same as \\n`c`\\n ! Therefore, we can simplify the expression for \\n`c’`\\n to be written in relation to \\n`c`\\n , and what we can call terms \\n`L`\\n and \\n`R`\\n :\\n\\n![](https://api.kauri.io:443/ipfs/QmarBi4vZbwTHj3mAKF85mthDQJGkT88uM8NpFkeAGr3ij)\\n\\nIn each round, the prover sends \\n`L`\\n and \\n`R`\\n to the verifier, and repeats the next round using the \\n`a’, b’, c’`\\n as \\n`a, b, c`\\n . Notice how at each step, this halves the lengths of the vectors \\n`a`\\n and \\n`b`\\n !\\nAfter \\n`log(n)`\\n steps, we arrive at the base case, where \\n`a’`\\n and \\n`b’`\\n are both of length \\n`1`\\n . Then, there is no more compression to be done, and the prover can simply send \\n`a’, b’, c’`\\n to the verifier.\\n\\n![](https://api.kauri.io:443/ipfs/QmZfd7TyKc82MAjTfBA3LQfoKDNWocumKMHbzjLszkkpd8)\\n\\nThe verifier now has scalars \\n`a’, b’, c’`\\n from the base case, and scalars \\n`L`\\n and \\n`R`\\n from each of the \\n`log(n)`\\n steps. The verifier can then reverse the process, starting at the base case. They can trivially verify the base case by checking that \\n`c’ = a’ * b’`\\n . They can check that the computation is done correctly at each higher step by verifying the calculation of \\n`c`\\n by using the \\n`c’, L, R`\\n from that step, until they have completed all checks.\\nTo see the full math behind the inner product proof, read our \\n[inner product proof notes](https://doc-internal.dalek.rs/bulletproofs/notes/inner_product_proof/index.html)\\n . To see the prover and verifier’s algorithms, read our \\n[inner product proof protocol notes](https://doc-internal.dalek.rs/bulletproofs/inner_product_proof/index.html)\\n .\\n\\n## Aggregated Range Proof\\nAggregated range proofs are great for performance, because they allow \\n`m`\\n parties to produce an aggregated proof of their individual statements ( \\n`m`\\n range proofs), such that the aggregated proof is smaller and faster to verify than \\n`m`\\n individual range proofs. The protocol for creating aggregated proofs is slightly more complex than creating individual range proofs, and requires a multi-party computation involving the parties. In our implementation, we used a centralized dealer to coordinate the communication between the \\n`m`\\n participating parties.\\nTo see the math behind the aggregated proof, see our \\n[aggregated range proof notes](https://doc-internal.dalek.rs/bulletproofs/notes/index.html#aggregated-range-proof)\\n . To see the prover and verifier’s algorithms, read our \\n[range proof protocol notes](https://doc-internal.dalek.rs/bulletproofs/range_proof/index.html)\\n . Also of potential interest is our \\n[notes on the aggregation multi-party computation protocol](https://doc-internal.dalek.rs/bulletproofs/aggregation/index.html)\\n and corresponding \\n[blog post](https://blog.chain.com/bulletproof-multi-party-computation-in-rust-with-session-types-b3da6e928d5d)\\n .\\n\\n## Constraint System Proof\\nA constraint system is a collection of two kinds of constraints:\\n\\n![](https://api.kauri.io:443/ipfs/QmYPXwC8Yp2kTdQx6zytZxCD1K7zvEc7hhDx2TZtTvM118)\\n\\nConstraint systems are very powerful because they can represent any efficiently verifiable program. A zero knowledge constraint system proof is a proof that all of the constraints in a constraint system are satisfied by certain secret inputs, without revealing what those secret inputs are.\\nFor example, we can make a set of constraints (a “gadget”) that enforces that some outputs are a valid permutation of some inputs. Let’s call this a shuffle gadgets. In a simple shuffle gadget with only two inputs and two outputs, we could represent the possible states as the following:\\n\\n![](https://api.kauri.io:443/ipfs/Qma7fA1LsWyG2kh53X32rezYG436S5eq3NiEhaGMPwTibF)\\n\\nIf we get a random scalar \\n`x`\\n , then we can actually express this requirement in the form of an equation: \\n`(A — x) * (B — x) = (C — x) * (D — x)`\\n . Because of the equality of polynomials when roots are permuted, we know that if the equation holds for a random \\n`x`\\n , then \\n`{A, B}`\\n must equal \\n`{C, D}`\\n in any order.\\nWhen we implement this 2-shuffle gadget in our constraint system, it looks like this:\\n\\n![](https://api.kauri.io:443/ipfs/QmW7VCxDfLYSwK9J4MLWyniEYQeVeQBrfGzU8QYqnmHGyB)\\n\\nIn line 6, we get our challenge scalar \\n`x`\\n .\\nIn line 8 and 10, we make two multiplication constraints: \\n`(A — x) * (B — x) = input_mul`\\n and \\n`(C — x) * (D — x) = output_mul`\\n .\\nIn line 12, we make one linear constraint: \\n`input_mul — output_mul = 0`\\n , which constrains \\n`input_mul = output_mul`\\n .\\nFor the full sample code of the 2-shuffle gadget, including tests, see our \\n[GitHub repo](https://github.com/interstellar/slingshot/tree/main/spacesuit)\\n . For an overview of how and why we implemented constraint system proofs, read our \\n[blog post here](https://medium.com/interstellar/programmable-constraint-systems-for-bulletproofs-365b9feb92f7)\\n . To see the math behind constraint system proofs, read our \\n[R1CS proof notes](https://doc-internal.dalek.rs/develop/bulletproofs/notes/r1cs_proof/index.html)\\n .\\n\\n## Cloak\\nThe goal of a Confidential Assets scheme is to make transactions in which the asset value and asset type are kept hidden, thereby allowing for multi-asset transactions in which external observers cannot deduce what is being transacted but can verify that the transactions are correct. Cloak is a Confidential Assets scheme built using Bulletproofs.\\nCloak is focused on one thing: proving that some number of values with different asset types is correctly transferred from inputs to outputs. Cloak ensures that values are balanced per asset type (so that one type is not transmuted to any other), that quantities do not overflow the group order (in other words, negative quantities are forbidden) and that both quantities and asset types are kept secret. Cloak does not specify how the transfers are authenticated or what kind of ledger represents those transfers: these are left to be defined in a protocol built around Cloak.\\nCloak builds a constraint system using a collection of gadgets like “shuffle”, “merge”, “split” and “range proof” all combined together under a single gadget called a “cloaked transaction”. The layout of all the gadgets is determined only by the number of inputs and outputs and not affected by actual values of the assets. This way, all transactions of the same size are indistinguishable. For example, this is what a 3 input 3 output cloak transaction looks like to a verifier or a viewer of the blockchain:\\n\\n![](https://api.kauri.io:443/ipfs/QmP8ZDWxkJdzZz85Xkp2wV1Tmkf5g8CXbcDsXYPPNtPCib)\\n\\nThis is what a 3 input 3 output cloak transaction would look like to a prover trying to make a proof of validity for a transaction with an input of $5, ¥3, $4 and an output of ¥3, $6, $3. Notice how the assets of the same type ($) are grouped, merged together, and then split and rearranged into the target amounts:\\n\\n![](https://api.kauri.io:443/ipfs/QmRs2sv8cRefVwVCyyqUTEKgJYMDtHy6xQZjaPYWjuBw2D)\\n\\nCloak turns out to be surprisingly efficient: compared to a single-asset transaction (such as the Confidential Transactions proposal for Bitcoin) where only range proofs are necessary, the additional constraints and gadgets needed to support the issued assets add less than 20% of the multipliers. And thanks to the inner product proof, the impact on the proof size is close to zero. This is an illustration of the number of multipliers required by each gadget in the Cloak protocol:\\n\\n![](https://api.kauri.io:443/ipfs/QmU7Vu6SWxCxye7Gbkv2sVhbAFBq5pxnsLpNQpFUoZm4QJ)\\n\\nTo learn more about Cloak, check out \\n[its specification](https://github.com/interstellar/spacesuit/blob/main/spec.md)\\n . To see the implementation, check out the open-source \\n[Cloak GitHub repo](https://github.com/interstellar/slingshot/tree/main/spacesuit)\\n .\\n\\n## ZkVM\\nThe goal of ZkVM is to make a smart contract language that allows for confidentiality. It builds upon previous smart contract language work, aiming for an expressive language that runs in a safe environment and outputs a deterministic log. It uses Cloak to validate that encrypted asset flows are correct, and uses Bulletproofs constraint system proofs to add constraints that values are being operated on and contracts are being executed correctly.\\nZkVM is still being developed, and you can follow along with progress in the open-source \\n[ZkVM GitHub repo](https://github.com/interstellar/slingshot/tree/main/zkvm)\\n .\\n\\n## Summary\\n\\n![](https://api.kauri.io:443/ipfs/QmWbfc3pPFfLCTwxEmJcLxVfe4oNrtwXtrgSs7FFPSjk3R)\\n\\nHopefully this post has helped you understand how the Bulletproofs zero knowledge proof protocol works, as well as what we’ve been building over that protocol. This just scratches the surface; I encourage you to read more in our notes and dive into our repo if you have more interest!\\n\\n## Acknowledgements\\nI worked with Henry de Valence and Oleg Andreev to understand and implement the Bulletproofs paper, as well as design and implement the Cloak protocol. The \\n[protocol research team](https://interstellar.com/protocol)\\n at Interstellar is currently designing and implementing ZkVM.\\nThanks to Benedikt Bünz for answering all our questions about the Bulletproofs paper! Also, thanks to Andrew Poelstra for his feedback on this writeup.\\n\"}","author":"9b66e2c73ee59c11ac25ef2730ab589c5416e81a","timestamp":1559717346247,"attributes":{"origin_name":"medium","origin_url":"https://medium.com/@cathieyun/building-on-bulletproofs-2faa58af0ba8","background":"https://api.kauri.io:443/ipfs/QmQ4nfToCaGt1qbEqhG66fEn6jicpycAdcg2orVsd4YMk7"}}