Expand description
ZkStd
This crate provides basic cryptographic implementation as in Field
, Curve
and Pairing
, Fft
, Kzg
, and also supports fully no_std
and parity-scale-codec
.
Design
Cryptography libraries need to be applied optimization easily because computation cost affects users waiting time and on-chain gas cost. We design this library following two perspectives.
- The simplicity to replace with the latest algorithm
- The brevity of code by avoiding duplication
We divide arithmetic operation and interface. Arithmetic operation is concrete logic as in elliptic curve addition and so on, and the interface is trait cryptography primitive supports. And we combine them with macro. With this design, we can keep the finite field and elliptic curve implementation simple.
Directory Structure
- arithmetic: the arithmetic operation of limbs, points and bit operation.
- behave: the interface of cryptography components as in
Fft Field
,Pairing Field
and so on. - dress: the macro used for implementation and in charge of combing
arithmetic
andbehave
together.
Modules
- The arithmetic operation of limbs, points and bit operation. Algebraic algorithms are here.
- export necessary traits for crypto Substrate compatible.
- macro used for crypto components construction
Macros
- curve reference basic operation macro
- extension field basic operation macro
- fft field macro
- abstract algebra field operation macro
- abstract algebra group operation macro
- affine and projective coordinate mixed basic operation
- prime field operation for extension field macro
- prime field macro
- basic operation reference macro
- abstract algebra ring operation macro
- Twisted Edwards curve group operation macro
- Weierstrass standard curve operation macro