Skip to content

Derives and borrows#3

Open
burdges wants to merge 2 commits into
zkcrypto:masterfrom
burdges:derives_n_borrows
Open

Derives and borrows#3
burdges wants to merge 2 commits into
zkcrypto:masterfrom
burdges:derives_n_borrows

Conversation

@burdges

@burdges burdges commented Nov 16, 2019

Copy link
Copy Markdown

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

@str4d str4d left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs a rebase.

Comment thread src/lib.rs
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
Copy Markdown
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.

Comment thread src/lib.rs
/// 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]);

@str4d str4d Sep 4, 2020

Copy link
Copy Markdown
Member

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