Expand description

Module for SafeType which enforce value range and realted functions.

Re-exports

pub use crate::gates::flex_gate::GateInstructions;
pub use crate::gates::range::RangeChip;
pub use crate::gates::range::RangeInstructions;
pub use crate::utils::ScalarField;
pub use crate::AssignedValue;
pub use crate::Context;
pub use crate::QuantumCell;
pub use crate::QuantumCell::Constant;
pub use crate::QuantumCell::Existing;
pub use crate::QuantumCell::Witness;

Structs

SafeType’s goal is to avoid out-of-range undefined behavior. When building circuits, it’s common to use mulitple AssignedValue to represent a logical varaible. For example, we might want to represent a hash with 32 AssignedValue where each AssignedValue represents 1 byte. However, the range of AssignedValue is much larger than 1 byte(0~255). If a circuit takes 32 AssignedValue 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. So circuits don’t need to do any extra value checking if they take SafeType as inputs. TOTAL_BITS is the number of total bits of this type. BYTES_PER_ELE is the number of bytes of each element.
Chip for SafeType

Type Definitions

SafeType for bool.
SafeType for bytes32.
SafeType for uint8.
SafeType for uint16.
SafeType for uint32.
SafeType for uint64.
SafeType for uint128.
SafeType for uint256.