Skip to content

Update NUT-29 signature message to include mint pubkey and timestamp#363

Open
a1denvalu3 wants to merge 3 commits into
cashubtc:get-quotes-by-pubkeysfrom
a1denvalu3:update-sig-nut-29
Open

Update NUT-29 signature message to include mint pubkey and timestamp#363
a1denvalu3 wants to merge 3 commits into
cashubtc:get-quotes-by-pubkeysfrom
a1denvalu3:update-sig-nut-29

Conversation

@a1denvalu3
Copy link
Copy Markdown
Contributor

Summary

  • Update msg_to_sign for the pubkey quote lookup to include a timestamp and the mint's pubkey
  • Add test vectors for NUT-29 request signature verification

@a1denvalu3
Copy link
Copy Markdown
Contributor Author

This PR includes updates to the signature scheme and test vectors, intended to be merged into the branch for #341.

Copy link
Copy Markdown

@TheMhv TheMhv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's better approach to fix reply attack on #341

Concept ACK 2fd727a

Comment thread xx.md
"pubkeys": <Array[str]>,
"pubkey_signatures": <Array[str]>
"pubkey_signatures": <Array[str]>,
"timestamp": <int>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a hard rule about acceptable timestamp age - eg, mint will reject any timestamp older than xx minutes, and any timestamp greater than current epoch

Resolves the issue where a signed timestamp had no required staleness window, meaning a signature could theoretically be reused indefinitely against the mint. The mint must now reject requests with timestamps that deviate by more than 60 seconds from its current time.
Comment thread xx.md Outdated
The wallet **MUST** provide a valid signature in `pubkey_signatures` for each public key in `pubkeys` with the corresponding private key in the same order as the `pubkeys` array. The message to sign is the byte representation of the public key.
The wallet **MUST** provide a valid signature in `pubkey_signatures` for each public key in `pubkeys` with the corresponding private key in the same order as the `pubkeys` array. The message to sign is the SHA-256 hash of the concatenated string `pubkey || timestamp || mint_pubkey`. Where `||` denotes concatenation, `pubkey` is the hex-encoded public key, `timestamp` is the UTF-8 string representation of the Unix timestamp, and `mint_pubkey` is the hex-encoded public key of the mint as defined in [NUT-06][06].

The mint **MUST** evaluate the `timestamp` field and reject the request if it is more than 60 seconds in the past or future.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 60 seconds may be too strict. We've had reports of mints having the time in the mint info off by 15 minutes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With NTP there should be little reason for clocks to be that far out really. I think maybe up to 300 seconds is more reasonable - still a 10 minute window overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

4 participants