fair-workflows / nanopub

Python client for searching, publishing and modifying nanopublications.
https://fair-workflows.github.io/nanopub
Apache License 2.0
22 stars 7 forks source link

`np setup` fails to parse newly-generated keypair #166

Open rokroskar opened 4 months ago

rokroskar commented 4 months ago

Hello! 👋

I've tried creating a keypair a few different ways (openssl genrsa and using the pycryptodome library) - I can read the keys with pycryptodome but the np setup process fails with:

 .../Projects/nanopubs/.venv/lib/python3.10/site-packages/Crypto/PublicKey/RSA.py:853 in   │
│ import_key                                                                                       │
│                                                                                                  │
│   850 │   │   # This is probably a DER encoded key                                               │
│   851 │   │   return _import_keyDER(extern_key, passphrase)                                      │
│   852 │                                                                                          │
│ ❱ 853 │   raise ValueError("RSA key format is not supported")                                    │
│   854                                                                                            │
│   855                                                                                            │
│   856 # Backward compatibility                                                                   │
│ 

What are the requirements for the keys? Do you have some instructions on how to generate a keypair that works?

dennisvang commented 4 months ago

... Do you have some instructions on how to generate a keypair that works?

@rokroskar Looks like the following works:

np setup --newkeys

Also see np setup --help for more options.

Would be nice if this were mentioned in the setup instructions...

https://github.com/fair-workflows/nanopub/blob/2072905fe79b779d04e799c29344a54cc14b8d9b/docs/getting-started/setup.md?plain=1#L22-L26

For reference, here's how the keys are created:

https://github.com/fair-workflows/nanopub/blob/2072905fe79b779d04e799c29344a54cc14b8d9b/nanopub/profile.py#L226-L231