def xor_if
import qasim-bend-kit@0.1.0.2/libs/AES256GCMCore.bend as AES256GCMCoreimport Base
4# Byte arithmetic. Inputs and outputs are represented by U32 values in [0,255].
5# Turn a boolean into an all-zero or all-one word to keep field arithmetic branchless.
6def xor_if(a: U32, b: U32, yes: Bool) -> U32:
7 mask = U32.sub(0, Bool.to_u32(yes))
8 U32.xor(a, U32.and(mask, b))