use super::*; use crate::convert::{ToBytesGadget, ToConstraintFieldGadget}; impl ToBytesGadget for Boolean { /// Outputs `1u8` if `self` is true, and `0u8` otherwise. #[tracing::instrument(target = "r1cs")] fn to_bytes(&self) -> Result>, SynthesisError> { let value = self.value().map(u8::from).ok(); let mut bits = [Boolean::FALSE; 8]; bits[0] = self.clone(); Ok(vec![UInt8 { bits, value }]) } } impl ToConstraintFieldGadget for Boolean { #[tracing::instrument(target = "r1cs")] fn to_constraint_field(&self) -> Result>, SynthesisError> { let var = From::from(self.clone()); Ok(vec![var]) } }