privacy-scaling-explorations / zk-kit

A monorepo of reusable libraries for zero-knowledge technologies.
https://zkkit.pse.dev
MIT License
290 stars 76 forks source link

feat: add `@zk-kit/logical-expressions` package #310

Closed vplasencia closed 3 months ago

vplasencia commented 4 months ago

Description

This PR:

There is no need to verify the correctness of the logical expression before calling the evaluate function, as this will be checked during the evaluation. If the expression is incorrect, an error will be thrown automatically.

Example of correct logical expression: "true and false".

Example of incorrect logical expression: "true true and false".

The @zk-kit/logical-expressions package facilitates the work with logical (boolean) expressions. It allows you to tokenize and evaluate any logical expression. It supports the use of parentheses.

Logical operators supported: and, or, not, xor.

All other existing logical operators (nand, nor, xnor) can be generated using the supported logical operators.

More context: https://github.com/bandada-infra/bandada/issues/223

Future work:

The algorithm used to evaluate boolean expressions can be generalized to evaluate arithmetic expressions or other types of expressions if necessary.

Related Issue(s)

Closes https://github.com/privacy-scaling-explorations/zk-kit/issues/307

Checklist

vplasencia commented 3 months ago

Hey @sripwoud!

I just replied in the Bandada issue and updated the files field and added the author field.

vplasencia commented 3 months ago

Thank you very much for the review 🙏

sripwoud commented 3 months ago

@vplasencia feel free to publish