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

Add low degree exponent interpolation proof #119

Closed
wants to merge 10 commits into from
Closed

Add low degree exponent interpolation proof #119

wants to merge 10 commits into from

Conversation

survived
Copy link
Contributor

PR adds low degree exponent interpolation proof. Here's construction:

image

I needed polynomial-related machinery (to sample polynomials, evaluate them, etc.), and it was already implemented as part of feldman_vss. I moved polynomial-related logic into dedicated struct Polynomial (and well-documented it). Functions in feldman_vss are still available, but got deprecated and now they use Polynomial under hood.

/// let polynomial = Polynomial::<GE>::sample_fixed_coef0(3, coef0);
/// assert_eq!(polynomial.evaluate(&FE::zero()), coef0);
/// ```
pub fn sample_fixed_coef0(n: u16, coef0: P::Scalar) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps coef0 could be renamed to "constant_term"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated! I let myself shorten your suggestion - renamed to const_term

{
let poly = Polynomial::<P>::sample(5);

let alpha: Vec<P::Scalar> = (1..=10).map(|i| ECScalar::from(&BigInt::from(i))).collect();
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure the generators are not supposed to be picked at random such that there is no way to compute x such that g_i = x g_j ?
for example see how we generate the generator vector in bulletproofs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The line you commented doesn't choose generators — it chooses list of α (a list of pairwise distinct scalar from Setup phase of the proof). Line below chooses generators completely at random. I agree that correlation like g_i = x g_j could potentially lead to vulnerabilities

Copy link
Contributor

Choose a reason for hiding this comment

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

no idea why I picked that line :)
so will you change it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I found what code you're referring to — generate_random_point. Are you ok with me moving this function to curv::elliptic::curves:: generate_random_point ?

@@ -0,0 +1,371 @@
use std::convert::TryFrom;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think polynomial count as a cryptographic primitive, but I am not sure where else to put it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it can be located in crate::elliptic module as well (as it heavily uses elliptic things). Currently elliptic module consist only of curves submodule. What do you think about moving it to elliptic module?

Copy link
Contributor

Choose a reason for hiding this comment

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

my opinion is to move polynomial into cryptographic_primitives/secret_sharing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough. Moved it into secret_sharing.

/// assert_eq!(polynomial.degree(), 3);
/// ```
///
pub fn sample(degree: u16) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we have to make sure we didn't sample zero as the most significant indeterminate? This can result in the polynomial having a wrong degree.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catch - I added sample_exact and sample_exact_with_fixed_const_term functions that produce polynomial of given degree, whereas sample and sample_with_fixed_const_term functions are allowed now to produce polynomial of degree less or equal to given degree

}

#[derive(Debug, Error)]
pub enum LdeiProveError {
Copy link
Contributor

Choose a reason for hiding this comment

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

change to LdeiProofError

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

.take(10)
.collect();

let (statement, proof) =
Copy link
Contributor

@omershlo omershlo Jun 30, 2021

Choose a reason for hiding this comment

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

the prover should accept a statement and a witness.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Can you confirm that it now looks like you expected?

where
H: Hash,
{
if alpha.len() != g.len() {
Copy link
Contributor

Choose a reason for hiding this comment

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

the prover should check correctness of the statement (same for the verifier):
I see that a check that g.len()>=w.degree

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the check

@survived
Copy link
Contributor Author

Merged along with #120

@survived survived closed this Jul 27, 2021
@survived survived deleted the ldei branch August 26, 2021 07:20
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.

None yet

3 participants