# Cannot import PGP keys from Rust API

**URL:** <https://forum.delta.chat/t/cannot-import-pgp-keys-from-rust-api/2943>\
**Category:** Uncategorized\
**Created:** [February 23, 2024, 9:15am UTC](https://forum.delta.chat/t/cannot-import-pgp-keys-from-rust-api/2943 "2024-02-23T09:15:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan](https://forum.delta.chat/user_avatar/forum.delta.chat/ivan/32/1822_2.png) [@Ivan](https://forum.delta.chat/u/Ivan)\
**Post date:** [February 23, 2024, 9:15am UTC](https://forum.delta.chat/t/cannot-import-pgp-keys-from-rust-api/2943/1 "2024-02-23T09:15:09Z")

</div>

Hi again 👋

So, I’m using `deltachat-core-rust` crate to implement a bot and I wan’t to import the PGP keys for its account but I think the API is not exporting some needed types.

The function I’m trying to use to import the keys is `store_self_keypair` but this function is getting a `KeyPair` as its second argument (see [deltachat-core-rust/src/key.rs at cf16671d8d562b41957a16af491d68367a91324e · deltachat/deltachat-core-rust · GitHub](https://github.com/deltachat/deltachat-core-rust/blob/cf16671d8d562b41957a16af491d68367a91324e/src/key.rs#L282)) and that type is not exported from the crate.

Is it a bug in the API or am I doing anything wrong?

Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![link2xt](https://forum.delta.chat/letter_avatar_proxy/v4/letter/l/ee7513/32.png) [@link2xt](https://forum.delta.chat/u/link2xt)\
**Post date:** [February 23, 2024, 9:44am UTC](https://forum.delta.chat/t/cannot-import-pgp-keys-from-rust-api/2943/2 "2024-02-23T09:44:13Z")

</div>

There is another API `imex(context, ImexMode::ImportSelfKeys, filename, None)` that you can use. This is what Delta Chat actually uses.

`store_self_keypair` should probably be made private.

---

<div class="post-metadata">

**Author:** ![Ivan](https://forum.delta.chat/user_avatar/forum.delta.chat/ivan/32/1822_2.png) [@Ivan](https://forum.delta.chat/u/Ivan)\
**Post date:** [February 23, 2024, 9:45am UTC](https://forum.delta.chat/t/cannot-import-pgp-keys-from-rust-api/2943/3 "2024-02-23T09:45:36Z")

</div>

Thx, I’ll try that one.

---

<div class="post-metadata">

**Author:** ![Ivan](https://forum.delta.chat/user_avatar/forum.delta.chat/ivan/32/1822_2.png) [@Ivan](https://forum.delta.chat/u/Ivan)\
**Post date:** [February 23, 2024, 9:47am UTC](https://forum.delta.chat/t/cannot-import-pgp-keys-from-rust-api/2943/4 "2024-02-23T09:47:06Z")

</div>

That was fast, BTW 😃

---

<div class="post-metadata">

**Author:** ![link2xt](https://forum.delta.chat/letter_avatar_proxy/v4/letter/l/ee7513/32.png) [@link2xt](https://forum.delta.chat/u/link2xt)\
**Post date:** [February 23, 2024, 9:47am UTC](https://forum.delta.chat/t/cannot-import-pgp-keys-from-rust-api/2943/5 "2024-02-23T09:47:18Z")

</div>

There is also [preconfigure\_keypair in deltachat::key - Rust](https://rs.delta.chat/deltachat/key/fn.preconfigure_keypair.html) which takes keys from memory, but it is not used by Delta Chat itself outside of the test suite, so more likely to be changed or removed in the future.

---

<div class="post-metadata">

**Author:** ![Ivan](https://forum.delta.chat/user_avatar/forum.delta.chat/ivan/32/1822_2.png) [@Ivan](https://forum.delta.chat/u/Ivan)\
**Post date:** [February 23, 2024, 11:36am UTC](https://forum.delta.chat/t/cannot-import-pgp-keys-from-rust-api/2943/6 "2024-02-23T11:36:16Z")

</div>

Yeah, I saw that one, but since it says in the docs that it can only be used in tests I reached the same conclusion 👍.

---

<div class="post-metadata">

**Author:** ![r10s](https://forum.delta.chat/user_avatar/forum.delta.chat/r10s/32/1513_2.png) [@r10s](https://forum.delta.chat/u/r10s)\
**Post date:** [February 21, 2026, 11:33am UTC](https://forum.delta.chat/t/cannot-import-pgp-keys-from-rust-api/2943/7 "2026-02-21T11:33:25Z")

</div>


