OpenNHP/opennhp · error
signature verification failed
Error message
signature verification failed
What it means
After decrypting, DecryptZtdoFile reads the trailing signature block and calls signature.verify(recalcSig), which recomputes the expected signature (recalcSig) and compares it with the one stored in the file. A mismatch means the file content was altered after signing or the signature was produced with different keys/data. The library throws to refuse processing tampered or mis-signed data.
Solutions
- Confirm the file came from a trusted, unmodified source and re-download/re-copy it.
- Check that the signing key used by the producer matches the verification key expected here.
- Regenerate the file: re-create the ztdo (including metadata/signature) from the original data instead of patching the corrupted one.
- If you produce signed files, verify the signature immediately after writing to catch serialization-order bugs.
Example fix
// before: assume file intact
err := ztdo.DecryptZtdoFile(f, pass)
// after: detect and surface tampering distinctly
if err := ztdo.DecryptZtdoFile(f, pass); err != nil {
if strings.Contains(err.Error(), "signature verification failed") {
return ErrTamperedZtdo // treat as security event, not I/O error
}
return err
} Defensive patterns
Strategy: try-catch
Try / catch
if err := ztdo.DecryptZtdoFile(f, pass); err != nil {
if strings.Contains(err.Error(), "signature verification failed") {
log.SecurityEvent("ztdo_signature_mismatch", path)
return ErrTampered
}
return err
} Prevention
- Sign and verify with matching keys; keep key rotation coordinated
- Verify signature immediately after writing signed ztdo files
- Transport ztdo files over integrity-checked channels (TLS/checksums)
- Never edit a signed ztdo file in place
When it happens
Trigger: Calling DecryptZtdoFile on a signed ztdo file where signature.verify() returns false — the stored signature does not match the recalculated signature over the decrypted content.
Common situations: File modified after signing (edited metadata, re-chunked content); signed by a different key than the one used to verify; a bug in a custom writer that serialized the header/signature out of order; partial re-encryption of the file by another tool.
Understand the failure class
Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.
Related errors
- invalid ztdo file
- access url is empty, please check with data provider
- failed to download ztdo
- failed to parse ztdo header
- ztdo id mismatch, please check with data provider
AI-assisted analysis of OpenNHP/opennhp@6e04ca5ff0 (2026-09-07).
Data as JSON: /api/errors/906bae33dfea8d20.
Report an issue: GitHub.
Appendix: source
Thrown at nhp/core/ztdo/ztdo.go:476
return fmt.Errorf("invalid ztdo file")
}
} else {
if remainingCiphertextFileSize == 0 {
break
}
}
}
// update recalculated signature
recalcSig.sign(gcmKey)
if ztdo.header.HasSignature() {
if err := toStructure(ciphertextFile, &ztdo.signature); err != nil {
return err
}
if !ztdo.signature.verify(recalcSig) {
return fmt.Errorf("signature verification failed")
}
}
return nil
}
// marshal searilizs Go struct into bytes buffer
func marshal(buf *bytes.Buffer, data any) error {
rData := reflect.ValueOf(data)
if rData.Kind() == reflect.Pointer {
rData = rData.Elem()
}
if rData.Kind() != reflect.Struct {
return fmt.Errorf("data must be a struct")
}
for i := range rData.NumField() {View on GitHub (pinned to 6e04ca5ff0)