Nanopublication from code via Nanodash

8 views
Skip to first unread message

Anatoly Scherbakov

unread,
Mar 16, 2025, 1:23:09 PMMar 16
to Nanopublications
Hello everyone,

I have already published my first nanopublication using Nanodash, and it got approved (thanks Tobias!)

That worked well; now, I am trying to understand how I could do it differently: using my code editor, write a file (say, in JSON-LD) and publish it.

For instance, I have this thing resembling my nanopub mentioned above:

{
  "@context": {
    "@import": "https://json-ld.org/contexts/dollar-convenience.jsonld",
    "owl": "http://www.w3.org/2002/07/owl#",
    "dc": "http://purl.org/dc/terms/",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "fip": "https://w3id.org/fair/fip/terms/"
  },
  "$id": "https://json-ld.github.io/yaml-ld/spec/",
  "$type": [
    "owl:NamedIndividual",
    "fip:Knowledge-representation-language"
  ],
  "dc:description": "A set of conventions built on top of YAML, which outlines how to serialize\nLinked Data as YAML based on JSON-LD syntax, semantics, and APIs.",
  "rdfs:label": "YAML-LD"
}


I'd like to turn this into an Assertion, I would like a tool to automatically add PubInfo for me, sign this and publish.

- I am trying nanopub-rs tool © Vincent Emonet, I do not think I am using it properly though — so I asked a few stupid questions in its repo;
- But anyway, even if I can do it, I will use a new RSA keypair that I generated locally,

and I already have an approved keypair stored by Nanodash. I don't think I can download the private key.

Perhaps there is an API endpoint supported by Nanodash where I could submit a document and thus get it published?

Or am I approaching this wrong?

Thanks!
Anatoly

Anatoly Scherbakov

unread,
Mar 22, 2025, 1:23:20 PMMar 22
to Nanopublications
…to continue,

I was able to publish my file using nanopub-rs (thanks to Vincent's help) but it is designated as having an invalid signature: https://nanodash.knowledgepixels.com/explore?58&id=RAZIrVNUTUEnIHgcKXzFUMRTLQKnMGIQh-xEvbbgUBfY4

I assume that's because I had not declared my public key.

I tried to declare it but I haven't found an example about how to do that.

- Not on Examples page https://nanopub.net/docs/examples
- Not found anything in Guidelines https://nanopub.net/guidelines/working_draft/

I have a nanopub in Nanodash that was created off of a template and declares my public key managed by Nanodash but it puzzles me how to de-sign it.|

Will be grateful for a kick towards the right direction.

My test declaration I was trying out is this:

@prefix : <http://purl.org/nanopub/temp/keyDeclaration#> .
@prefix np: <http://www.nanopub.org/nschema#> .
@prefix npx: <http://purl.org/nanopub/x/> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix orcid: <https://orcid.org/> .

:Head {
: a np:Nanopublication ;
np:hasAssertion :assertion ;
np:hasProvenance :provenance ;
np:hasPublicationInfo :pubinfo .
}

:assertion {
orcid:0009-0001-8740-4213 npx:hasPublicKey "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCn6rJWI3NmhXLeWDIE+uuqZu2tPbDJ9ARhL5DFPmQahm7aFQ2hCtduWhucML5gBj4bQl/+PsG4bcjz2cFQEgEqCiV7WoK6d7zlm+ru3UbOK+8J1Nbd84zvSjtg/SCo4VOxiu2tgMZR1Ys7S+sm/9GB5jBuZUy2GQxQpKiuK+TDfa4vCZyUt7P6FlyTE7ELNsgeJe4Be+V1lFSjEsmArE166zUOYPMdbpar/r23bHRGr98UbfKUsqHJCVc9YWWzuFwL3Nbuj9f9fZi1DjFJsJb0euEb47AMfA3sadWgnDPgaQ18JDMHLVLuwB9isrTNUn+XXGa2kI4papVPdnmntRuJiZ2ijV8V6b50Wd8uqu7Evy6lx97cEDVQPmuf69AhuBxi7jzczNHRy06xnN8uUb2wPxua9vzlfpBAsE+qLfzlMdbaoqUTJRf+WrsSi8/tReCymVgKhkd66Zd5e43oYNmXvtEK7ITFnERh/bOOb9flTa0F+HsfNGHQj25TJ/GGinDvhToYZ+LHHzG1sTAfVfMDoVM8y/a6sU+ELZeoWh3HxXuhn4y2FAD63i10L+94gbZEwOqvqgvr8q60WLa8U1c+hMSpurFCappp31qjAp2blTzJFPpaL5v4E+ZkTu6CTeC4Vo4rErlQBj6zEwbRuB9w+7tFLvsRGs2tXc6StHJIRQ== ana...@iolanta.tech" .
}

:provenance {
:assertion prov:wasAttributedTo orcid:0009-0001-8740-4213 .
}

:pubinfo {
: prov:wasAttributedTo orcid:0009-0001-8740-4213 .
}


Thanks!
Anatoly

Tobias Kuhn

unread,
Mar 24, 2025, 3:37:56 AMMar 24
to Anatoly Scherbakov, Nanopublications
Hi Anatoly,

No, this has nothing to do with you declaring the public key in an intro
nanopub, but the public key in your nanopublication is not properly
formatted:

> "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCn6rJWI3NmhXLeWDIE+uuqZu2tPbDJ9ARhL5DFPmQahm7aFQ2hCtduWhucML5gBj4bQl/+PsG4bcjz2cFQEgEqCiV7WoK6d7zlm+ru3UbOK+8J1Nbd84zvSjtg/SCo4VOxiu2tgMZR1Ys7S+sm/9GB5jBuZUy2GQxQpKiuK+TDfa4vCZyUt7P6FlyTE7ELNsgeJe4Be+V1lFSjEsmArE166zUOYPMdbpar/r23bHRGr98UbfKUsqHJCVc9YWWzuFwL3Nbuj9f9fZi1DjFJsJb0euEb47AMfA3sadWgnDPgaQ18JDMHLVLuwB9isrTNUn+XXGa2kI4papVPdnmntRuJiZ2ijV8V6b50Wd8uqu7Evy6lx97cEDVQPmuf69AhuBxi7jzczNHRy06xnN8uUb2wPxua9vzlfpBAsE+qLfzlMdbaoqUTJRf+WrsSi8/tReCymVgKhkd66Zd5e43oYNmXvtEK7ITFnERh/bOOb9flTa0F+HsfNGHQj25TJ/GGinDvhToYZ+LHHzG1sTAfVfMDoVM8y/a6sU+ELZeoWh3HxXuhn4y2FAD63i10L+94gbZEwOqvqgvr8q60WLa8U1c+hMSpurFCappp31qjAp2blTzJFPpaL5v4E+ZkTu6CTeC4Vo4rErlQBj6zEwbRuB9w+7tFLvsRGs2tXc6StHJIRQ== ana...@iolanta.tech"

It should be just the key characters without "ssh-rsa " and "
ana...@iolanta.tech".

You probably should make sure you feed in your public key without these
extra characters.

Regards,
Tobias
> convenience.jsonld <https://json-ld.org/contexts/dollar-
> convenience.jsonld>",
>     "owl": "http://www.w3.org/2002/07/owl# <http://
> www.w3.org/2002/07/owl#>",
>     "dc": "http://purl.org/dc/terms/ <http://purl.org/dc/terms/>",
>     "rdfs": "http://www.w3.org/2000/01/rdf-schema# <http://
> www.w3.org/2000/01/rdf-schema#>",
>     "fip": "https://w3id.org/fair/fip/terms/ <https://w3id.org/
> fair/fip/terms/>"
>   },
>   "$id": "https://json-ld.github.io/yaml-ld/spec/ <https://json-
> ld.github.io/yaml-ld/spec/>",
>   "$type": [
>     "owl:NamedIndividual",
>     "fip:Knowledge-representation-language"
>   ],
>   "dc:description": "A set of conventions built on top of YAML,
> which outlines how to serialize\nLinked Data as YAML based on JSON-
> LD syntax, semantics, and APIs.",
>   "rdfs:label": "YAML-LD"
> }
>
> I'd like to turn this into an Assertion, I would like a tool to
> automatically add PubInfo for me, sign this and publish.
>
> - I am trying nanopub-rs tool © Vincent Emonet, I do not think I am
> using it properly though — so I asked a few stupid questions in its
> repo;
> - But anyway, even if I can do it, I will use a new RSA keypair that
> I generated locally,
>
> and I already have an approved keypair stored by Nanodash. I don't
> think I can download the private key.
>
> Perhaps there is an API endpoint supported by Nanodash where I could
> submit a document and thus get it published?
>
> Or am I approaching this wrong?
>
> Thanks!
> Anatoly
>
> --
> You received this message because you are subscribed to the Google
> Groups "Nanopublications" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to nanopub-user...@googlegroups.com <mailto:nanopub-
> users+un...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/nanopub-
> users/19b7f2dc-7977-4999-a8e9-30c3d56aed60n%40googlegroups.com <https://
> groups.google.com/d/msgid/nanopub-users/19b7f2dc-7977-4999-
> a8e9-30c3d56aed60n%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout <https://
> groups.google.com/d/optout>.

Anatoly Scherbakov

unread,
Mar 24, 2025, 2:50:03 PMMar 24
to Nanopublications
Thanks Tobias,

I originally generated the key using the following command:

ssh-keygen -t rsa -m PKCS8 -b 4096 -f ~/.nanopub/id_rsa -C "…"

I have removed the prefix and the suffix, and now I have this: https://nanodash.knowledgepixels.com/explore?0&id=RA3DKF6sGQRwUSfnDZkpKT6L-FmyE0n3EQYmpdNFy0bcQ — which still shows "Invalid signature" though.

- The signed document is attached to this message if you have a moment to glance over it.
- If you have to edit the key after generating it, there may be a piece of documentation somewhere regarding actions like this which I do not know about?

Thanks,
Anatoly
signed.np.trig

Vincent Emonet

unread,
Mar 25, 2025, 7:17:47 AMMar 25
to Anatoly Scherbakov, Nanopublications
Hi Anatoly and Tobias,

The additional `ssh-rsa [...]== em...@email.com` is caused by nanopub-rs that was taking directly the public key found in the `.nanopub/id_rsa.pub` file without doing changes

And there are various ways to encode a public keys:
  • SSH-keygen produces SSH public key format: ssh-rsa [base64-encoded data] [comment]
  • The RSA crate I use produces PKCS#8/X.509 SubjectPublicKeyInfo format

If I understand well we should use the PKCS8 format?

I can easily fix this by ignoring the public key in .nanopub/id_rsa, and generate the public key from the private key directly. I already do this when no public key is provided anyway. This way we know it's always in the right format


Best,

Vincent



To unsubscribe from this group and stop receiving emails from it, send an email to nanopub-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/nanopub-users/78f4d800-7195-4ab9-b47c-df314bb24fb0n%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages