The ElGamal encryption in the Zei library is defined over the Ristretto curve, where the base G is the base point of the Ristretto group. Note that the message m is encoded into a group element as m⋅G, which means that it can only be decrypted through brute-force. One who wants to remove this restriction can use reversible encoding, but it is not implemented in the Zei library.
The ElGamal encryption scheme has the following syntax:
The hybrid encryption in the Zei library supports the X25519 curve and the Ed25519 curve, and the symmetric encryption is done using the counter mode of the AES cipher.
The hybrid encryption scheme has the following syntax:
HybridEnc(sk,m)→ct:
r←$F
ct1:=r⋅G
derive an AES symmetric key k from sk⋅ct1 using SHA256
ct2:=AESEnc(k,m)
output ct=(ct1,ct2)
HybridDec(sk,ct):=m:
(ct1,ct2):=ct
derive an AES symmetric key k from sk⋅ct1 using SHA256
The matrix Sigma protocol in the Zei library is a proof of knowledge for the following statement: the prover P knows a scalar vector x∈{0,1}n such that:
M⋅xT=y
where M∈Gm×n is a matrix of group elements and y∈Gm is a vector of group elements.
The matrix Sigma protocol has the following syntax. In the actual implementation, the Fiat-Shamir transform is performed over a transcript across one or more interactive protocols.
Prove(M,x)→π:
append individual group elements in M to the transcript
r←$Fn
c:=M⋅rT
append c to the transcript
squeeze a challenge β from the Fiat-Shamir transform
d:=βx+r
output π=(c,d)
Verify(M,y,π):=b∈{0,1}
(c,d):=π
append individual group elements in M to the transcript
append c to the transcript
squeeze a challenge β from the Fiat-Shamir transform
The Schnorr signature in the Zei library is the classical version. The multi-signature implementation extends from the simple Schnorr signature in a naive manner: the multi-signature is a list of simple Schnorr signatures from individual signers. The Schnorr signature scheme is defined over a group G with a generator G with a scalar field F.
The Schnorr signature has the following syntax.
KeyGen(1λ)→(sk,pk):
sk←$F
pk:=sk⋅G
output (sk,pk)
Sign(sk,m)→σ:
r←$F
R:=r⋅G
append the message m, the public key pk:=sk⋅G, and R to the transcript
squeeze a challenge c from the Fiat-Shamir transform
s:=r+c⋅sk
output σ:=(R,s)
Verify(pk,m,σ):=b∈{0,1}:
(R,s):=σ
append the message m, the public key pk:=sk⋅G, and R to the transcript
squeeze a challenge c from the Fiat-Shamir transform
The Pedersen commitment over Ristretto scheme in the Zei library is used to represent the amount and the asset type. The scheme is defined over a group with two independent generators G and H, where we do not know their discrete logs to each other. The commitment algorithm is as follows.
The Chaum-Pedersen proof of commitment equality scheme in the Zei library is to show that two Pedersen commitments comm1 and comm2, whose blinding factors are correspondingly r1,r2, commit to the same value m. This proof is commonly used to show equality over commitments.
The Chaum-Pedersen proof of commitment equality scheme has the following syntax.
Prove(comm1,comm2,m,r1,r2)→π:
let matrix M be:
M:=(GGH1G1GH)
let vector x be:
x:=(mr1r2)
output π=MatrixSigma.Prove(M,x)
Verify(comm1,comm2,π):=b∈{0,1}:
let matrix M be:
M:=(GGH1G1GH)
let vector y be:
y:=(comm1,comm2)
check MatrixSigma.Verify(M,y,π)=1
There is an extended version of Chaum-Pedersen proof that checks the equality of multiple commitments, often used for checking the asset types. It has the following syntax. Note that there are alternative constructions, but due to compatibility reasons, we cannot easily upgrade.
BatchProve([commi]1n,m,[ri]1n)→π:
append G,H,[commi]1n to the transcript
π1←Prove(comm1,comm2,m,r1,r2)
squeeze ℓ3,ℓ4,...,ℓn from the Fiat-Shamir transform
comm:=∑i=3nℓi⋅(commi−comm1)
r:=∑i=3nℓi⋅(ri−r1)
π2←Prove(comm,1G,0F,r,0F)
output π:=(π1,π2)
BatchVerify([commi]1n,π):=b∈{0,1}:
append G,H,[commi]1n to the transcript
(π1,π2):=π
squeeze ℓ3,ℓ4,...,ℓn from the Fiat-Shamir transform
The Pedersen-ElGamal proof of equality scheme in the Zei library is used for a very special situation for the Pedersen commitments and associated ElGamal ciphertexts. Particularly, the commitments and the ElGamal ciphertexts share the same message as well as the same randomness. The only difference is that, in the commitment, the random scalar r is multiplied over an independent group generator H, while in the ciphertext, r is multiplied over some public key pk.
The Pedersen-ElGamal proof of equality has the following syntax.
The Rescue hash function implementation in the Zei library follows this reference implementation. The test against the reference implementation shows that the implementation has been correctly implemented.