pyca / pyca/pynacl

handling signed messages?

Open
#151 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.2k
Forks
267
Avg merge
42m
Merged PRs (30d)
2

Description

Hi,

Thanks for the awesome library. This is not a bug report so much as an assistance request.

When I sign a message as per the doc, the "signed" result is a string, both:

isinstance(signed, str)

and

isinstance(signed, nacl.signing.SignedMessage)

return true.

However I can't seem to encode the signed message like I can with all of the other provided objects.

When I attempt:

In [1]: import nacl.utils

In [2]: import nacl.signing

In [3]: signing_key = nacl.signing.SigningKey.generate()

In [4]: signed = signing_key.sign(b"abc123")

In [5]: signed.encode(encoder = nacl.encoding.HexEncoder)

I get the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-c597ca2a169e> in <module>()
----> 1 signed.encode(encoder = nacl.encoding.HexEncoder)

TypeError: 'encoder' is an invalid keyword argument for this function

So I used base64.b64encode to encode the signed message for transport, however once decoded on the other side I no longer have access to the "signed.signature" and "signed.message" attributes.

In [11]: signed.message
Out[11]: 'abc123'

In [12]: encoded = base64.b64encode(signed)

In [13]: decoded = base64.b64decode(encoded)

In [14]: encoded.message
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-14-68a604c6014b> in <module>()
----> 1 encoded.message

AttributeError: 'str' object has no attribute 'message'

Do I have to parse the signed message myself?
Is there any way to cast the signed str back to nacl.signing.SignedMessage to programmatically retrieve signed.message?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the signing documentation and the nacl.signing.SignedMessage behavior described in the report. Determine whether the intended outcome is documentation guidance or a supported encode/decode API, then define the expected round-trip behavior and document or test it accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cryptography
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.