Skip to content

feat: add cadence script signature#853

Merged
jaymengxy merged 3 commits intodevelopfrom
x_sign
Apr 24, 2025
Merged

feat: add cadence script signature#853
jaymengxy merged 3 commits intodevelopfrom
x_sign

Conversation

@jaymengxy
Copy link
Copy Markdown
Contributor

Related Issue

Closes #777

Summary of Changes

Need Regression Testing

  • Yes
  • No

Risk Assessment

  • Low
  • Medium
  • High

Additional Notes

Screenshots (if applicable)

@jaymengxy jaymengxy added this to the Release 2.8.3 milestone Apr 24, 2025
@jaymengxy jaymengxy requested a review from lmcmz April 24, 2025 02:39
@jaymengxy jaymengxy self-assigned this Apr 24, 2025
@jaymengxy jaymengxy requested a review from a team as a code owner April 24, 2025 02:39
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 24, 2025

PR Summary

Enhanced security by implementing signature verification for Cadence scripts. Added new functionality to verify script authenticity using NIST256P1 public key verification, with proper error handling and reporting. Updated API service to handle signature headers and implemented response body verification.

Changes

File Summary
app/build.gradle Added X_SIGNATURE_KEY build config field to store the signature verification key from properties
app/src/main/assets/config/cadence_api.json Modified configuration file (no visible changes in diff)
app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt Added signature verification using wallet.core for Cadence scripts. Implemented verifySignature method using NIST256P1 public key, added error handling and reporting for signature verification failures.
app/src/main/java/com/flowfoundation/wallet/network/ApiService.kt Modified getCadenceScript to getCadenceScriptWithHeaders returning Response<ResponseBody> to access signature headers
app/src/main/java/com/flowfoundation/wallet/utils/error/Error.kt Added new error types for signature verification: EMPTY_SCRIPT_SIGNATURE, INVALID_SCRIPT_SIGNATURE, SIGNATURE_VERIFICATION_ERROR, DECODE_SCRIPT_FAILED
gradle.properties Increased version code from 270 to 271
key.properties.example Added X_SIGNATURE_KEY to the example properties file

autogenerated by presubmit.ai

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • 00baaf6: feat: add cadence script signature
Files Processed (8)
  • app/build.gradle (1 hunk)
  • app/src/main/assets/config/cadence_api.json (0 hunks)
  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt (5 hunks)
  • app/src/main/java/com/flowfoundation/wallet/network/ApiService.kt (2 hunks)
  • app/src/main/java/com/flowfoundation/wallet/utils/error/Error.kt (1 hunk)
  • app/src/test/java/com/flowfoundation/wallet/utils/SignatureVerificationTest.kt (1 hunk)
  • gradle.properties (1 hunk)
  • key.properties.example (1 hunk)
Actionable Comments (2)
  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt [76-77]

    best practice: "Response body is not properly closed after use"

  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt [141-144]

    possible bug: "Missing validation for signature byte length"

Skipped Comments (1)
  • app/src/test/java/com/flowfoundation/wallet/utils/SignatureVerificationTest.kt [68-68]

    maintainability: "Non-ASCII character in error message"

Comment thread app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt Outdated
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • f50b581: fix: close response body
Files Processed (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt (5 hunks)
Actionable Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt [130-130]

    security: "Potential security risk in key handling"

Skipped Comments (2)
  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt [160-163]

    best practice: "Avoid printing stack traces to logs"

  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt [91-97]

    enhancement: "Improve error handling resilience"

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • b6e19b2: fix: close response body
Files Processed (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt (5 hunks)
Actionable Comments (2)
  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt [161-162]

    security: "Avoid logging sensitive error details"

  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt [94-94]

    security: "Avoid exposing error details in logs"

Skipped Comments (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt [127-127]

    security: "Specify message digest encoding mode"

Comment thread app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt Outdated
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • fe993cc: fix: use wallet core verify
Files Processed (1)
  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt (5 hunks)
Actionable Comments (3)
  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt [71-76]

    possible bug: "Missing null check for raw response"

  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt [119-123]

    security: "Potential timing attack vulnerability in signature verification"

  • app/src/main/java/com/flowfoundation/wallet/manager/cadence/CadenceApiManager.kt [97-102]

    security: "Missing data validation before parsing"

Skipped Comments (0)

@jaymengxy jaymengxy requested a review from lmcmz April 24, 2025 05:12
@jaymengxy jaymengxy merged commit f05757d into develop Apr 24, 2025
3 checks passed
@jaymengxy jaymengxy deleted the x_sign branch April 24, 2025 05:31
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.

Add X-Signature verification on script API

2 participants