-
Notifications
You must be signed in to change notification settings - Fork 11.4k
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
Conversation
punwai
commented
Aug 16, 2022
•
edited
Loading
edited
- 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)
There was a problem hiding this 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.
b75b4ed
to
25d1a20
Compare
There was a problem hiding this 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
6cd8923
to
a3327ff
Compare
There was a problem hiding this 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; |
There was a problem hiding this comment.
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") { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
79442f5
to
7d863aa
Compare
There was a problem hiding this 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. |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3