-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: modify local signer from remote one; removed private keys from …
…'contracts/signer'
- Loading branch information
Showing
11 changed files
with
93 additions
and
231 deletions.
There are no files selected for viewing
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,48 @@ | ||
use std::{error::Error, str::FromStr}; | ||
|
||
use ethers::{ | ||
abi::{encode, Token}, | ||
signers::{LocalWallet, Signer}, | ||
utils::{keccak256, to_checksum}, | ||
}; | ||
|
||
use summa_backend::apis::csv_parser::SignatureRecord; | ||
|
||
pub async fn sign_message(message: &str) -> Result<Vec<SignatureRecord>, Box<dyn Error>> { | ||
// Using private keys directly is insecure. | ||
// Instead, consider leveraging hardware wallet support. | ||
// `ethers-rs` provides support for both Ledger and Trezor hardware wallets. | ||
// | ||
// For example, you could use the Ledger wallet as shown below: | ||
// let signing_wallets = (0..2).map(|index| Ledger::new(HDPath::LedgerLive(index), 1).await.unwrap()).collect(); | ||
// | ||
// Refers to: https://docs.rs/ethers/latest/ethers/signers/index.html | ||
let private_keys = &[ | ||
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d", | ||
"0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a", | ||
]; | ||
|
||
let signing_wallets: Vec<LocalWallet> = private_keys | ||
.iter() | ||
.map(|private_key| LocalWallet::from_str(private_key).unwrap()) | ||
.collect(); | ||
|
||
let encoded_message = encode(&[Token::String(message.to_owned())]); | ||
let hashed_message = keccak256(encoded_message); | ||
|
||
let mut signatures: Vec<SignatureRecord> = Vec::new(); | ||
|
||
// Iterating signing wallets and generate signature to put `signatures` vector | ||
for wallet in signing_wallets { | ||
let signature = wallet.sign_message(hashed_message).await.unwrap(); | ||
let record = SignatureRecord::new( | ||
"ETH".to_string(), | ||
to_checksum(&wallet.address(), None), // | ||
format!("0x{}", signature.to_string()), | ||
message.to_string(), | ||
); | ||
signatures.push(record); | ||
} | ||
|
||
Ok(signatures) | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
chain;address;signature;message | ||
ETH;0x70997970C51812dc3A010C7d01b50e0d17dc79C8;0x089b32327d332c295dc3b8873c205b72153211de6dc1c51235782b091cefb9d06d6df2661b86a7d441cd322f125b84901486b150e684221a7b7636eb8182af551b;Summa proof of solvency for CryptoExchange | ||
ETH;0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC;0xb17a9e25265d3b88de7bfad81e7accad6e3d5612308ff83cc0fef76a34152b0444309e8fc3dea5139e49b6fc83a8553071a7af3d0cfd3fb8c1aea2a4c171729c1c;Summa proof of solvency for CryptoExchange | ||
chain;address;signature;message | ||
ETH;0x70997970C51812dc3A010C7d01b50e0d17dc79C8;0x089b32327d332c295dc3b8873c205b72153211de6dc1c51235782b091cefb9d06d6df2661b86a7d441cd322f125b84901486b150e684221a7b7636eb8182af551b;Summa proof of solvency for CryptoExchange | ||
ETH;0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC;0xb17a9e25265d3b88de7bfad81e7accad6e3d5612308ff83cc0fef76a34152b0444309e8fc3dea5139e49b6fc83a8553071a7af3d0cfd3fb8c1aea2a4c171729c1c;Summa proof of solvency for CryptoExchange |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pub mod address_ownership; | ||
mod csv_parser; | ||
pub mod csv_parser; | ||
pub mod round; |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pub mod inclusion_verifier; | ||
pub mod solvency_verifier; | ||
pub mod summa_contract; | ||
pub mod solvency_verifier; | ||
pub mod inclusion_verifier; |
Oops, something went wrong.