# Bad return code -1 when running client.get\_public\_key

**URL:** <https://community.zymbit.com/t/bad-return-code-1-when-running-client-get-public-key/1424>\
**Category:** HSM6\
**Created:** [May 12, 2022, 1:47pm UTC](https://community.zymbit.com/t/bad-return-code-1-when-running-client-get-public-key/1424 "2022-05-12T13:47:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shanet](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@shanet](https://community.zymbit.com/u/shanet)\
**Post date:** [May 12, 2022, 1:47pm UTC](https://community.zymbit.com/t/bad-return-code-1-when-running-client-get-public-key/1424/1 "2022-05-12T13:47:16Z")

</div>

Hello! I’m using a HSM6 and hoping to follow the digital wallet tutorial, but I’m running into issues

Setup:  
Raspberry Pi 4 running Bullseye  
HSM6

I followed the getting started guide, most things seem OK, the LED blinks every three seconds and so on.

When I run `zk_crypto_test.py` it passes, but when I run `zk_app_utils_test.py` it fails with

```auto
Testing get_ecdsa_public_key()...
Traceback (most recent call last):
  File "/home/pi/zk_app_utils_test.py", line 45, in <module>
    pk = zymkey.client.get_ecdsa_public_key()
  File "/usr/local/lib/python3.9/dist-packages/zymkey/ __init__.py", line 978, in get_ecdsa_public_key
    raise AssertionError("bad return code %d" % ret)
AssertionError: bad return code -1

```

After some digging, I found I can reproduce this with a minimal example

```auto
import zymkey
zymkey_pub_key_slot = zymkey.client.gen_key_pair("secp256k1")
zymkey.client.get_ecdsa_public_key(zymkey_pub_key_slot)

```

Any ideas? I tried both install scripts from “Getting Started” but no joy.

---

<div class="post-metadata">

**Author:** ![shanet](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@shanet](https://community.zymbit.com/u/shanet)\
**Post date:** [May 12, 2022, 1:48pm UTC](https://community.zymbit.com/t/bad-return-code-1-when-running-client-get-public-key/1424/2 "2022-05-12T13:48:46Z")

</div>

I get the same issue with `get_public_key()` as `get_ecdsa_public_key()`

---

<div class="post-metadata">

**Author:** ![Bob\_of\_Zymbit](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Bob\_of\_Zymbit](https://community.zymbit.com/u/Bob_of_Zymbit)\
**Post date:** [May 12, 2022, 4:43pm UTC](https://community.zymbit.com/t/bad-return-code-1-when-running-client-get-public-key/1424/3 "2022-05-12T16:43:34Z")

</div>

I’m assuming your LED is still blinking once every three seconds. Can you print the slot number and slot allocation? Try this:

```auto
pi@raspberrypi $ python3
Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import zymkey
>>> slot = zymkey.client.gen_key_pair("secp256k1")
>>> zymkey.client.get_public_key(slot)
bytearray(b"\xf0\x06h\xd8\xea\xc6.\x91\x7f\xa6\x93^<\xdeyx\xe6\xa3\xaf|\xf9\xcb\xfc:\xcbj-K\x8b\xb2\x1f\xb6MC\xc8:\xee\x82gk\xf7l\xc1\x07\xde)$\xdeq\xc8c\x16qa@\xecj\xc8\x00\x02\xe9+\'$")
>>> print(slot)
19
>>> zymkey.client.get_slot_alloc_list()
([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19], 528)
>>>

```

---

<div class="post-metadata">

**Author:** ![Bob\_of\_Zymbit](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Bob\_of\_Zymbit](https://community.zymbit.com/u/Bob_of_Zymbit)\
**Post date:** [May 12, 2022, 6:30pm UTC](https://community.zymbit.com/t/bad-return-code-1-when-running-client-get-public-key/1424/4 "2022-05-12T18:30:45Z")

</div>

@shanet - Can you also verify your firmware revision for me?

`python3 -c "import zymkey; print(zymkey.client.get_firmware_version())"`

---

<div class="post-metadata">

**Author:** ![shanet](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@shanet](https://community.zymbit.com/u/shanet)\
**Post date:** [May 12, 2022, 9:52pm UTC](https://community.zymbit.com/t/bad-return-code-1-when-running-client-get-public-key/1424/5 "2022-05-12T21:52:15Z")

</div>

> I’m assuming your LED is still blinking once every three seconds.

It is indeed!

> Can you print the slot number and slot allocation? Try this:

I hope this is useful:

```auto
>>> slot = zymkey.client.gen_key_pair("secp256k1")
>>> zymkey.client.get_public_key(slot)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/zymkey/ __init__.py", line 1012, in get_public_key
    raise AssertionError("bad return code %d" % ret)
AssertionError: bad return code -1
>>> print(slot)
23
>>> zymkey.client.get_slot_alloc_list()
([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 22, 23], 528)
>>> 

```

> @shanet - Can you also verify your firmware revision for me?

```auto
06.00.16Rel

```

This is interesting - I wonder if it needs to be / can be updated?

---

<div class="post-metadata">

**Author:** ![Bob\_of\_Zymbit](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Bob\_of\_Zymbit](https://community.zymbit.com/u/Bob_of_Zymbit)\
**Post date:** [May 12, 2022, 10:32pm UTC](https://community.zymbit.com/t/bad-return-code-1-when-running-client-get-public-key/1424/6 "2022-05-12T22:32:08Z")

</div>

@shanet That is indeed a very early unit. It is not field upgradeable. We’ll send you an up-to-date replacement unit.

---

<div class="post-metadata">

**Author:** ![shanet](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@shanet](https://community.zymbit.com/u/shanet)\
**Post date:** [May 13, 2022, 9:54am UTC](https://community.zymbit.com/t/bad-return-code-1-when-running-client-get-public-key/1424/7 "2022-05-13T09:54:26Z")

</div>

Thanks very much @Bob_of_Zymbit !
