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

[crypto] Move Bulletproofs and EC #4035

Merged
merged 1 commit into from
Aug 18, 2022
Merged

Conversation

punwai
Copy link
Contributor

@punwai punwai commented Aug 16, 2022

  • Introduce a Elliptic Curve library based on the Ristretto-255 group to Move (includes structs for both the group element and the underlying finite-field elements)
  • Introduce a native Move implementation of Pedersen Commitments
  • Introduce a native Move implementation of Bulletproofs (range proofs)

Copy link
Contributor

@Clay-Mysten Clay-Mysten left a comment

Choose a reason for hiding this comment

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

The small Markdown change LGTM with some mods I made in a new commit here.

@punwai punwai changed the title Bulletproofs [crypto] Move Bulletproofs and EC Aug 16, 2022
@punwai punwai force-pushed the bulletproofs branch 4 times, most recently from b75b4ed to 25d1a20 Compare August 17, 2022 19:52
@punwai punwai requested a review from kchalkias August 17, 2022 19:55
Copy link
Collaborator

@kchalkias kchalkias left a comment

Choose a reason for hiding this comment

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

1st quick scan. Need more time to evaluate logic

@punwai punwai force-pushed the bulletproofs branch 2 times, most recently from 6cd8923 to a3327ff Compare August 18, 2022 03:49
Copy link
Collaborator

@kchalkias kchalkias left a comment

Choose a reason for hiding this comment

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

Let's rebase (due to fastcrypto update)

use smallvec::smallvec;
use std::collections::VecDeque;

pub const FAIL_TO_RECOVER_PUBKEY: u64 = 0;
pub const INVALID_SIGNATURE: u64 = 1;
pub const INVALID_BULLETPROOF: u64 = 2;
pub const INVALID_RISTRETTO_GROUP_ELEMENT: u64 = 3;
pub const INVALID_RISTRETTO_SCALAR: u64 = 5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

switch 4 and 5 for readability (the first one to be 4)

return Ok(NativeResult::err(cost, INVALID_RISTRETTO_GROUP_ELEMENT));
};

match proof.verify_bit_length(&commitment, bit_length as usize, b"sui") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd put `b"sui" as const if possible (not to have it hidden inside the function.

}

/// Create a pedersen commitment from two field elements
public fun create_pedersen_commitment(value: Scalar, blinding_factor: Scalar): RistrettoPoint {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Although it's not clear where we need that (because we reveal a blinding factor and in most privacy preserving apps we don't open commitments publicly), I'll approve for now as it might be useful in the future for fraud proofs etc.

Copy link
Contributor Author

@punwai punwai Aug 18, 2022

Choose a reason for hiding this comment

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

I'll keep this for this PR, but if I can implement the example without this, I'll remove it with the example PR.

@punwai punwai force-pushed the bulletproofs branch 2 times, most recently from 79442f5 to 7d863aa Compare August 18, 2022 22:03
Copy link
Collaborator

@kchalkias kchalkias left a comment

Choose a reason for hiding this comment

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

Amazing job

}

// TODO: Add arithmetic for Scalar elements. We just need add, subtract, and multiply.
// TODO: Add scalar to point multiplication for group elements.
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

pub const INVALID_RISTRETTO_SCALAR: u64 = 4;
pub const BULLETPROOFS_VERIFICATION_FAILED: u64 = 5;

pub const BP_DOMAIN: &[u8] = b"sui";
Copy link
Collaborator

Choose a reason for hiding this comment

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

<3

@punwai punwai enabled auto-merge (squash) August 18, 2022 22:19
@punwai punwai merged commit 36cd1ae into MystenLabs:main Aug 18, 2022
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.

3 participants