canopy-network/canopy · error

key not found

Error message

key not found

What it means

Raised in Keystore.GetKey when no key is registered in AddressMap for the hex-encoded address argument. The address has never been imported (or was deleted), so there is nothing to decrypt; this is a lookup miss, not a wrong-password error (which DecryptPrivateKey would raise).

Source

Thrown at lib/crypto/keystore.go:145

	err = ks.Import(encrypted, ImportOpts{
		Address:  publicKey.Address().Bytes(),
		Nickname: opts.Nickname,
	})
	if err != nil {
		return
	}

	address = publicKey.Address().String()

	return
}

// GetKey() returns the PrivateKeyI interface for an address and decrypts it using the password
func (ks *Keystore) GetKey(address []byte, password string) (PrivateKeyI, error) {
	v, ok := ks.AddressMap[hex.EncodeToString(address)]
	if !ok {
		return nil, fmt.Errorf("key not found")
	}
	return DecryptPrivateKey(v, []byte(password))
}

type GetKeyGroupOpts struct {
	Address  []byte
	Nickname string
}

// GetKeyGroup() returns the full keygroup for an address or nickname and decrypts the private key using the password
func (ks *Keystore) GetKeyGroup(password string, opts GetKeyGroupOpts) (*KeyGroup, error) {
	var stringAddress string
	if opts.Address != nil {
		stringAddress = hex.EncodeToString(opts.Address)
	}
	if opts.Nickname != "" {
		stringAddress = ks.NicknameMap[opts.Nickname]
	}

View on GitHub (pinned to ee8197d91d)

Solutions

  1. Verify the address was imported (ImportRaw/Import) before calling GetKey.
  2. Check that the address bytes are hex-encoded the same way the keystore stores keys (hex.EncodeToString).
  3. If the key may have been deleted, recreate/import it before retrying.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/crypto/keystore.go:145 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of canopy-network/canopy@ee8197d91d (2026-09-06). Data as JSON: /api/errors/c39db1a19cb1f52a. Report an issue: GitHub.