ZK Fixed Point Arithmetic with its Application in Machine Learning based on Halo2 & Axiom's Halo2-base.
- FixedPointChip: Fixed point arithmetic and math library
- Support different kinds of precisions (from
32.32to63.63) with automatically generated polynomial using Remez algorithm - Support negative number arithmetics with quantization
- Support functions:
add,sub,mul,div,mod,sign,clip,polynomial,bit_xor,sum,neg,exp,log,pow,sqrt,max,sin,cos,tan,sinh,cosh, etc.
- Support different kinds of precisions (from
- ZK-LR: LinearRegressionChip/LogisticRegressionChip
- Support inference with vector multiplication and
sigmoid(based onexp) using FixedPointChip - Support training with gradient descent algorithm
- Support inference with vector multiplication and
- ZK-DT: DecisionTreeChip
- Support inference with tree traversal over the decision tree
- Support training by building the decision tree recursively with the calculated Gini Impurity in each node
Install rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shClone this repo:
git clone https://github.com/DCMMC/ZKFixedPointChip.git
cd ZKFixedPointChipFixed Point Arithmetic (exp2, log2, sin):
cargo run --example fixed_pointLinear Regression (Inference & Training):
cargo run --example linear_regressionLogistic Regression (Inference & Training):
cargo run --example logistic_regressionDecision Tree (Inference & Training):
cargo run --example decision_treeFor visualizing, you should install
graphvizand the generatedsvgfile is located in./figure/dt.svg.
The complexity of decision tree training is proportional to
$2^d$ where$d$ is the tree depth.
