Skip to content

feat: IsZero, IsOne, tests - #1042

Merged
DavePearce merged 3 commits into
mainfrom
feat/isone
Jul 29, 2025
Merged

feat: IsZero, IsOne, tests#1042
DavePearce merged 3 commits into
mainfrom
feat/isone

Conversation

@Tabaie

@Tabaie Tabaie commented Jul 28, 2025

Copy link
Copy Markdown
Contributor
  • Introduce the functions IsZero and IsOne
  • Tests for the same, along with the basic algebraic properties of zero and one.
  • Improve NewElement by taking out the % m operation.
  • Rename NewElement to New.

@Tabaie
Tabaie requested a review from Copilot July 28, 2025 22:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces IsZero and IsOne utility functions to field elements across multiple field implementations, along with comprehensive test coverage. The changes also refactor the Montgomery representation constants and improve the NewElement function implementation.

  • Adds IsZero and IsOne methods to field element implementations
  • Refactors constant naming from rSq to rSqModM and introduces rModM constant
  • Updates NewElement implementation to use multiplication instead of modular arithmetic

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/util/field/interface.go Adds IsZero and IsOne methods to the Element interface
pkg/util/field/interface_test.go New test file to verify interface compliance
pkg/util/field/internal/generator/main.go Updates field configuration to generate both rModM and rSqModM constants
pkg/util/field/internal/generator/templates/*.tmpl Template updates for new constants and methods
pkg/util/field/*/element.go Implements IsZero/IsOne methods and refactors constants across field types
pkg/util/field/*/element_test.go Adds comprehensive tests for zero/one properties and algebraic operations
pkg/util/assert/assert.go Adds True and False assertion helpers

Comment thread pkg/util/assert/assert.go Outdated
Comment thread pkg/util/assert/assert.go Outdated
@Tabaie
Tabaie marked this pull request as ready for review July 28, 2025 22:53
@Tabaie
Tabaie requested a review from DavePearce July 28, 2025 22:53
Comment thread pkg/util/assert/assert.go

@DavePearce DavePearce left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@DavePearce
DavePearce merged commit 1952950 into main Jul 29, 2025
7 checks passed
@DavePearce
DavePearce deleted the feat/isone branch July 29, 2025 20:50
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