{"record":{"id":"5685e2cff98559d3","repo":"OpenNHP/opennhp","slug":"relay-failed-to-create-nhp-device","errorCode":null,"errorMessage":"relay: failed to create NHP device","messagePattern":"relay: failed to create NHP device","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/relay/relay.go","lineNumber":202,"sourceCode":"\n\tstats struct {\n\t\ttotalRecvBytes uint64\n\t\ttotalSendBytes uint64\n\t}\n}\n\n// New creates a RelayServer from the given configuration.\nfunc New(cfg *Config) (*RelayServer, error) {\n\t// Decode relay private key.\n\tprk, err := base64.StdEncoding.DecodeString(cfg.PrivateKeyBase64)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"relay: invalid privateKeyBase64: %w\", err)\n\t}\n\n\t// Create NHP device with relay identity.\n\tdevice := core.NewDevice(core.NHP_RELAY, prk, nil)\n\tif device == nil {\n\t\treturn nil, fmt.Errorf(\"relay: failed to create NHP device\")\n\t}\n\n\trs := &RelayServer{\n\t\tconfig:    cfg,\n\t\tdevice:    device,\n\t\tservers:   make(map[string]*serverRuntime, len(cfg.Servers)),\n\t\tsendMsgCh: make(chan *core.MsgData, PacketQueueSizePerConnection),\n\t\tstopCh:    make(chan struct{}),\n\t}\n\trs.recvMsgCh = device.DecryptedMsgQueue\n\n\tfor i := range cfg.Servers {\n\t\tc := &cfg.Servers[i]\n\t\tcr, err := rs.buildServer(c)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\trs.servers[cr.id] = cr","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/relay/relay.go#L184-L220","documentation":"Raised in relay New right after core.NewDevice(core.NHP_RELAY, prk, nil) returned nil: the NHP device factory refused the freshly decoded private key, so the relay cannot build its Noise-protocol identity. In practice this means the decoded key bytes are not a valid scalar/key for the configured cipher scheme even though the base64 itself decoded.","triggerScenarios":"Thrown at endpoints/relay/relay.go:202 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the relay key pair and update PrivateKeyBase64 in config.toml","Verify the key length matches what core.NewDevice expects for the configured cipher scheme","Ensure the key was generated by the matching keygen mode (curve vs sm2)"],"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"}