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

Wrap Signature into a struct #184

Merged
merged 7 commits into from
Jan 22, 2020
Merged

Wrap Signature into a struct #184

merged 7 commits into from
Jan 22, 2020

Conversation

ec2
Copy link
Member

@ec2 ec2 commented Jan 21, 2020

Before Signature was a type alias to Vec<u8. This doesnt allow us to write a custom Serialize and Derserialize on it. So we need to wrap it in a struct.

crypto/src/signature.rs Outdated Show resolved Hide resolved
Comment on lines 27 to 33
impl Deref for Signature {
type Target = Vec<u8>;

fn deref(&self) -> &Self::Target {
&self.0
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is what I would do as well, but just to give the other option:

impl Signature {
    pub fn as_bytes(&self) -> &Vec<u8> {
        &self.0
    }
}

Which seperates the functions on Signature with Vec. But since there seems to be nothing specific to signature and nothing to hide from signature this is probably good.

crypto/src/signature.rs Outdated Show resolved Hide resolved
crypto/src/vrf.rs Outdated Show resolved Hide resolved
@ec2 ec2 requested a review from austinabell January 21, 2020 21:02
crypto/src/signature.rs Outdated Show resolved Hide resolved
crypto/src/vrf.rs Outdated Show resolved Hide resolved
@austinabell austinabell changed the title Wrap Signature into a tuple struct Wrap Signature into a struct Jan 22, 2020
@austinabell
Copy link
Contributor

@dutterbutter if you don't mind rereviewing (and @ec2) from 26165cc changes. Don't worry I have Eric's blessing to push to his branch the serialization was missing the signature type :)

@ec2 ec2 merged commit ab99a6e into master Jan 22, 2020
@ec2 ec2 deleted the ec2/signature-struct branch January 22, 2020 19:11
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