Skip to content

chore: Add Integer abstraction#11723

Open
jfecher wants to merge 3 commits intomasterfrom
jf/add-integer
Open

chore: Add Integer abstraction#11723
jfecher wants to merge 3 commits intomasterfrom
jf/add-integer

Conversation

@jfecher
Copy link
Contributor

@jfecher jfecher commented Feb 27, 2026

Description

Problem

This is broken out from #11710

Summary

If we want to remove SignedField entirely we need a new way of representing "any kind of integer value." To do this, I've refactored the integer variants of comptime::Value into their own enum so we can use them throughout the codebase. I think this generally improves readability since it gives us a single location where our various conversions and operations like add are defined for every integer type.

Our current codebase isn't always the most clear on what encoding of fields we are using:

  • Normal form where -1 == -FieldElement::from(1)
  • Two's complement where -1i8 == FieldElement::from(255)
  • SignedField form where -1 == SignedField::negative(1) != SignedField::positive(-FieldElement::from(1))

Although we generally use "normal form" in more places, SSA is an exception for example where we may still have fields used for any integer type but expect them to be in two's complement.

We should gradually switch over to this new Integer type instead - so far this PR only changes comptime to use it, but it was already essentially used there already since that is where it was refactored from.

Additional Context

We will want to use this for numeric generics as well to be more accurate to the actual type used. This would fix #11722 but is more difficult than just a refactor since we'd need to know which type we're creating when we create the type constants instead of later on when the numeric generic is checked against the function signature.

User Documentation

Check one:

  • No user documentation needed.
  • Changes in docs/ included in this PR.
  • [For Experimental Features] Changes in docs/ to be submitted in a separate PR.

PR Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@jfecher jfecher requested a review from a team February 27, 2026 21:35
Copy link
Contributor

@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.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 518db21 Previous: 65c3939 Ratio
test_report_zkpassport_noir-ecdsa_ 3 s 2 s 1.50
test_report_zkpassport_noir_rsa_ 2 s 1 s 2

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

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.

Incorrect result for division on type constants

1 participant