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

[WAR-535] Sylow review comments #26

Merged
merged 10 commits into from
Aug 27, 2024
Merged

[WAR-535] Sylow review comments #26

merged 10 commits into from
Aug 27, 2024

Conversation

merolish
Copy link
Contributor

No description provided.

Copy link

linear bot commented Aug 23, 2024

@merolish merolish marked this pull request as ready for review August 27, 2024 19:01
Copy link

codecov bot commented Aug 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link
Collaborator

@trbritt trbritt left a comment

Choose a reason for hiding this comment

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

great feedback, and most of this is addressed now either in this pr or in the upcoming #28

Cargo.toml Outdated
@@ -4,6 +4,7 @@ categories = ["cryptography", "mathematics"]
description = "Implementation of the BLS signature scheme using the alt-bn128 curve."
homepage = "https://github.com/warlock-labs/sylow"
keywords = ["alt-bn128", "bls", "cryptography", "elliptic-curve", "pairing"]
# BN254, any Ethereum/crypto-specific categories/keywords?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll modify "bls" to "zero-knowledge" for now since its closer to the current functionality, but there's a hard limit of 5 keywords :/

Cargo.toml Outdated
name = "key"
path = "examples/key.rs"
# do we need/want to add all examples here
# also, some examples demonstrating groups and fields
Copy link
Collaborator

Choose a reason for hiding this comment

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

added the example for pairing explicitly as well

@@ -5,6 +5,7 @@
[![Docs](https://img.shields.io/crates/v/sylow?color=blue&label=docs)](https://docs.rs/sylow/)
![CI](https://github.com/warlock-labs/sylow/actions/workflows/CI.yml/badge.svg)

<!-- Generally seems to be pronounced SEE-low at least in American English, and perhaps note that it's being named after Ludwig. -->
Copy link
Collaborator

Choose a reason for hiding this comment

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

I just copied the ipa spelling from Wikipedia for this so I assume it reads SEE-low but I'm not sure! either way, ill let wikipedia be the decider

},
Err(e) => println!("Signing error: {:?}", e),
}
// Generate a new key pair
Copy link
Collaborator

Choose a reason for hiding this comment

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

great catch rustfmt-ing this!

benches/field.rs Outdated
@@ -1,3 +1,5 @@
// Would testing for operations running in const time, e.g. through sampling,
// be feasible as a part of benchmark or other testing?
Copy link
Collaborator

Choose a reason for hiding this comment

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

yes it is, and they will have been added on main soon

@@ -27,6 +29,7 @@ impl<const D: usize, const N: usize, F: FieldExtensionTrait<D, N>> From<u64>
fn from(value: u64) -> Self {
let mut retval = [F::zero(); N];
retval[0] = F::from(value);
// And we're sure F is always >= u64
Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, since crypto_bigint won't let you instantiate a ConstMontyForm with a bit precision less than that

@@ -44,12 +47,14 @@ impl<const D: usize, const N: usize, F: FieldExtensionTrait<D, N>> FieldExtensio
/// <https://eprint.iacr.org/2010/354.pdf>
/// # Arguments
/// * `factor` - a field element that is used to scale the extension element
// This has a clear meaning in context, as opposed to multiplication?
Copy link
Collaborator

Choose a reason for hiding this comment

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

note added clarifying this

pub(crate) fn scale(&self, factor: F) -> Self {
let mut i = 0;
let mut retval = [F::zero(); N];
while i < N {
retval[i] = self.0[i] * factor;
i += 1;
// There's no concern about carry/overflow here?
Copy link
Collaborator

Choose a reason for hiding this comment

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

in what way? overflow of the accumulator i or of the multiplication? the multiplication will always be handled with the Montgomery modular arithmetic and therefore handles overflow over the modulus

@@ -156,6 +162,7 @@ impl<const D: usize, const N: usize, F: FieldExtensionTrait<D, N>> Neg for Field
while i < N {
retval[i] = -self.0[i];
i += 1;
// This element-wise negation just works?
Copy link
Collaborator

Choose a reason for hiding this comment

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

yep, since this just determines A' such that A + A' = \vec{0} element-wise, which is achieved with each element of the extension being A'_i = -A_i.

@@ -156,6 +162,7 @@ impl<const D: usize, const N: usize, F: FieldExtensionTrait<D, N>> Neg for Field
while i < N {
retval[i] = -self.0[i];
i += 1;
// This element-wise negation just works?
Copy link
Collaborator

Choose a reason for hiding this comment

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

yep, since this just determines A' such that A + A' = \vec{0} element-wise, which is achieved with each element of the extension being A'_i = -A_i.

@trbritt trbritt merged commit 96d5013 into main Aug 27, 2024
15 checks passed
@trbritt trbritt deleted the mike/review branch August 27, 2024 21:35
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