Skip to content

Add incremental support for malachite#714

Draft
Rigidity wants to merge 1 commit intomainfrom
malachite
Draft

Add incremental support for malachite#714
Rigidity wants to merge 1 commit intomainfrom
malachite

Conversation

@Rigidity
Copy link
Contributor

@Rigidity Rigidity commented Feb 26, 2026

Note

Medium Risk
Introduces a second bigint backend and routes + through it, which may subtly change arithmetic behavior/perf and increases dependency surface; core allocator number encoding is also refactored but kept logically equivalent.

Overview
Adds malachite-bigint (and transitive deps) to the workspace and exposes a new Malachite bigint type plus malachite_number_from_u8 conversion helper.

Extends Allocator with new_malachite_number() and malachite_number() and refactors number allocation to share small-int detection and atom creation from signed-byte buffers.

Updates the + operator implementation (op_add) to accumulate using Malachite and allocate the result via the new allocator path; includes minor test expectation tweaks where an empty vec literal is asserted.

Written by Cursor Bugbot for commit 0e5018b. This will update automatically on new commits. Configure here.

@Rigidity Rigidity marked this pull request as draft February 26, 2026 23:01
@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​malachite-bigint@​0.9.11001009310070

View full report

@socket-security
Copy link

Caution

Review the following alerts detected in dependencies.

According to your organization's Security Policy, you must resolve all "Block" alerts before proceeding. It is recommended to resolve "Warn" alerts too. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Block Medium
Install-time scripts: cargo libm

Install script: Package overview

Source: undefined

From: ?cargo/malachite-bigint@0.9.1cargo/libm@0.2.16

ℹ Read more on: This package | This alert | What is an install script?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore cargo/libm@0.2.16. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Medium
Install-time scripts: cargo malachite-nz

Install script: Package overview

Source: undefined

From: ?cargo/malachite-bigint@0.9.1cargo/malachite-nz@0.9.1

ℹ Read more on: This package | This alert | What is an install script?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore cargo/malachite-nz@0.9.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Medium
Install-time scripts: cargo paste

Install script: Package overview

Source: undefined

From: ?cargo/malachite-bigint@0.9.1cargo/paste@1.0.15

ℹ Read more on: This package | This alert | What is an install script?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore cargo/paste@1.0.15. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Medium
Native binaries present: cargo libm

Location: Package overview

From: ?cargo/malachite-bigint@0.9.1cargo/libm@0.2.16

ℹ Read more on: This package | This alert | Why is native code a concern?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Verify that the inclusion of native code is expected and necessary for this package's functionality. If it is unnecessary or unexpected, consider using alternative packages without native code to mitigate potential risks.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore cargo/libm@0.2.16. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Medium
Native binaries present: cargo malachite-nz

Location: Package overview

From: ?cargo/malachite-bigint@0.9.1cargo/malachite-nz@0.9.1

ℹ Read more on: This package | This alert | Why is native code a concern?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Verify that the inclusion of native code is expected and necessary for this package's functionality. If it is unnecessary or unexpected, consider using alternative packages without native code to mitigate potential risks.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore cargo/malachite-nz@0.9.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Medium
Native binaries present: cargo paste

Location: Package overview

From: ?cargo/malachite-bigint@0.9.1cargo/paste@1.0.15

ℹ Read more on: This package | This alert | Why is native code a concern?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Verify that the inclusion of native code is expected and necessary for this package's functionality. If it is unnecessary or unexpected, consider using alternative packages without native code to mitigate potential risks.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore cargo/paste@1.0.15. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

panic!("number() called on pair");
}
}
}
Copy link

Choose a reason for hiding this comment

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

Unused public malachite_number method on Allocator

Low Severity

The newly added pub fn malachite_number on Allocator has no callers anywhere in the codebase. A grep for .malachite_number( returns zero matches. While new_malachite_number is called from op_add and malachite_number_from_u8 is used in more_ops.rs, the reader counterpart malachite_number is dead code.

Fix in Cursor Fix in Web

let bytes = v.to_signed_bytes_be();

self.new_atom_from_bigint_bytes(bytes.as_slice())
}
Copy link

Choose a reason for hiding this comment

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

Duplicated new_number and new_malachite_number implementations

Low Severity

new_malachite_number is an exact copy of new_number with only the parameter type changed. Similarly, malachite_number_from_u8 duplicates number_from_u8, and malachite_number duplicates number. Both Number and Malachite already share ToPrimitive (used in new_small_number_from_bigint); a similar trait-based approach for to_signed_bytes_be/from_signed_bytes_be could unify these three pairs of functions.

Additional Locations (2)

Fix in Cursor Fix in Web

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.

1 participant