Module halo2_base::safe_types

source ·
Expand description

Module for SafeType which enforce value range and realted functions.

Structs

  • Represents a fixed length byte array in circuit.
  • Represents a fixed length byte array in circuit. Not encouraged to use because MAX_LEN cannot be verified at compile time.
  • SafeType for bool (1 bit).
  • SafeType for byte (8 bits).
  • SafeType’s goal is to avoid out-of-range undefined behavior. When building circuits, it’s common to use multiple AssignedValue<F>s to represent a logical variable. For example, we might want to represent a hash with 32 AssignedValue<F> where each AssignedValue represents 1 byte. However, the range of AssignedValue<F> is much larger than 1 byte(0~255). If a circuit takes 32 AssignedValue<F> as inputs and some of them are actually greater than 255, there could be some undefined behaviors. SafeType gurantees the value range of its owned AssignedValue<F>. So circuits don’t need to do any extra value checking if they take SafeType as inputs.
  • Chip for SafeType
  • Represents a variable length byte array in circuit.
  • Represents a variable length byte array in circuit. Not encouraged to use because MAX_LEN cannot be verified at compile time.

Functions

  • Represents a fixed length byte array in circuit as a vector, where length must be fixed. Not encouraged to use because LEN cannot be verified at compile time. Takes a fixed length array arr and returns a length out_len array equal to [[0; out_len - len], arr[..len]].concat(), i.e., we take arr[..len] and zero pad it on the left.

Type Aliases