A key was rejected by Ring: InvalidEncoding

Hello!

I created some identities using dfx 0.13.1; these “new” identities have the following shape:

-----BEGIN EC PRIVATE KEY-----
line 1
line 2
line 3
-----END EC PRIVATE KEY-----

now when I start a process (written in rust, using the ic-agent crate) that uses the private key to instantiate an identity I get the following error:

A key was rejected by Ring: InvalidEncoding

This does not happen with identities created with dfx 0.11.2. These have the following format:

-----BEGIN PRIVATE KEY-----
line 1
line 2
-----END PRIVATE KEY-----

I tried

  • ic-agent = "0.23.0"
  • ic-agent = "0.23.2"

Anyone else experiencing this? How can this be resolved?

okay so our rust code uses this

/// A Basic Identity which sign using an ED25519 key pair.
pub struct BasicIdentity {
    key_pair: Ed25519KeyPair,
    der_encoded_public_key: Vec<u8>,
}

and that only seems to support ED25519

what should be used for EC keys?

okay … found it :stuck_out_tongue:

/// A cryptographic identity based on the Secp256k1 elliptic curve.
///
/// The caller will be represented via [`Principal::self_authenticating`], which contains the SHA-224 hash of the public key.
#[derive(Clone, Debug)]
pub struct Secp256k1Identity {
    private_key: SigningKey,
    _public_key: VerifyingKey,
    der_encoded_public_key: Document,
}