{"record":{"id":"5eb652aa3707ec7c","repo":"OpenNHP/opennhp","slug":"full-key-generation-failed-please-regenerate-user","errorCode":null,"errorMessage":"full key generation failed, please regenerate user partial key","messagePattern":"full key generation failed, please regenerate user partial key","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/kgc/user/user.go","lineNumber":86,"sourceCode":"\tpartialPrivateKey, err := kgc.GenerateRandomNumber(u.Params().N)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpartialPubX, partialPubY := u.Curve.ScalarBaseMult(partialPrivateKey.Bytes())\n\n\treturn &UserPartialKey{\n\t\tPrivateKey: partialPrivateKey,\n\t\tPubX:       partialPubX,\n\t\tPubY:       partialPubY,\n\t}, nil\n}\n\nfunc (u *UserImpl) GenerateUserFullKey(kgcUserPartialKey *kgc.KGCUserPartialKey, userPartialKey *UserPartialKey) (*UserFullKey, error) {\n\tfullPrivateKey := new(big.Int).Add(kgcUserPartialKey.T, userPartialKey.PrivateKey)\n\tfullPrivateKey.Mod(fullPrivateKey, u.Params().N)\n\tif fullPrivateKey.Cmp(big.NewInt(0)) == 0 {\n\t\treturn nil, fmt.Errorf(\"full key generation failed, please regenerate user partial key\")\n\t}\n\n\treturn &UserFullKey{\n\t\tPrivateKey: fullPrivateKey,\n\t\tPubX:       kgcUserPartialKey.Wx,\n\t\tPubY:       kgcUserPartialKey.Wy,\n\t}, nil\n}\n\n// CalculateFullPublicKey computes the full public key by combining a declared public key with a master public key.\n// It takes a base64-encoded declared public key and user ID as input, and returns the derived public key coordinates (X,Y).\n// The calculation involves hashing user-specific information and applying elliptic curve operations.\n// Returns error if the input public key is invalid.\nfunc (u *UserImpl) CalculateFullPublicKey(declaredPbkBase64, userId string) (*big.Int, *big.Int, error) {\n\tbyteLen := u.Curve.Params().BitSize / 8\n\tdeclaredPbk, err := base64.StdEncoding.DecodeString(declaredPbkBase64)\n\tif err != nil {\n\t\treturn nil, nil, err","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/kgc/user/user.go#L68-L104","documentation":"Raised inside UserImpl.GenerateUserFullKey (via VerifyFullKey) after combining the KGC-issued partial key and the user partial key: the resulting full key failed self-verification, meaning the arithmetic combination of the two partial secrets did not reproduce the declared public key. Typically caused by a stale or mismatched kgcUserPartialKey that was generated for different system parameters or a different user.","triggerScenarios":"Thrown at endpoints/kgc/user/user.go:86 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the user partial key locally and request a fresh KGC partial key, then retry","Confirm the KGC master public key in use matches the one the KGC partial key was derived from","Check the user-id used for key derivation matches on both sides","Verify the config was not regenerated (setup re-run) between issuing and combining the partial keys"],"exampleFix":null,"handlingStrategy":"retry","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"}