forked from ZenGo-X/gotham-city
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- DynamoDB integration (remote database, low latency and full managed by AWS) - User authentication using Json Web Tokens and AWS Cognito pools (this is optional and has to be defined (1) in Settings.toml or (2) as environment variable. - Thin client and refactoring in order to abstract for the client the process of keygen. - Additional unit testing Tested with RUST_TEST_THREADS=1 cargo test
- Loading branch information
Showing
43 changed files
with
2,133 additions
and
441 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
endpoint = "http://localhost:8000" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use super::ecdsa::{keygen, sign}; | ||
use kms::ecdsa::two_party::MasterKey2; | ||
use multi_party_ecdsa::protocols::two_party_ecdsa::lindell_2017::party_one; | ||
use reqwest; | ||
|
||
pub struct ClientShim { | ||
pub client: reqwest::Client, | ||
pub endpoint: String, | ||
} | ||
|
||
impl ClientShim { | ||
pub fn new(endpoint: String) -> ClientShim { | ||
let client = reqwest::Client::new(); | ||
ClientShim { client, endpoint } | ||
} | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct PrivateShare { | ||
pub id: String, | ||
pub master_key: MasterKey2, | ||
} | ||
|
||
pub fn get_master_key(client_shim: &ClientShim) -> PrivateShare { | ||
keygen::get_master_key(&client_shim) | ||
} | ||
|
||
pub fn sign( | ||
client_shim: &ClientShim, | ||
message: bitcoin::util::hash::Sha256dHash, | ||
mk: &MasterKey2, | ||
pos: u32, | ||
id: &String, | ||
) -> party_one::Signature { | ||
sign::sign(&client_shim, message, mk, pos, id) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use bitcoin; | ||
use curv::BigInt; | ||
use kms::ecdsa::two_party::party2; | ||
use kms::ecdsa::two_party::MasterKey2; | ||
use multi_party_ecdsa::protocols::two_party_ecdsa::lindell_2017::party_one; | ||
use multi_party_ecdsa::protocols::two_party_ecdsa::lindell_2017::party_two; | ||
|
||
use super::super::api; | ||
use super::super::utilities::requests; | ||
use curv::arithmetic::traits::Converter; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct SignSecondMsgRequest { | ||
pub message: BigInt, | ||
pub party_two_sign_message: party2::SignMessage, | ||
pub pos_child_key: u32, | ||
} | ||
|
||
pub fn sign( | ||
client_shim: &api::ClientShim, | ||
message: bitcoin::util::hash::Sha256dHash, | ||
mk: &MasterKey2, | ||
pos: u32, | ||
id: &String, | ||
) -> party_one::Signature { | ||
let (eph_key_gen_first_message_party_two, eph_comm_witness, eph_ec_key_pair_party2) = | ||
MasterKey2::sign_first_message(); | ||
|
||
let request: party_two::EphKeyGenFirstMsg = eph_key_gen_first_message_party_two; | ||
let res_body = | ||
requests::postb(client_shim, &format!("/ecdsa/sign/{}/first", id), &request).unwrap(); | ||
|
||
let sign_party_one_first_message: party_one::EphKeyGenFirstMsg = | ||
serde_json::from_str(&res_body).unwrap(); | ||
|
||
let party_two_sign_message = mk.sign_second_message( | ||
&eph_ec_key_pair_party2, | ||
eph_comm_witness.clone(), | ||
&sign_party_one_first_message, | ||
&BigInt::from_hex(&message.le_hex_string()), | ||
); | ||
|
||
let signature: party_one::Signature = | ||
get_signature(client_shim, message, party_two_sign_message, pos, &id); | ||
|
||
signature | ||
} | ||
|
||
fn get_signature( | ||
client_shim: &api::ClientShim, | ||
message: bitcoin::util::hash::Sha256dHash, | ||
party_two_sign_message: party2::SignMessage, | ||
pos_child_key: u32, | ||
id: &String, | ||
) -> party_one::Signature { | ||
let request: SignSecondMsgRequest = SignSecondMsgRequest { | ||
message: BigInt::from_hex(&message.le_hex_string()), | ||
party_two_sign_message, | ||
pos_child_key, | ||
}; | ||
|
||
let res_body = | ||
requests::postb(client_shim, &format!("/ecdsa/sign/{}/second", id), &request).unwrap(); | ||
|
||
let signature: party_one::Signature = serde_json::from_str(&res_body).unwrap(); | ||
signature | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.