Precompiles
Precompiles are built-in system functions within ZisK’s operating system that accelerate computationally expensive and frequently used operations such as the Keccak-f permutation and Secp256k1 addition and doubling.
These precompiles improve proving efficiency by offloading intensive computations from ZisK programs to dedicated, pre-integrated sub-processors. ZisK manages precompiles as system calls using the RISC-V ecall
instruction.
How Precompiles Work
Precompiles are primarily used to patch third-party crates, replacing costly operations with system calls. This ensures that commonly used cryptographic primitives like Keccak hashing and elliptic curve operations can be efficiently executed within ZisK programs.
Typically, precompiles are used to patch third-party crates that implement these operations and are then used as dependencies in the Zisk programs we write.
You can see here an example of the patched tiny-keccak
crate.
Available Precompiles in ZisK
Below is a summary of the precompiles currently available in ZisK:
- syscall_arith256_mod: Modular multiplication followed by addition over 256-bit non-negative integers.
- syscall_arith256: Multiplication followed by addition over 256-bit non-negative integers.
- syscall_keccak_f: Keccak-f[1600] permutation function from the Keccak cryptographic sponge construction.
- secp256k1_add: Elliptic curve point addition over the Secp256k1 curve.
- secp256k1_dbl: Elliptic curve point doubling over the Secp256k1 curve.