Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
leontiadZen committed Sep 28, 2023
1 parent 79202b4 commit 21064c5
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 37 deletions.
2 changes: 1 addition & 1 deletion gotham-client/src/ecdsa/recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
// version 3 of the License, or (at your option) any later version.
//

use two_party_ecdsa::kms::ecdsa::two_party::{MasterKey1, MasterKey2};
use serde_json::Error;
use two_party_ecdsa::centipede::juggling::proof_system::Helgamalsegmented;
use two_party_ecdsa::centipede::juggling::segmentation::Msegmentation;
use two_party_ecdsa::curv::arithmetic::traits::{Converter, Modulo};
use two_party_ecdsa::curv::elliptic::curves::secp256_k1::{FE, GE};
use two_party_ecdsa::curv::elliptic::curves::traits::{ECPoint, ECScalar};
use two_party_ecdsa::curv::BigInt;
use two_party_ecdsa::kms::ecdsa::two_party::{MasterKey1, MasterKey2};
// iOS bindings
use std::ffi::{CStr, CString};
use std::os::raw::c_char;
Expand Down
2 changes: 1 addition & 1 deletion gotham-client/src/ecdsa/sign.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use failure::format_err;
use two_party_ecdsa::kms::ecdsa::two_party::{party2, MasterKey2};
use serde::{Deserialize, Serialize};
use two_party_ecdsa::kms::ecdsa::two_party::{party2, MasterKey2};
use two_party_ecdsa::{curv::BigInt, party_one, party_two};
// iOS bindings
use std::ffi::{CStr, CString};
Expand Down
2 changes: 1 addition & 1 deletion gotham-client/src/ecdsa/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use two_party_ecdsa::kms::ecdsa::two_party::MasterKey2;
use serde::{Deserialize, Serialize};
use two_party_ecdsa::curv::BigInt;
use two_party_ecdsa::kms::ecdsa::two_party::MasterKey2;

#[derive(Serialize, Deserialize)]
pub struct PrivateShare {
Expand Down
4 changes: 2 additions & 2 deletions gotham-server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod tests;
pub mod server;
pub mod public_gotham;
pub mod server;
pub mod tests;
2 changes: 1 addition & 1 deletion gotham-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod server;
mod public_gotham;
mod server;

use std::collections::HashMap;

Expand Down
3 changes: 1 addition & 2 deletions gotham-server/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::public_gotham::{Config, PublicGotham, DB};
use rocket::{self, catch, routes, Build, Request, Rocket, catchers};
use rocket::{self, catch, catchers, routes, Build, Request, Rocket};
use std::collections::HashMap;
use tokio::sync::Mutex;

Expand All @@ -19,7 +19,6 @@ fn not_found(req: &Request) -> String {
}

pub fn get_server(settings: HashMap<String, String>) -> Rocket<Build> {

// let settings = get_settings_as_map();
let db_config = Config {
db: get_db(settings.clone()),
Expand Down
39 changes: 10 additions & 29 deletions gotham-server/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ mod tests {
let (id, kg_party_one_first_message): (String, party_one::KeyGenFirstMsg) =
serde_json::from_str(&res_body).unwrap();


let (kg_party_two_first_message, kg_ec_key_pair_party2) = MasterKey2::key_gen_first_message();
let (kg_party_two_first_message, kg_ec_key_pair_party2) =
MasterKey2::key_gen_first_message();

/*************** END: FIRST MESSAGE ***************/

Expand All @@ -43,14 +43,12 @@ mod tests {
let kg_party_one_second_message: party1::KeyGenParty1Message2 =
serde_json::from_str(&res_body).unwrap();


let key_gen_second_message = MasterKey2::key_gen_second_message(
&kg_party_one_first_message,
&kg_party_one_second_message,
);
assert!(key_gen_second_message.is_ok());


let (party_two_second_message, party_two_paillier, party_two_pdl_chal) =
key_gen_second_message.unwrap();

Expand Down Expand Up @@ -82,26 +80,23 @@ mod tests {
let request = party_2_pdl_second_message;
let body = serde_json::to_string(&request).unwrap();


let response = client
.post(format!("/ecdsa/keygen/{}/fourth", id))
.body(body)
.header(ContentType::JSON)
.dispatch();
assert_eq!(response.status(), Status::Ok);


let res_body = response.into_string().unwrap();
let party_one_pdl_second_message: party_one::PDLSecondMessage =
serde_json::from_str(&res_body).unwrap();


MasterKey2::key_gen_fourth_message(
&party_two_pdl_chal,
&party_one_third_message,
&party_one_pdl_second_message,
)
.expect("pdl error party1");
.expect("pdl error party1");

/*************** START: CHAINCODE FIRST MESSAGE ***************/

Expand All @@ -111,20 +106,17 @@ mod tests {
.dispatch();
assert_eq!(response.status(), Status::Ok);


let res_body = response.into_string().unwrap();
let cc_party_one_first_message: Party1FirstMessage = serde_json::from_str(&res_body).unwrap();

let (cc_party_two_first_message, cc_ec_key_pair2) =
ChainCode2::chain_code_first_message();
let cc_party_one_first_message: Party1FirstMessage =
serde_json::from_str(&res_body).unwrap();

let (cc_party_two_first_message, cc_ec_key_pair2) = ChainCode2::chain_code_first_message();

/*************** END: CHAINCODE FIRST MESSAGE ***************/

/*************** START: CHAINCODE SECOND MESSAGE ***************/
let body = serde_json::to_string(&cc_party_two_first_message.d_log_proof).unwrap();


let response = client
.post(format!("/ecdsa/keygen/{}/chaincode/second", id))
.body(body)
Expand All @@ -133,26 +125,24 @@ mod tests {
assert_eq!(response.status(), Status::Ok);

let res_body = response.into_string().unwrap();
let cc_party_one_second_message: Party1SecondMessage = serde_json::from_str(&res_body).unwrap();
let cc_party_one_second_message: Party1SecondMessage =
serde_json::from_str(&res_body).unwrap();

let _cc_party_two_second_message = ChainCode2::chain_code_second_message(
&cc_party_one_first_message,
&cc_party_one_second_message,
);


/*************** END: CHAINCODE SECOND MESSAGE ***************/

let party2_cc = ChainCode2::compute_chain_code(
&cc_ec_key_pair2,
&cc_party_one_second_message.comm_witness.public_share,
)
.chain_code;

.chain_code;

/*************** END: CHAINCODE COMPUTE MESSAGE ***************/


let party_two_master_key = MasterKey2::set_master_key(
&party2_cc,
&kg_ec_key_pair_party2,
Expand Down Expand Up @@ -181,15 +171,13 @@ mod tests {

let body = serde_json::to_string(&request).unwrap();


let response = client
.post(format!("/ecdsa/sign/{}/first", id))
.body(body)
.header(ContentType::JSON)
.dispatch();
assert_eq!(response.status(), Status::Ok);


let res_body = response.into_string().unwrap();
let sign_party_one_first_message: party_one::EphKeyGenFirstMsg =
serde_json::from_str(&res_body).unwrap();
Expand All @@ -208,8 +196,6 @@ mod tests {
&message,
);



let request: SignSecondMsgRequest = SignSecondMsgRequest {
message,
party_two_sign_message,
Expand All @@ -219,24 +205,19 @@ mod tests {

let body = serde_json::to_string(&request).unwrap();


let response = client
.post(format!("/ecdsa/sign/{}/second", id))
.body(body)
.header(ContentType::JSON)
.dispatch();
assert_eq!(response.status(), Status::Ok);



let res_body = response.into_string().unwrap();
let signature_recid: party_one::SignatureRecid = serde_json::from_str(&res_body).unwrap();

signature_recid
}



#[test]
fn key_gen_and_sign() {
// Passthrough mode
Expand All @@ -252,7 +233,7 @@ mod tests {
]);
let server = server::get_server(settings);
let client = Client::tracked(server).expect("valid rocket instance");
let (id,master_key_2) = key_gen(&client);
let (id, master_key_2) = key_gen(&client);

let message = BigInt::from(1234u32);

Expand Down

0 comments on commit 21064c5

Please sign in to comment.