-
Notifications
You must be signed in to change notification settings - Fork 20
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
Introduce KeyFragID instead of using a Scalar for this purpose #40
Conversation
Codecov Report
@@ Coverage Diff @@
## master #40 +/- ##
==========================================
- Coverage 94.83% 94.64% -0.19%
==========================================
Files 10 10
Lines 736 766 +30
==========================================
+ Hits 698 725 +27
- Misses 38 41 +3
Continue to review full report at Codecov.
|
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.
Looks great!
@@ -17,7 +48,7 @@ pub struct CapsuleFragProof { | |||
kfrag_pok: CurvePoint, | |||
signature: CurveScalar, | |||
kfrag_signature: Signature, | |||
metadata: CurveScalar, | |||
metadata: HashedMetadata, |
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.
👍
type HashedMetadataSize = BytesDigestOutputSize; | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub(crate) struct HashedMetadata(GenericArray<u8, HashedMetadataSize>); |
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.
Very nice.
) -> CurveScalar { | ||
ScalarDigest::new_with_dst(b"POLYNOMIAL_ARG") | ||
.chain_point(precursor) | ||
.chain_point(pubkey) | ||
.chain_point(dh_point) | ||
.chain_scalar(id) | ||
.chain_bytes(kfrag_id) |
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.
👍
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub(crate) struct KeyFragID(GenericArray<u8, KeyFragIDSize>); | ||
|
||
impl KeyFragID { |
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.
Very nice, lots of room for other cool additions here in the future.
@@ -59,7 +91,7 @@ impl KeyFragProof { | |||
#[allow(clippy::too_many_arguments)] | |||
fn new( | |||
params: &Parameters, | |||
kfrag_id: &CurveScalar, | |||
kfrag_id: &KeyFragID, |
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.
👍
@@ -151,8 +183,7 @@ impl SerializableToArray for KeyFrag { | |||
|
|||
impl KeyFrag { | |||
fn new(factory: &KeyFragFactory, sign_delegating_key: bool, sign_receiving_key: bool) -> Self { | |||
// Was: `os.urandom(bn_size)`. But it seems we just want a scalar? | |||
let kfrag_id = CurveScalar::random_nonzero(); | |||
let kfrag_id = KeyFragID::random(); |
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.
👍
@@ -221,7 +252,7 @@ impl KeyFrag { | |||
let correct_commitment = commitment == &u * &key; | |||
|
|||
let mut digest = SignatureDigest::new() | |||
.chain_scalar(&kfrag_id) | |||
.chain_bytes(&kfrag_id) |
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.
👍
@@ -200,7 +231,7 @@ impl CapsuleFrag { | |||
|
|||
let h = ScalarDigest::new() | |||
.chain_points(&[e, e1, e2, v, v1, v2, u, u1, u2]) | |||
.chain_scalar(&self.proof.metadata) | |||
.chain_bytes(&self.proof.metadata) |
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.
👍
@@ -209,7 +240,7 @@ impl CapsuleFrag { | |||
let kfrag_id = self.kfrag_id; | |||
|
|||
let valid_kfrag_signature = SignatureDigest::new() | |||
.chain_scalar(&kfrag_id) | |||
.chain_bytes(&kfrag_id) |
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.
👍
@@ -137,7 +168,7 @@ impl SerializableToArray for CapsuleFrag { | |||
fn from_array(arr: &GenericArray<u8, Self::Size>) -> Option<Self> { | |||
let (point_e1, rest) = CurvePoint::take(*arr)?; | |||
let (point_v1, rest) = CurvePoint::take(rest)?; | |||
let (kfrag_id, rest) = CurveScalar::take(rest)?; | |||
let (kfrag_id, rest) = KeyFragID::take(rest)?; |
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.
👍
A part of #27
Fixes #21
KeyFrag
identifier matches the one used inPyUmbral
.CapsuleFrag
metadata in bytes instead of a scalar