Skip to content

winderica/r1cs-float

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

r1cs-float

R1CS constraints for floating-point arithmetic.

Disclaimer

This project is still in its early stages and hasn't been audited/reviewed by third parties. It may have some security flaws and side-channel vulnerabilities. Please DO NOT use this project in production unless you know what you are doing.

Features

  • Compatible with IEEE 754
    • Formats
      • Single precision (binary32)
      • Double precision (binary64)
      • Quadruple precision (binary128)
    • Values
      • Signed zero (+0 and -0)
      • Subnormal numbers
      • Normal numbers
      • Infinity
      • NaNs
    • Operations
      • Mathematical operations
        • add
        • sub
        • mul
        • div
        • neg
        • abs
        • rem
        • fma
        • Exponential functions
          • sqrt
          • pow
          • etc.
        • Logarithm functions (ln, log2, etc.)
        • Trigonometric functions (sin, cos, etc.)
      • Comparisons
        • eq
        • lt, gt, le, ge
        • min, max
      • Conversions
        • Rounding functions
          • trunc
          • floor
          • ceil
          • round
  • Highly optimized (C: Number of R1CS constraints, B: Number of bits queried to the lookup table)
    Operation binary32 binary64
    new 15C, 53B 15C, 114B
    neg, abs 0C, 0B 0C, 0B
    add, sub 45C, 125B 45C, 250B
    mul 36C, 145B 36C, 299B
    div 45C, 149B 45C, 303B
    sqrt 28C, 110B 28C, 229B
    lt, gt, le, ge 27C, 33B 27C, 65B
    trunc 13C, 64B 13C, 128B
    ceil, round 20C, 64B 20C, 128B

Usage

TODO

Tests

Simply run cargo test. Test datasets are generated using TestFloat.

License

MIT

About

R1CS constraints for floating-point arithmetic

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages