zknode

Binary tree node structure for representing parsed ZK statements.

This module provides the BinNode class used by the ZKP compiler to represent parsed zero-knowledge proof statements as a binary tree structure.

Note:

This module is part of the experimental ZKP compiler and should be considered proof-of-concept quality.

class zknode.BinNode(value, left=None, right=None)[source]

Bases: object

Binary tree node for representing ZK proof statement components.

Node types:
  • ATTR (0): Attribute/variable node (leaf)

  • OR (1): Logical OR node

  • AND (2): Logical AND node

  • EXP (3): Exponentiation node (^)

  • EQ (4): Equality node (=)

Args:

value: Either a string (creates ATTR node) or int (creates operator node) left: Left child node (optional) right: Right child node (optional)

addSubNode(left, right)[source]

Set the left and right child nodes.

getAttribute()[source]

Return the attribute value if this is an ATTR node, else None.

getLeft()[source]

Return the left child node.

getRight()[source]

Return the right child node.

traverse(function)[source]

Traverse the tree and apply function to each node.

Args:

function: Callable that takes (node_type, node) as arguments