The Zcash network is young, but evolving quickly! Sign up and we'll be in touch with monthly highlights on ecosystem growth, network development and how to get started with Zcash!

# Rust编程语言中的配对密码

## 配对密码学

$$e(a g_{1}, b g_{2}) = e(g_{1}, g_{2})^{ab}$$，其中 $$a$$$$b$$$$g_{2}$$ 是各自群的生成器。

## Joux的秘钥协商协议

Alice Computes Bob Computes Carol Computes
$$e(B_{1}^{pk}, C_{2}^{pk})^{A^{sk}}$$ $$e(C_{1}^{pk}, A_{2}^{pk})^{B^{sk}}$$ $$e(A_{1}^{pk}, B_{2}^{pk})^{C^{sk}}$$
All equivalent to $$e(g_{1}, g_{2})^{A^{sk} B^{sk} C^{sk}}$$

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // Generate private keys let alice_sk = Scalar::random(rng); let bob_sk = Scalar::random(rng); let carol_sk = Scalar::random(rng); // Generate public keys in G1 and G2 let (alice_pk1, alice_pk2) = (G1::one() * &alice_sk, G2::one() * &alice_sk); let (bob_pk1, bob_pk2) = (G1::one() * &bob_sk, G2::one() * &bob_sk); let (carol_pk1, carol_pk2) = (G1::one() * &carol_sk, G2::one() * &carol_sk); // Each party computes the shared secret let alice_ss = pairing(&bob_pk1, &carol_pk2) ^ &alice_sk; let bob_ss = pairing(&carol_pk1, &alice_pk2) ^ &bob_sk; let carol_ss = pairing(&alice_pk1, &bob_pk2) ^ &carol_sk; assert!(alice_ss == bob_ss && bob_ss == carol_ss); 

## bn

“bn”是用于执行这些配对操作的 Rust编程语言 库，利用了我们的 科学家设计 的一个加密结构。 它使用一个Barreto-Naehrig椭圆曲线。这个库是新的、不完整的，不应该被应用到真实生成环境中，但是这是我们实现我们的目标—使得这一新的密码学更为人所知和易于使用—的第一步。