Cryptography Primitives
The ElGamal encryption in the Zei library is defined over the Ristretto curve, where the base
is the base point of the Ristretto group. Note that the message
is encoded into a group element as
, 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:
- :
-
-
- output
- :
-
- output.
- :
- .
- .
- Output.
- :
-
- check
- :
-
- output
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:
- :
-
-
- derive an AES symmetric keyfromusing SHA256
-
- output
- :
-
- derive an AES symmetric keyfromusing SHA256
- output
The matrix Sigma protocol in the Zei library is a proof of knowledge for the following statement: the prover
knows a scalar vector
such that:
where
is a matrix of group elements and
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.
- :
- append individual group elements into the transcript
-
-
- appendto the transcript
- squeeze a challengefrom the Fiat-Shamir transform
-
- output
-
-
- append individual group elements into the transcript
- appendto the transcript
- squeeze a challengefrom the Fiat-Shamir transform
- check
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
with a generator
with a scalar field
.
The Schnorr signature has the following syntax.
-
-
-
- output
-
-
-
- append the message, the public key, andto the transcript
- squeeze a challengefrom the Fiat-Shamir transform
-
- output
- :
-
- append the message, the public key, andto the transcript
- squeeze a challengefrom the Fiat-Shamir transform
- check
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
and
, where we do not know their discrete logs to each other. The commitment algorithm is as follows.
- :
- output
The Chaum-Pedersen proof of commitment equality scheme in the Zei library is to show that two Pedersen commitments
and
, whose blinding factors are correspondingly
, commit to the same value
. This proof is commonly used to show equality over commitments.
The Chaum-Pedersen proof of commitment equality scheme has the following syntax.
- :
- let matrixbe:
- let vectorbe:
- output
- :
- let matrixbe:
- let vectorbe:
- check
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.
- :
- appendto the transcript
-
- squeezefrom the Fiat-Shamir transform
-
-
-
- output
- :
- appendto the transcript
-
- squeezefrom the Fiat-Shamir transform
-
- check
- check
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
is multiplied over an independent group generator
, while in the ciphertext,
is multiplied over some public key
.
The Pedersen-ElGamal proof of equality has the following syntax.
- :
- let matrixbe:
- let vectorbe:
- output
- :
- let matrixbe:
- let vectorbe:
- check
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.
Last modified 4mo ago