https://github.com/0x3327/ZKFloat
Noir language library for floating point numbers
https://github.com/0x3327/ZKFloat
Last synced: 5 months ago
JSON representation
Noir language library for floating point numbers
- Host: GitHub
- URL: https://github.com/0x3327/ZKFloat
- Owner: 0x3327
- Created: 2023-02-27T11:44:18.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-07-31T14:21:57.000Z (over 1 year ago)
- Last Synced: 2024-02-13T00:51:50.840Z (about 1 year ago)
- Language: Roff
- Size: 4.88 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- awesome-noir - ZKFloat - a floating point library for Noir (Libraries / Data Types)
README
# ZKFloat
## About
ZKFLoat library adds support for representing floating point values and performing a basic arythmetic operations over floating point numbers. The numbers are represented as a base 10 floating point values in format inspired by [IEEE 754](https://standards.ieee.org/ieee/754/6210/) format for representing floating points using base 2. The structure consists of a sign, mantissa and exponent. Due to a current lack of support for signed data types in [Noir](https://noir-lang.org/) language, explicit representation of a sign value is required. Mantissa is represented using p number of significant digits, which equals 7 in the basic form but can be altered. As exponent value can also be negative values, current implementation uses exponent value centered around a specified positive value. In current value, the center value is 100, meaning that 0 exponent equals 100 in transformed format.The library implements `Float` structure representing floating point values, as well as operations for addition, subtraction and multiplications of the values. Each operation keeps first p number of digits in mantissa and updates exponent value of the result when needed.
### Implemented methods
- `addFloats` - Addition of floats
- `mulFloats` - Multiplication of floats
- `subFloats` - Subtraction of floats
- `divFloats` - Dividing of floats
- `truncate` - Internal method for truncating mantissa values which overflows the
maximum number of significant digits.
- `relu` - ReLU activation function, used in ANN models.## Future work
- Removing explicit sign attribute when [Noir](https://noir-lang.org/) language adds support for signed values
- More complex arithmetic operations## Applications
The library is used in [SKProof](https://github.com/0x3327/skproof) python library for proving execution of ML models