sampleproject icon indicating copy to clipboard operation
sampleproject copied to clipboard

Unable verify

Open murugesanmadappan opened this issue 6 months ago • 1 comments

This is my code while verifying error

Error: ERROR - Error verifying the message: Malformed public key

My Code

`import logging from hsslms import HSS_Priv, LMS_ALGORITHM_TYPE, LMOTS_ALGORITHM_TYPE

def main(): # Define the LMS and LMOTS algorithm types lms_type = LMS_ALGORITHM_TYPE.LMS_SHA256_M24_H15 lmots_type = LMOTS_ALGORITHM_TYPE.LMOTS_SHA256_N32_W1

# Initialize the HSS private key
logging.info("Initializing HSS private key with LMS and LMOTS algorithm types.")
hss_private_key = HSS_Priv([lms_type]*2, lmots_type)
logging.debug("HSS private key initialized.")

# message to sign
message = b"This is a Muru Secret message."
logging.info("Message to be signed: %s", message)

# Sign the message
logging.info("Signing the message.")
try:
    signature = hss_private_key.sign(message)
    logging.debug("Signature generated: %s", signature)
except Exception as e:
    logging.error("Error signing the message: %s", e)
    return

# Verify the message
logging.info("Verifying the message.")
try:
    # Initialize the HSS public key
    # Ensure that the public key is correctly created or loaded
    try:
        hss_public_key = hss_private_key.gen_pub()
        logging.debug("HSS public key initialized.")
    except Exception as e:
        logging.error("Error initializing HSS public key: %s", e)
        return

    # Perform verification
    is_valid = hss_public_key.verify(message, signature)
    logging.info("Verification result: %s", is_valid)
except Exception as e: logging.error("Error verifying the message: %s", e)

if name == "main": main()`

murugesanmadappan avatar Aug 14 '24 13:08 murugesanmadappan