Skip to content

Commit

Permalink
Merge pull request ZenGo-X#26 from KZen-networks/hotfix/ddb-attribute…
Browse files Browse the repository at this point in the history
…-alpha

Wrapping alpha into a serializable struct for DynamoDB attribute mapping
  • Loading branch information
omershlo authored May 22, 2019
2 parents c970b7d + 69ddc8f commit 16996e9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions gotham-server/src/routes/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ struct HDPos {
pos: u32,
}

#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
struct Alpha {
value: BigInt
}

#[derive(ToString, Debug)]
pub enum Share {
KeyGenFirstMsg,
Expand Down Expand Up @@ -218,7 +223,7 @@ pub fn third_message(
&party_one_pdl_decommit,
)?;

db::insert(&state.db, &claim.sub, &id, &Share::Alpha, &alpha)?;
db::insert(&state.db, &claim.sub, &id, &Share::Alpha, &Alpha { value: alpha })?;

db::insert(
&state.db,
Expand Down Expand Up @@ -254,15 +259,15 @@ pub fn fourth_message(
db::get(&state.db, &claim.sub, &id, &Share::Party2PDLFirstMsg)?
.ok_or(format_err!("No data for such identifier {}", id))?;

let alpha: BigInt = db::get(&state.db, &claim.sub, &id, &Share::Alpha)?
let alpha: Alpha = db::get(&state.db, &claim.sub, &id, &Share::Alpha)?
.ok_or(format_err!("No data for such identifier {}", id))?;

let res = MasterKey1::key_gen_fourth_message(
&party_2_pdl_first_message,
&party_two_pdl_second_message.0,
party_one_private,
party_one_pdl_decommit,
alpha,
alpha.value,
);

assert!(res.is_ok());
Expand Down Expand Up @@ -565,7 +570,7 @@ pub fn rotate_third(
&party_one_private_new,
);

db::insert(&state.db, &claim.sub, &id, &Share::Alpha, &alpha)?;
db::insert(&state.db, &claim.sub, &id, &Share::Alpha, &Alpha { value: alpha })?;

db::insert(
&state.db,
Expand Down Expand Up @@ -625,7 +630,7 @@ pub fn rotate_fourth(
db::get(&state.db, &claim.sub, &id, &Share::RotatePdlDecom)?
.ok_or(format_err!("No data for such identifier {}", id))?;

let alpha: BigInt = db::get(&state.db, &claim.sub, &id, &Share::Alpha)?
let alpha: Alpha = db::get(&state.db, &claim.sub, &id, &Share::Alpha)?
.ok_or(format_err!("No data for such identifier {}", id))?;

let result_rotate_party_two_second_message = party_one_master_key.rotation_third_message(
Expand All @@ -635,7 +640,7 @@ pub fn rotate_fourth(
&rotation_party_two_first_message,
&rotation_party_two_second_message.0,
party_one_pdl_decommit,
alpha,
alpha.value,
);
if result_rotate_party_two_second_message.is_err() {
panic!("rotation failed");
Expand Down

0 comments on commit 16996e9

Please sign in to comment.