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 multipleAssignedValue<F>
s to represent a logical variable. For example, we might want to represent a hash with 32AssignedValue<F>
where eachAssignedValue
represents 1 byte. However, the range ofAssignedValue<F>
is much larger than 1 byte(0~255). If a circuit takes 32AssignedValue<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 ownedAssignedValue<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 arrayarr
and returns a lengthout_len
array equal to[[0; out_len - len], arr[..len]].concat()
, i.e., we takearr[..len]
and zero pad it on the left.
Type Aliases§
- SafeType for Address.
- SafeType for bytes32.
- SafeType for uint8.
- SafeType for uint16.
- SafeType for uint32.
- SafeType for uint64.
- SafeType for uint128.
- SafeType for uint160.
- SafeType for uint256.