Add BigInt utility functions for number theory operations#2205
Open
p-leriche wants to merge 4 commits intogchq:masterfrom
Open
Add BigInt utility functions for number theory operations#2205p-leriche wants to merge 4 commits intogchq:masterfrom
p-leriche wants to merge 4 commits intogchq:masterfrom
Conversation
This was referenced Feb 25, 2026
This was referenced Feb 26, 2026
GCHQDeveloper581
requested changes
Mar 2, 2026
Contributor
GCHQDeveloper581
left a comment
There was a problem hiding this comment.
I've added some very basic tests (since this represented a new "type" of testing and I wanted to establish the file structure).
Please could you add to these to more completely test the desired functionality.
Contributor
|
I appreciate that there are tests for the Operations you've added in separate PRs and these will to some extent overlap. However I think it best practice to have unit tests to test these library functions, and then test the higher level functionality of the Operation(s) in their tests. (this may mean moving some of the detailed testing from the Operations into the unit tests). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds utility functions for working with BigInt values in number theory operations. These utilities provide a foundation for upcoming cryptographic and mathematical operations.
Changes
src/core/lib/BigIntUtils.mjswith:parseBigInt()- Parse decimal or hexadecimal (0x...) strings to BigIntegcd()- Extended Euclidean Algorithm (iterative implementation, no recursion limits)Features
Testing
npm run buildRelated
This is a dependency for PRs:
Related PRs:
This collection of 5 new operations together with this libray of supporting functions has been created as a teaching resource for Diffie-Hellman and RSA, hopefully as an extension activity for CyberFirst Girls' competitors. (Unfortunately, my last years groups have all dispersed - but there's always another year.) After a frantic burst of activity, no more related PRs are currently envisaged.
A build containing all 5 new operations is online at https://blueskylark.org/CyberFirst/CyberChef