Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make short_weierstrass::Affine's infinity flag conditional #639

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Pratyush
Copy link
Member

Description

This PR allows short_weierstrass::Affine's layout to conditionally contain a bool flag indicating whether or not it is zero. This is helpful for compressing the representation of the point in memory. Note that due to the unfortunate lack of associated type defaults, we cannot set the type of the flag to be bool by default.

In the future, it would be nice to automatically derive this from certain conditions (e.g., A.is_zero())


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (master)
  • Linked to GitHub issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Wrote unit tests
  • Updated relevant documentation in the code
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md
  • Re-reviewed Files changed in the GitHub PR explorer

@Pratyush Pratyush requested review from a team as code owners April 21, 2023 15:26
@Pratyush Pratyush requested review from mmagician and weikengchen and removed request for a team April 21, 2023 15:26
@Pratyush
Copy link
Member Author

Pratyush commented Apr 21, 2023

Note that I'm not sure this is necessarily a change that we want: the resulting UX is worse (implementors of SWConfig now need to decide what ZeroIndicator to use, which is something they can screw up), and the cost of is_zero() is now potentially higher.

For the first issue, maybe we can provide a macro or something that automatically makes the choice for end users.

For the second issue, we should benchmark and see if there's perf differences.

@@ -30,6 +33,9 @@ pub trait SWCurveConfig: super::CurveConfig {
/// Generator of the prime-order subgroup.
const GENERATOR: Affine<Self>;

/// A type that is stored in `Affine<Self>` to indicate whether the point is at infinity.
type ZeroIndicator: ZeroInd<Self>;
Copy link
Member Author

Choose a reason for hiding this comment

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

Not really happy with this name; happy to take suggestions for better name.

@@ -198,3 +204,30 @@ pub trait SWCurveConfig: super::CurveConfig {
}
}
}

pub trait ZeroInd<C: SWCurveConfig>:
Copy link
Member Author

Choose a reason for hiding this comment

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

Same for this.

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