Consistent algebra for the constraints of quantum gravity