canopy-network/canopy · error

invalid password

Error message

invalid password

What it means

Raised in Keystore.ImportRaw when the supplied password is the empty string. The keystore refuses to encrypt and store a private key without a non-empty password, since it would be stored effectively unprotected; the key is not imported.

Source

Thrown at lib/crypto/keystore.go:114

		if ok && opts.Nickname != oldNickname {
			return errors.New("nickname already used")
		}
		ks.NicknameMap[opts.Nickname] = encrypted.KeyAddress
	}

	ks.AddressMap[encrypted.KeyAddress] = encrypted

	return nil
}

type ImportRawOpts struct {
	Nickname string
}

// ImportRaw() imports a non-encrypted private key to the store, but encrypts it given a password
func (ks *Keystore) ImportRaw(privateKeyBytes []byte, password string, opts ImportRawOpts) (address string, err error) {
	if password == "" {
		return "", fmt.Errorf("invalid password")
	}

	privateKey, err := NewPrivateKeyFromBytes(privateKeyBytes)
	if err != nil {
		return
	}
	publicKey := privateKey.PublicKey()

	encrypted, err := EncryptPrivateKey(publicKey.Bytes(), privateKeyBytes, []byte(password), address)
	if err != nil {
		return
	}

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

View on GitHub (pinned to ee8197d91d)

Solutions

  1. Supply a non-empty password when calling ImportRaw.
  2. Prompt the user interactively if the password was read from an empty env var or config field.
  3. Distinguish this from decrypt failures downstream: this fires before any encryption happens.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/crypto/keystore.go:114 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/242ebb94a67f3b41. Report an issue: GitHub.