A complex math library with fast fourier transform and some trigonometric functions, along with concerned circuits in Noir.
We have developed a complex math library in Noirlang, which includes a fast Fourier transform and various trigonometric functions. These functions are implemented in separate files, using basic structs and operations to ensure accurate results for complex math operations. These operations include addition, subtraction, multiplication, division, square root, and magnitude for complex numbers. To maintain precision up to at least two decimal places, we have also implemented scaling.
While we aimed to include logarithmic and exponential functions, the time constraints of the hackathon and certain language limitations made this challenging. However, once we implement the exponential function, we will be able to extend our library to include various mathematical functions used in machine learning, such as the sigmoid and softmax functions. This will be beneficial for further research and development of ZKML.
We are committed to continuing our efforts beyond the hackathon. Additionally, for the front-end, we have developed circuits to generate and verify proofs, all of which will be accessible through the browser.
We first built all the functions in the library. The library part of our project is solely built on noir-lang and it includes two structs "Number" and "Complex" in order to support both positive and negative values of real and imaginary parts of the complex number. We implemented the functions for addition, subtraction, multiplication, division, magnitude, square root, abs, FFT, sine, cosine etc. in our library. Then we went on to write the circuits for these functions in order to generate proof and verify these proofs with the help of noir-lang. The final step in the project is building the front-end. We implemented the front-end such that it generates a smart-contract using the noir files and after taking up the values of the public and private inputs, it passes them on to the functions of generate proof and verify proof. Proof generation takes place off-chain while proof verification takes place on-chain by sending a transaction. We have used the Nextjs framework for the front-end and used Typescript as the programming language. Then, at last we integrated these all parts on the frontend itself.