Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update default cryptographic algorithm in Wallet class methods #770

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ckeshava
Copy link
Collaborator

@ckeshava ckeshava commented Nov 8, 2024

High Level Overview of Change

This change is related to this PR: #748
I've addressed my comment (#748 (comment)) in the current PR.

@anissa-ripple @justinr1234 @dangell7 please review the changes in this PR

Context of Change

Use ed25519 as the default cryptographic algorithm in Wallet.from_secret_numbers method. This ensures consistency amongst all the methods of the Wallet class.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

Did you update CHANGELOG.md?

  • Yes
  • No, this change does not impact library users

Test Plan

Copy link
Contributor

coderabbitai bot commented Nov 8, 2024

Walkthrough

The pull request introduces several significant updates to the project. It adds the include_deleted parameter to the ledger_entry request and removes support for Python 3.7, establishing Python 3.8 as the new default version. The default cryptographic algorithm in the Wallet.from_secret_numbers method is updated to ED25519. Additionally, the changelog has been revised to document these changes and previous versions, including notable breaking changes and new features.

Changes

File Change Summary
CHANGELOG.md Updated to include include_deleted parameter, removed Python 3.7 support, updated default algorithm to ED25519, and documented previous versions.
tests/unit/asyn/wallet/test_main.py Modified expected algorithm in test cases from secp256k1 to ed25519 for specific test methods.
xrpl/wallet/main.py Updated comments, enhanced error handling in __init__, and changed default algorithm in from_secret_numbers method to ED25519.

Possibly related PRs

  • Add include_deleted param to ledger_entry API #721: This PR adds the include_deleted parameter to the ledger_entry API, which is directly related to the changes made in the main PR regarding the same parameter's addition in the CHANGELOG.md.
  • Update CHANGELOG.md #748: This PR updates the CHANGELOG.md to reflect the addition of the include_deleted parameter and the removal of Python 3.7 support, which aligns with the updates documented in the main PR.

Suggested reviewers

  • justinr1234

🐇 In the code, I hop and play,
New features bloom, bright as day!
With ED25519, we leap so high,
Python 3.8, we wave goodbye!
Changelog's clear, the path is bright,
Hopping forward, all feels right! 🌟


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9637590 and 5195623.

📒 Files selected for processing (1)
  • CHANGELOG.md (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
xrpl/wallet/main.py (1)

218-219: Enhance documentation with compatibility note.

While the added documentation link is valuable, consider adding a note about compatibility considerations when changing from the previous default (SECP256K1) to ED25519.

Consider updating the docstring to include:

                The default is ED25519. Docs:
                https://xrpl.org/docs/concepts/accounts/cryptographic-keys#ed25519-key-derivation
+               Note: If you're upgrading from a previous version that used SECP256K1 as
+               the default, ensure your code explicitly specifies the algorithm if
+               SECP256K1 is required.
CHANGELOG.md (1)

95-95: Remove empty line.

There's an unnecessary empty line with a dash that should be removed.

Apply this diff to remove the empty line:

-- 
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ea1174b and f582f99.

📒 Files selected for processing (3)
  • CHANGELOG.md (2 hunks)
  • tests/unit/asyn/wallet/test_main.py (1 hunks)
  • xrpl/wallet/main.py (4 hunks)
🔇 Additional comments (5)
xrpl/wallet/main.py (3)

72-74: LGTM: Clear and appropriate comment style.

The comment effectively emphasizes the security-critical nature of the seed value while using the appropriate comment style for an internal implementation detail.


91-91: LGTM: Well-structured error handling enhancement.

The error handling improvement properly chains exceptions and provides comprehensive context including the seed, algorithm, and original error message, which will greatly aid in debugging.


207-207: Verify impact of changing the default algorithm.

The change to ED25519 as default aligns with the PR objective, but we should verify the impact on existing code that relies on the default behavior.

Let's check for any direct usage of this method without explicit algorithm specification:

✅ Verification successful

Default algorithm change to ED25519 is safe to proceed

The codebase analysis shows that:

  • All direct usages of from_secret_numbers are in test files
  • Tests explicitly cover both algorithms (ED25519 and SECP256K1)
  • The change is properly documented in CHANGELOG.md
  • No production code relies on the default behavior

The change is well-tested and doesn't introduce breaking changes in existing code.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for calls to from_secret_numbers that might be affected
rg "from_secret_numbers\([^)]*\)" --type python

# Search for tests that might need updating
rg "test.*from_secret_numbers" --type python

Length of output: 158


Script:

#!/bin/bash
# Search for calls to from_secret_numbers without file type flag
rg "from_secret_numbers\([^)]*\)"

# Also search for test files containing from_secret_numbers
rg "test.*from_secret_numbers"

# Search for any imports or references to from_secret_numbers
rg "from_secret_numbers"

Length of output: 3037

CHANGELOG.md (1)

Line range hint 1-24: Verify categorization of the change.

The PR objectives describe this as a bug fix that ensures consistency across all methods within the Wallet class, following up on changes made in PR #748. However, it's currently categorized as a breaking change in the changelog. Since version 2.0.0 already established ED25519 as the default signing algorithm, this change appears to be fixing an inconsistency rather than introducing a breaking change.

Please verify if this should indeed be a breaking change or if it's completing the transition that was already announced in version 2.0.0.

Let's verify the changes made in PR #748:

🧰 Tools
🪛 Markdownlint

13-13: Punctuation: ':'
Trailing punctuation in heading

(MD026, no-trailing-punctuation)

tests/unit/asyn/wallet/test_main.py (1)

320-320: LGTM! Test changes correctly reflect the new default algorithm.

The test assertions have been updated to expect ed25519 as the default algorithm for both string and array inputs to Wallet.from_secret_numbers. This aligns with the PR objective to set ed25519 as the default cryptographic algorithm.

Let's verify that this change is consistent with other default algorithm tests in the codebase:

Also applies to: 325-325

✅ Verification successful

Let me verify the implementation of these test methods to ensure they all consistently validate the ed25519 default algorithm.


Changes are consistent with default algorithm tests across the codebase

The verification confirms that all test methods using default algorithm consistently validate ed25519 as the expected algorithm. This includes tests for all wallet creation methods: create(), from_seed(), from_secret(), from_entropy(), and from_secret_numbers(). The changes in lines 320 and 325 align perfectly with this consistent pattern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all default algorithm tests expect ed25519
# Test: Search for test methods using default algorithm. Expect: All should use ed25519.
rg -A 2 "test_.*using_default_algorithm" tests/

Length of output: 2295


Script:

#!/bin/bash
# Search for _test_wallet_values calls in test methods to verify expected algorithm
rg -B 2 "_test_wallet_values.*ed25519" tests/unit/asyn/wallet/test_main.py

Length of output: 1526

CHANGELOG.md Outdated Show resolved Hide resolved
ckeshava and others added 2 commits November 8, 2024 10:08
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
CHANGELOG.md (1)

96-96: Remove extra blank line.

There's an unnecessary blank line that should be removed to maintain consistent formatting.

### BREAKING CHANGE
- The default signing algorithm in the `Wallet` was changed from secp256k1 to ed25519
-

### Added:
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f582f99 and 9637590.

📒 Files selected for processing (2)
  • CHANGELOG.md (2 hunks)
  • xrpl/wallet/main.py (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • xrpl/wallet/main.py
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[uncategorized] ~16-~16: Possible missing preposition found.
Context: ...and use 3.8 as new default. ### Fixed - Ensure consistent use of ED25519 as the defaul...

(AI_HYDRA_LEO_MISSING_TO)

🔇 Additional comments (1)
CHANGELOG.md (1)

15-16: LGTM! The changelog entry is well-positioned and clearly written.

The entry correctly documents this change under the "Fixed" section, appropriately noting that this ensures consistency with the ED25519 default established in v2.0.0.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~16-~16: Possible missing preposition found.
Context: ...and use 3.8 as new default. ### Fixed - Ensure consistent use of ED25519 as the defaul...

(AI_HYDRA_LEO_MISSING_TO)

@ckeshava
Copy link
Collaborator Author

ckeshava commented Nov 8, 2024

Note to the reviewers: I've made an attempt to update the docs to better communicate these changes here: XRPLF/xrpl-dev-portal#2844

@mvadari
Copy link
Collaborator

mvadari commented Nov 8, 2024

This is a breaking change.

@justinr1234
Copy link
Collaborator

@ckeshava would need to put this into a major version release --- and move to the breaking change docs

@ckeshava
Copy link
Collaborator Author

@justinr1234 I've moved the update-message into the "Breaking Changes" section. There is already one other breaking change as well.

How do I indicate that the next release needs to be a major version upgrade? Since we are removing support for Python 3.7, I suspect we need to do a major version upgrade anyway.

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