def check_totp(secret, ticket):
 for offset in [0, 1, (-1)]:
  if (ticket == compute_totp(secret, offset)):
   return True
 return False

def check_totp ( secret , ticket ) : for offset in [ 0 , 1 , ( - 1 ) ] : if ( ticket == compute_totp ( secret , offset ) ) : return True return False
check a totp value received from a principal trying to authenticate against the expected value computed from the secret shared between the principal and the authenticating entity .