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

Derives and borrows #3

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

Conversation

burdges
Copy link

@burdges burdges commented Nov 16, 2019

Adds some basic functions to encoded points and makes batch_normalization slightly easier to use

Copy link
Member

@str4d str4d left a comment

Choose a reason for hiding this comment

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

Needs a rebase.

Comment on lines +124 to +125
Sized + Send + Sync + AsRef<[u8]> + AsMut<[u8]> + Clone + Copy
+ PartialOrd + Ord + PartialEq + Eq + ::std::hash::Hash + 'static
Copy link
Member

Choose a reason for hiding this comment

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

These bounds should now be applied to GroupEncoding::Repr and UncompressedEncoding::Repr. Also add use core::hash::Hash at the top of the file instead of the explicit form here.

@@ -35,7 +35,7 @@ pub trait CurveProjective:

/// Normalizes a slice of projective elements so that
/// conversion to affine is cheap.
fn batch_normalization(v: &mut [Self]);
fn batch_normalization<S: ::std::borrow::BorrowMut<Self>>(v: &mut [S]);
Copy link
Member

@str4d str4d Sep 4, 2020

Choose a reason for hiding this comment

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

This change would now apply to Curve::batch_normalize, and would look something like:

use core::borrow::{Borrow, BorrowMut};
...
fn batch_normalize<P: Borrow<Self>, Q: BorrowMut<Self::AffineRepr>>(p: &[P], q: &mut [Q]) {

However, when I tried this locally, I ran into issues with &P not implementing Curve, that I wasn't immediately able to figure out how to resolve. Perhaps the P: Borrow<Self> is unnecessary flexibility?

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.

2 participants