Fixed signature creation and validation code