解釋SNARKs 第1部分:同態(tài)隱藏

原文出自:https://blog.z.cash/snark-explain/
作者:Ariel Gabizon
譯者:Matter實驗室

Constructions of zk-SNARKs involve a careful combination of several ingredients; fully understanding how these ingredients all work together can take a while.

zk-SNARKs 的結(jié)構(gòu)包含許多元素的精妙組合泞辐;完全了解這些元素需要花費一些時間裂允。

If I had to choose one ingredient whose role is most prominent, it would be what I will call here Homomorphic Hiding(HH) [1]. In this post we explain what an HH is, and then give an example of why it is useful and how it is constructed.

[1] Homomorphic hiding is not a term formally used in cryptography, and is introduced here for didactic purposes. It is similar to but weaker than the well-known notion of a computationally hiding commitment. The difference is that an HH is a deterministic function of the input, whereas a commitment uses additional randomness. As a consequence, HHs essentially ”hide most x’s” whereas commitments ”hide every x”.

如果你不得不選擇 一個最重要的元素沉颂,那么你可以把它稱為 同態(tài)隱藏 (HH) [1]。在這篇博文中,我們將解釋 HH 是什么,并解釋它為什么如此重要让蕾,同時闡述它的構(gòu)成涡戳。

  • [1] 同態(tài)隱藏并不是密碼學(xué)中常用的短語结蟋,在這里出于解釋說明的目的被引入。它與知名的短語“可計算的隱藏承諾”意思相近渔彰,但沒有這個短語語氣強烈嵌屎。它們的不同點在于,HH 是由輸入決定的函數(shù)恍涂,而承諾則使用了額外的隨機(jī)性宝惰。因此,HH 可以基本“隱藏絕大部分 x”再沧,而承諾則可以“隱藏每一個x”尼夺。

An HH E(x) of a number x is a function satisfying the following properties:

  • For most x’s, given E(x) it is hard to find x.
  • Different inputs lead to different outputs – so if x≠y, then E(x)≠E(y).
  • If someone knows E(x) and E(y), they can generate the HH of arithmetic expressions in x and y. For example, they can compute E(x+y) from E(x) and E(y).

具有HH屬性 E(x) 是一個關(guān)于 x 的函數(shù),它有如下特點:

  • 對于大部分的 x,給定某個 E(x) 通常很難求解出 x.
  • 不同輸入將會得到不同輸出 – 因此汞斧,如果 x≠y夜郁,則 E(x)≠E(y)
  • 如果某人知道了 E(x)E(y)粘勒,則他可以生成xy的算術(shù)表達(dá)式的 HH 函數(shù)竞端。比如,他們可以使用 E(x)E(y) 來計算 E(x+y)庙睡。

Here’s a toy example of why HH is useful for Zero-Knowledge proofs: Suppose Alice wants to prove to Bob she knows numbers x,y such that x+y=7 (Of course, it’s not too exciting knowing such x,y, but this is a good example to explain the concept with).

  1. Alice sends E(x) and E(y) to Bob.
  2. Bob computes E(x+y) from these values (which he is able to do since E is an HH).
  3. Bob also computes E(7), and now checks whether E(x+y)=E(7). He accepts Alice’s proof only if equality holds.

以下是關(guān)于為什么 HH 可以用于零知識證明的一個簡單的例子: 假設(shè) Alice 需要向 Bob 證明她知道數(shù)字 x,y 滿足 x+y=7 事富。(當(dāng)然,知道 x,y, 的具體數(shù)字并不會令人非常激動乘陪,但這是解釋這個概念非常簡潔的例子)统台。

  1. Alice 發(fā)送 E(x)E(y) 的值給 Bob。
  2. Bob 從得到的數(shù)值中計算出 E(x+y) 的值 (因為 E 是一個 HH)啡邑。
  3. Bob 同樣計算出了 E(7), 并檢查 E(x+y)=E(7)等式是否成立贱勃。只有等式成立,他才認(rèn)可Alice的證明谤逼。

As different inputs are mapped by E to different hidings, Bob indeed accepts the proof only if Alice sent hidings of x,y such that x+y=7. On the other hand, Bob does not learn x and y, as he just has access to their hidings [2].

[2] Bob does learn some information about x and y. For example, he can choose a random x’, and check whether x=x’ by computing E(x’). For this reason the above protocol is not really a Zero-Knowledge protocol, and is only used here for explanatory purposes. In fact, as we shall see in later posts, HH is ultimately used in snarks to conceal verifier challenges rather than prover secrets.

由于不同的輸入被 E 映射到了不同的匿數(shù)贵扰,Bob只有在Alice發(fā)送滿足x+y=7這個條件的 x,y 的匿數(shù)時才確切的認(rèn)可這個證明。 另一方面流部,Bob 并不知道 xy的值戚绕,因為他只獲得了他們的匿數(shù) [2]。

    • [2]Bob 確實可以獲取與 x 和 y 相關(guān)的一些信息枝冀。比如舞丛,他可以選擇一個隨機(jī)的 x',并通過計算 E(x') 的方式檢查 x=x' 等式是否成立果漾。出于這種原因球切,上面的協(xié)議并不是一個真正的零知識證明協(xié)議,它僅僅用于解釋跨晴。事實上欧聘,我們會在以后的文章中看到,HH 最終用在 snark 隱藏驗證者挑戰(zhàn)數(shù)時使用端盆,而不在隱藏證明者秘密時使用。

Now let’s see an example of how such hidings are constructed. We actually cannot construct them for regular integers with regular addition, but need to look at finite groups:

現(xiàn)在讓我們從一個例子中了解匿數(shù)是如何構(gòu)成的费封。事實上焕妙,我們不能使用常規(guī)的整數(shù)和常規(guī)的加法來構(gòu)造他們,因此弓摘,我們需要看看“有限群”:

Let n be some integer. When we write A mod n for an integer A, we mean taking the remainder of A after dividing by n. For example, 9 mod 7=2 and 13 mod 12=1. We can use the mod n operation to define an addition operation on the numbers {0,…,n?1}: We do regular addition but then apply (mod n) on the result to get back a number in the range {0,…,n?1}. We sometimes write (mod n) on the right to clarify we are using this type of addition. For example, 2+3=1(mod4). We call the set of elements {0,…,n?1} together with this addition operation the group Z(+,n).

假設(shè) n 是一個整數(shù)焚鹊。當(dāng)我們對整數(shù) A 寫下 A mod n 時,我們的意思是在 A 除以 n 后取余數(shù)韧献。比如 9 mod 7=213 mod 12=1末患。 我們可以使用 mod n 在正數(shù)集 {0,…,n?1} 上定義加法操作:我們在做常規(guī)加法后研叫,對結(jié)果應(yīng)用(mod n)來獲取一個在{0,...,n-1}范圍中的數(shù)。 我們有時會在右邊寫下 (modn) 來聲明我們使用的是此種類型的加法璧针。 比如嚷炉,2+3=1(mod4)。 我們稱帶有這種加法操作的集合 {0,…,n?1}Z(+,n)探橱。

For a prime p, we can use the mod p operation to also define a multiplication operation over the numbers {1,…,p?1} in a way that the multiplication result is also always in the set {1,…,p?1} – by performing regular multiplication of integers, and then taking the result mod p. [3] For example, 2?4=1 (mod 7).

[3]When p is not a prime it is problematic to define multiplication this way. One issue is that the multiplication result can be zero even when both arguments are not zero. For example when p=4, we can get 2*2=0 (mod 4).

對于一個質(zhì)數(shù) p申屹,我們可以使用 mod p 在集合{1,....,p-1}上定義一個乘法操作,這樣操作的結(jié)果也會在集合 {1,…,p?1} 中 —— 通過對整數(shù)的常規(guī)乘法隧膏,并對結(jié)果進(jìn)行mod p操作哗讥。[3] 比如,2?4=1 (mod 7) .

    • [3]當(dāng) p 不是質(zhì)數(shù)時胞枕,以上的方式定義乘法是有問題的杆煞。其中的一個問題是即便兩個參數(shù)都不為零,乘積的結(jié)果仍可能為零腐泻。比如當(dāng) p = 4 是决乎,我們可以得到 2*2=0 (mod 4)

This set of elements together with this operation is referred to as the group Z(*,p). Z(*,p) has the following useful properties:

這樣的集合和操作一起被稱為群 Z(*,p)Z(*,p)具有以下這些有用的屬性:

  1. It is a cyclic group; which means that there is some element g in Z(*,p) called a generator such that all elements of Z(*,p) can be written as gaga for some a in {0,..,p?2}, where we define g^0=1.
  2. The discrete logarithm problem is believed to be hard in Z(*,p). This means that, when p is large, given an element h in Z(*,p) it is difficult to find the integer a in 0,..,p?2 such that g^a=h (mod p).
  3. As ”exponents add up when elements are multiplied”, we have for a,b in 0,..,p?2 ; ( g^a )?( g^b )=g^(a+b (mod p?1)).
  1. 它是一個循環(huán)群贫悄;這意味著瑞驱,Z(*,p)其中有一些被稱為生成器(generator)的元素g,當(dāng)我們定義g^0=1時窄坦,Z(*,p)所有的元素都能被寫成g^a的形式唤反,其中a{0,...,p-2}的元素 。
  2. 離散對數(shù)問題在 Z(*,p) 中被認(rèn)為是困難的鸭津。這意味著彤侍,當(dāng) p 值較大時,給定一個在Z(*,p)中的元素h逆趋,很難在 0,..,p?2 中找到整數(shù) a 盏阶,滿足 g^a=h (mod p)
  3. 由于 “元素相乘時它們的指數(shù)會相加”闻书,對于來自0,..,p-2a,b名斟,等式( g^a )?( g^b )=g^( a+b (mod p-2) )成立。

Using these properties, we now construct an HH that ”supports addition” – meaning that E(x+y) is computable from E(x) and E(y). We assume the input x of E is from Z(p?1), so it is in the range {0,…,p?2}. We define E(x)=g^x for each such x, and claim that E is an HH: The first property implies that different x’s in Z(p?1) are mapped to different outputs. The second property implies that given E(x)=g^x it is hard to find x. Finally, using the third property, given E(x) and E(y) we can compute E(x+y) as E(x+y)=g^( x+y (mod p?1) )=( g^x )?( g^y )=E(x)?E(y).

使用這些特性魄眉,我們現(xiàn)在建立一個 “支持加法” 的 HH – 這意味著 E(x+y) 可以由 E(x)E(y) 計算得到砰盐。 我們假設(shè) E 的輸入 x 來自 Z(*,p-1),因此它的范圍是 {0,..,p?2}坑律。 我們對每個這樣的 x 定義 E(x)=g^x 岩梳,并稱這樣的 E 是一個 HH: 第一個特性表明,在 Z(*,p?1) 中的不同 x 會映射到不同的輸出。 第二個特性表明冀值,給定一個 E(x)=g^x 也物,很難計算出 x。 最終列疗,使用第三個特性滑蚯,對于給定的 E(x)E(y),我們可以計算出 E(x+y) 作彤,因為 E(x+y) as E(x+y)=g^( x+y (mod p?1) )=( g^x )?( g^y )=E(x)?E(y)膘魄。


譯者總結(jié)


數(shù)學(xué)關(guān)系
模型
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市竭讳,隨后出現(xiàn)的幾起案子创葡,更是在濱河造成了極大的恐慌,老刑警劉巖绢慢,帶你破解...
    沈念sama閱讀 218,941評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件灿渴,死亡現(xiàn)場離奇詭異,居然都是意外死亡胰舆,警方通過查閱死者的電腦和手機(jī)骚露,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,397評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來缚窿,“玉大人棘幸,你說我怎么就攤上這事【肓悖” “怎么了误续?”我有些...
    開封第一講書人閱讀 165,345評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長扫茅。 經(jīng)常有香客問我蹋嵌,道長,這世上最難降的妖魔是什么葫隙? 我笑而不...
    開封第一講書人閱讀 58,851評論 1 295
  • 正文 為了忘掉前任栽烂,我火速辦了婚禮,結(jié)果婚禮上恋脚,老公的妹妹穿的比我還像新娘腺办。我一直安慰自己,他們只是感情好糟描,可當(dāng)我...
    茶點故事閱讀 67,868評論 6 392
  • 文/花漫 我一把揭開白布菇晃。 她就那樣靜靜地躺著,像睡著了一般蚓挤。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,688評論 1 305
  • 那天灿意,我揣著相機(jī)與錄音估灿,去河邊找鬼。 笑死缤剧,一個胖子當(dāng)著我的面吹牛馅袁,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播荒辕,決...
    沈念sama閱讀 40,414評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼汗销,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了抵窒?” 一聲冷哼從身側(cè)響起弛针,我...
    開封第一講書人閱讀 39,319評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎李皇,沒想到半個月后削茁,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,775評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡掉房,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,945評論 3 336
  • 正文 我和宋清朗相戀三年茧跋,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片卓囚。...
    茶點故事閱讀 40,096評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡瘾杭,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出哪亿,到底是詐尸還是另有隱情粥烁,我是刑警寧澤,帶...
    沈念sama閱讀 35,789評論 5 346
  • 正文 年R本政府宣布锣夹,位于F島的核電站页徐,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏银萍。R本人自食惡果不足惜变勇,卻給世界環(huán)境...
    茶點故事閱讀 41,437評論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望贴唇。 院中可真熱鬧搀绣,春花似錦、人聲如沸戳气。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,993評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽瓶您。三九已至麻捻,卻和暖如春纲仍,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背贸毕。 一陣腳步聲響...
    開封第一講書人閱讀 33,107評論 1 271
  • 我被黑心中介騙來泰國打工郑叠, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人明棍。 一個月前我還...
    沈念sama閱讀 48,308評論 3 372
  • 正文 我出身青樓乡革,卻偏偏與公主長得像,于是被迫代替她去往敵國和親摊腋。 傳聞我的和親對象是個殘疾皇子沸版,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,037評論 2 355

推薦閱讀更多精彩內(nèi)容