{"record":{"id":"1054e9190150fea5","repo":"OpenNHP/opennhp","slug":"full-key-verification-failed","errorCode":null,"errorMessage":"full key verification failed","messagePattern":"full key verification failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/kgc/user/user.go","lineNumber":166,"sourceCode":"// the public key generated from the private key. It combines user information with system\n// parameters to compute a hash, then uses this hash to scale the master public key.\n// The scaled key is added to declared public key and compared against the public key\n// generated from the full key's private key. Returns an error if verification fails.\nfunc (u *UserImpl) VerifyFullKey(fullKey *UserFullKey, userId string) error {\n\tdeclaredUserPubBytes := fullKey.PubX.Bytes()\n\tdeclaredUserPubBytes = append(declaredUserPubBytes, fullKey.PubY.Bytes()...)\n\n\tdeclaredPbkBase64 := base64.StdEncoding.EncodeToString(declaredUserPubBytes)\n\n\tuserPubX, userPubY, err := u.CalculateFullPublicKey(declaredPbkBase64, userId)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tuserPubXFromPrk, userPubYFromPrk := u.Curve.ScalarBaseMult(fullKey.PrivateKey.Bytes())\n\n\tif userPubX.Cmp(userPubXFromPrk) != 0 || userPubY.Cmp(userPubYFromPrk) != 0 {\n\t\treturn fmt.Errorf(\"full key verification failed\")\n\t}\n\n\treturn nil\n}\n\n// Sign generates an ECDSA signature for the given message using the user's private key.\n// It returns the signature components (r, s) and any error encountered during signing.\n// The signature is computed using the standard ECDSA algorithm:\n// 1. Hashes the message\n// 2. Generates a random nonce k\n// 3. Computes r = (k*G).x mod N\n// 4. Computes s = k⁻¹·(e + r·dA) mod N\n// where e is the message hash, dA is the private key, and N is the curve order.\nfunc (u *UserImpl) Sign(prkBase64 string, message string) (r, s *big.Int, err error) {\n\tu.h.Write([]byte(message))\n\tmsgHash := u.h.Sum(nil)\n\tu.h.Reset()\n","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/kgc/user/user.go#L148-L184","documentation":"Raised by UserImpl.VerifyFullKey: it encodes the full key's declared public point, computes the identity-and-parameters hash, scales the master public key, adds it to the declared public key, and compares the result with the public key derived from the full private key. The comparison failed, so the full key is internally inconsistent — the private scalar does not correspond to the declared public point under the current system parameters.","triggerScenarios":"Thrown at endpoints/kgc/user/user.go:166 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the user full key from fresh KGC and user partial keys","Ensure the KGC instance and parameters (master public key, curve) are identical during issuance and verification","Confirm the key was not truncated or re-encoded (base64 round-trip) before verification"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6e04ca5ff03222a699c24205cd4bf8fee9af7ffe","analyzedAt":"2026-09-07T15:44:59.941Z","contentChangedAt":"2026-09-07T15:44:59.941Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}