Skip to content

v0.22.0

Compare
Choose a tag to compare
@github-actions github-actions released this 29 Mar 08:13
· 132 commits to main since this release

What’s New?

  • slice and join operator
  • Compilation speedup

slice and join operator

We've found that cryptographic primitives, such as hashing functions, are largely about shuffling bits around. Therefore, we have introduced two new operators for manipulating bit arrays (i.e. UInt).

slice for bit array slicing

slice :: UInt w -> (Int, Int) -> UInt v

slice takes an unsigned integer UInt w, along with a range, and returns a slice UInt v of that integer. The range is inclusive at the start and exclusive at the end.

For example, here’s a program that slices the 3rd and 4th bits off a byte:

program :: Comp (UInt 2)
program = do
  x <- input Public :: Comp (UInt 8)
  return $ slice x (2, 4)

join for bit array concatenation

join :: UInt u -> UInt v -> UInt (u + v)

The join function concatenates two unsigned integers, UInt u and UInt v, producing a new unsigned integer UInt (u + v). This function combines the bit representations of the two input unsigned integers into a single unsigned integer whose width is the sum of the widths of the two inputs.

For example:

program :: Comp (UInt 8)
program = do
  u <- input Public :: Comp (UInt 2)
  v <- input Public :: Comp (UInt 6)
  return $ u `join` v

Compilation Speedup

You should notice a nice speedup when compiling programs that involve a lot of UInts.

Polynomials play a central role in the compiler, as they represent constraints and relations within a program. These data structures have internal states (or invariants) that require maintenance after each operation, and it can really slow things down if this maintenance is not performed properly.

We've recently managed to improve the invariant maintenance of the polynomial insertion operation, making it 9 times faster.

We recognize that there are still other performance bottlenecks within the compiler, and we plan to continue optimizing them in future releases.

What’s Next?

  • API of the R1CS Witness Solver: We’ve been using the witness solver as a means of testing the correctness of the compilation. We believe that this tool will also greatly aid the testing and development of Keelung programs.
  • Make the R1CS witness solver smarter.
  • Optimization for the implementation of AES in the standard library.