Skip to content

Commit

Permalink
Merge pull request #590 from Zeegomo/api-update
Browse files Browse the repository at this point in the history
uniform keys API
  • Loading branch information
zeegomo authored Jul 1, 2021
2 parents 1517288 + ae9708c commit 0d419a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions chain-vote/src/committee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ impl MemberSecretKey {
let sk = Scalar::from_bytes(bytes)?;
Some(Self(SecretKey { sk }))
}

pub fn to_public(&self) -> MemberPublicKey {
MemberPublicKey(PublicKey {
pk: GroupElement::generator() * &self.0.sk,
})
}
}

impl MemberPublicKey {
Expand All @@ -168,14 +174,6 @@ impl From<PublicKey> for MemberPublicKey {
}
}

impl From<&MemberSecretKey> for MemberPublicKey {
fn from(sk: &MemberSecretKey) -> Self {
MemberPublicKey(PublicKey {
pk: GroupElement::generator() * &sk.0.sk,
})
}
}

impl MemberCommunicationKey {
pub fn new<R: RngCore + CryptoRng>(rng: &mut R) -> Self {
let sk = SecretKey::generate(rng);
Expand All @@ -197,14 +195,20 @@ impl MemberCommunicationKey {
}
}

impl MemberCommunicationPublicKey {
pub fn from_public_key(pk: PublicKey) -> Self {
impl From<PublicKey> for MemberCommunicationPublicKey {
fn from(pk: PublicKey) -> MemberCommunicationPublicKey {
Self(pk)
}
}

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

pub fn from_bytes(bytes: &[u8]) -> Option<Self> {
PublicKey::from_bytes(bytes).map(Self)
}
}

impl ElectionPublicKey {
Expand Down
2 changes: 1 addition & 1 deletion chain-vote/src/tally.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl EncryptedTally {
for r in &self.r {
// todo: we are decrypting twice, we can probably improve this
let decrypted_share = &r.e1 * &secret_key.0.sk;
let pk = MemberPublicKey::from(secret_key);
let pk = secret_key.to_public();
let proof = ProofOfCorrectShare::generate(&r, &pk.0, &secret_key.0, rng);
dshares.push(ProvenDecryptShare {
r1: decrypted_share,
Expand Down

0 comments on commit 0d419a9

Please sign in to comment.