Skip to content

Refactor signatures#457

Merged
jonesmarvin8 merged 11 commits intomainfrom
marvin/signature-bip340-fixes
Apr 30, 2026
Merged

Refactor signatures#457
jonesmarvin8 merged 11 commits intomainfrom
marvin/signature-bip340-fixes

Conversation

@jonesmarvin8
Copy link
Copy Markdown
Collaborator

@jonesmarvin8 jonesmarvin8 commented Apr 24, 2026

🎯 Purpose

Refactor signatures for compatibility with Keycard. Both Keycard and LEE are BIP-340 compliant; however, the proposal was updated in 2022. Keycard is pre-2022 BIP-340 and LEE (currently) is post-2022. Post 2022 allowed for signatures to sign messages of variable length.

In this PR, we pre-hash messages before signing. Thus, enforcing 32-byte length for messages.

This PR updates how messages are signed. This induces a breaking change to LEE.

  • Changes to Signature breaks verification of previous transactions. Thus, current state from history cannot be verified without introducing versions (for Signature).
    • Mitigation: Generate a signature based on current testnet state, and re-initialize genesis block based on thee current state.
  • This does not affect spendability or retrievability of public accounts. Public accounts are retrieved from the sequencer, and new transactions (using this PR) will generate and verify signatures based on the logic included in this PR.

⚙️ Approach

  • Introduce functions for Message (public and privacy version) for to hash a message (hash_message()).
  • Update Signature::new logic to only accept [u8;32] message.
  • Signature::new_with_aux_rand updated to sign_prehash_with_rand
  • Comment out varied length test vectors for BIP-340 added in 2022.

🧪 How to Test

Refactoring. All previous tests still work (except the test vectors noted above)

🔗 Dependencies

N/A

🔜 Future Work

None.

📋 PR Completion Checklist

Mark only completed items. A complete PR should have all boxes ticked.

  • Complete PR description
  • Implement the core functionality
  • Add/update tests
  • Add/update documentation and inline comments

Comment thread nssa/src/privacy_preserving_transaction/message.rs Outdated
Comment thread nssa/src/signature/mod.rs
Comment thread nssa/src/signature/mod.rs
Comment thread nssa/src/signature/bip340_test_vectors.rs
Comment thread nssa/src/signature/mod.rs
Comment thread nssa/src/signature/mod.rs Outdated
Comment thread nssa/src/public_transaction/message.rs Outdated
@jonesmarvin8 jonesmarvin8 requested a review from moudyellaz April 28, 2026 22:13
Copy link
Copy Markdown
Collaborator

@moudyellaz moudyellaz left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for addressing my comments

Copy link
Copy Markdown
Collaborator

@schouhy schouhy left a comment

Choose a reason for hiding this comment

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

Thanks LGTM! Left some minor comments

Comment thread nssa/src/privacy_preserving_transaction/message.rs Outdated
Comment thread nssa/src/public_transaction/message.rs Outdated
Comment thread nssa/src/privacy_preserving_transaction/message.rs Outdated
Comment thread nssa/src/signature/mod.rs
Comment thread common/src/block.rs
@jonesmarvin8 jonesmarvin8 merged commit f37454e into main Apr 30, 2026
12 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants