Skip to content

Commit

Permalink
chore: use workspace dependencies & rename crypto-shared to mpc-crypto (
Browse files Browse the repository at this point in the history
#172)

* Renamed crypto-shared to mpc-crypto

* fmt
  • Loading branch information
ChaoticTempest authored Feb 7, 2025
1 parent a7f8532 commit 11fc78c
Show file tree
Hide file tree
Showing 33 changed files with 157 additions and 142 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY chain-signatures/node/Cargo.toml Cargo.toml
RUN sed -i 's#src/main.rs#dummy.rs#' Cargo.toml
RUN sed -i 's#mpc-keys = { path = "../keys" }##' Cargo.toml
RUN sed -i 's#mpc-contract = { path = "../contract" }##' Cargo.toml
RUN sed -i 's#crypto-shared = { path = "../crypto-shared" }##' Cargo.toml
RUN sed -i 's#mpc-crypto = { path = "../mpc-crypto" }##' Cargo.toml
RUN sed -i 's#version.workspace = true##' Cargo.toml
RUN cargo build --release
# Now build the actual node
Expand Down
51 changes: 25 additions & 26 deletions chain-signatures/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions chain-signatures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@ resolver = "2"
[workspace.package]
version = "1.0.0"

[workspace.dependencies]
anyhow = { version = "1.0.95", features = ["backtrace"] }
borsh = "1.5.3"
cait-sith = { git = "https://github.com/sig-net/cait-sith", rev = "9f34e8c", features = ["k256"] }
hex = "0.4.3"
k256 = { version = "0.13.1", features = [
"sha256",
"ecdsa",
"serde",
"arithmetic",
"expose-field",
] }
rand = "0.8.5"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha3 = "0.10.8"
thiserror = "1"

near-account-id = "1.0.0"
near-sdk = { version = "5.6.0", features = ["legacy", "unit-testing", "unstable"] }

mpc-contract = { path = "./contract" }
mpc-crypto = { path = "./crypto" }
mpc-keys = { path = "./keys" }

[patch.crates-io]
# TODO: trigger Cargo.lock update for x25519-dalek once they release.
# This fixes https://rustsec.org/advisories/RUSTSEC-2024-0344 by pointing to a commit that includes the fix.
Expand Down
18 changes: 9 additions & 9 deletions chain-signatures/contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ edition = "2021"
crate-type = ["cdylib", "lib"]

[dependencies]
borsh = "1.5.3"
near-sdk = { version = "5.6.0", features = ["legacy", "unit-testing"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
k256 = { version = "0.13.1", features = ["sha256", "ecdsa", "serde", "arithmetic", "expose-field"] }
crypto-shared = { path = "../crypto-shared" }
thiserror = "1"
borsh.workspace = true
k256.workspace = true
mpc-crypto.workspace = true
near-sdk.workspace = true
serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true

[dev-dependencies]
anyhow = "1"
rand = "0.8"
anyhow.workspace = true
rand.workspace = true
tokio = { version = "1", features = ["full"] }

# crypto dependencies
Expand Down
8 changes: 4 additions & 4 deletions chain-signatures/contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ pub mod primitives;
pub mod state;
pub mod update;

use crypto_shared::{
derive_epsilon, derive_key, kdf::check_ec_signature, near_public_key_to_affine_point,
types::SignatureResponse, ScalarExt as _,
};
use errors::{
ConversionError, InitError, InvalidParameters, InvalidState, JoinError, PublicKeyError,
RespondError, SignError, VoteError,
};
use k256::elliptic_curve::sec1::ToEncodedPoint;
use k256::Scalar;
use mpc_crypto::{
derive_epsilon, derive_key, kdf::check_ec_signature, near_public_key_to_affine_point,
types::SignatureResponse, ScalarExt as _,
};
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::collections::LookupMap;
use near_sdk::json_types::U128;
Expand Down
2 changes: 1 addition & 1 deletion chain-signatures/contract/src/primitives.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crypto_shared::{derive_epsilon, SerializableScalar};
use k256::Scalar;
use mpc_crypto::{derive_epsilon, SerializableScalar};
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::serde::{Deserialize, Serialize};
use near_sdk::{AccountId, BorshStorageKey, CryptoHash, NearToken, PublicKey};
Expand Down
10 changes: 5 additions & 5 deletions chain-signatures/contract/tests/common.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use std::collections::{BTreeMap, HashMap};
use std::str::FromStr;

use crypto_shared::kdf::{check_ec_signature, derive_secret_key};
use crypto_shared::{
derive_epsilon, derive_key, ScalarExt as _, SerializableAffinePoint, SerializableScalar,
SignatureResponse,
};
use digest::{Digest, FixedOutput};
use ecdsa::signature::Verifier;
use k256::elliptic_curve::ops::Reduce;
Expand All @@ -16,6 +11,11 @@ use mpc_contract::primitives::{
CandidateInfo, ParticipantInfo, Participants, SignRequest, SignatureRequest,
};
use mpc_contract::update::UpdateId;
use mpc_crypto::kdf::{check_ec_signature, derive_secret_key};
use mpc_crypto::{
derive_epsilon, derive_key, ScalarExt as _, SerializableAffinePoint, SerializableScalar,
SignatureResponse,
};
use near_workspaces::network::Sandbox;
use near_workspaces::types::{AccountId, NearToken};
use near_workspaces::{Account, Contract, Worker};
Expand Down
2 changes: 1 addition & 1 deletion chain-signatures/contract/tests/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use mpc_contract::errors;
use mpc_contract::primitives::{CandidateInfo, SignRequest};
use near_workspaces::types::{AccountId, NearToken};

use crypto_shared::SignatureResponse;
use mpc_crypto::SignatureResponse;
use std::collections::HashMap;

#[tokio::test]
Expand Down
26 changes: 0 additions & 26 deletions chain-signatures/crypto-shared/Cargo.toml

This file was deleted.

19 changes: 19 additions & 0 deletions chain-signatures/crypto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "mpc-crypto"
version.workspace = true
edition = "2021"

[dependencies]
k256.workspace = true
anyhow.workspace = true
serde.workspace = true
borsh.workspace = true
near-account-id.workspace = true
serde_json.workspace = true
near-sdk.workspace = true
sha3.workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2.12", features = ["custom"] }

[dev-dependencies]
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 4 additions & 7 deletions chain-signatures/keys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ edition = "2021"
crate-type = ["cdylib", "lib"]

[dependencies]
borsh = "1.5.3"
hex = "0.4.3"
borsh.workspace = true
hex.workspace = true
hpke = { version = "0.11", features = ["serde_impls", "std"] }
serde = { version = "1", features = ["derive"] }
rand = { version = "0.8" }

[dev-dependencies]
hex = "*"
serde.workspace = true
rand.workspace = true
32 changes: 17 additions & 15 deletions chain-signatures/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,24 @@ name = "mpc-node"
path = "src/main.rs"

[dependencies]
anyhow = { version = "1", features = ["backtrace"] }
async-trait = "0.1"
aws-config = "1.4"
aws-sdk-s3 = "1.29"
axum = { version = "0.6.19" }
axum-extra = "0.7"
borsh = "1.5.3"
cait-sith = { git = "https://github.com/sig-net/cait-sith", rev = "9f34e8c", features = ["k256"] }
ciborium = "0.2.2"
clap = { version = "4.2", features = ["derive", "env"] }
chrono = "0.4.24"
google-datastore1 = "=5.0.4"
google-secretmanager1 = "5"
hex = "0.4.3"
hkdf = "0.12.4"
highway = "1.1.0"
hyper = { version = "0.14", features = ["full"] }
hyper-rustls = { version = "=0.24", features = ["http2"] }
k256 = { version = "0.13.1", features = ["sha256", "ecdsa", "serde"] }
local-ip-address = "0.5.4"
rand = "0.8"
reqwest = { version = "0.11.16", features = ["blocking", "json"] }
semver = "1.0.23"
sha3 = "0.10.8"
serde = { version = "1", features = ["derive"] }
serde_bytes = "0.11.15"
serde_json = "1"
thiserror = "1"
tokio = { version = "1.28", features = ["full"] }
tokio-retry = "0.3"
tracing = "0.1"
Expand All @@ -44,17 +34,29 @@ tracing-stackdriver = "0.10.0"
web3 = "0.19.0"
url = { version = "2.4.0", features = ["serde"] }

near-account-id = "1.0.0"
# workspace dependencies
anyhow.workspace = true
borsh.workspace = true
cait-sith.workspace = true
hex.workspace = true
k256.workspace = true
rand.workspace = true
serde.workspace = true
serde_json.workspace = true
sha3.workspace = true
thiserror.workspace = true

near-account-id.workspace = true
near-crypto = "0.26.0"
near-fetch = "0.6.0"
near-lake-framework = { git = "https://github.com/near/near-lake-framework-rs", branch = "node/2.3.0" }
near-lake-primitives = { git = "https://github.com/near/near-lake-framework-rs", branch = "node/2.3.0" }
near-primitives = "0.26.0"
near-sdk = { version = "5.2.1", features = ["legacy", "unit-testing"] }
near-sdk.workspace = true

mpc-contract = { path = "../contract" }
mpc-keys = { path = "../keys" }
crypto-shared = { path = "../crypto-shared" }
mpc-contract.workspace = true
mpc-keys.workspace = true
mpc-crypto.workspace = true

http = "1.1.0"
prometheus = { version = "0.13.3" }
Expand Down
2 changes: 1 addition & 1 deletion chain-signatures/node/src/indexer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::protocol::Chain::NEAR;
use crate::protocol::{Chain, SignRequest};
use crate::storage::app_data_storage::AppDataStorage;
use crypto_shared::{derive_epsilon, ScalarExt};
use k256::Scalar;
use mpc_crypto::{derive_epsilon, ScalarExt};
use near_account_id::AccountId;
use near_lake_framework::{Lake, LakeBuilder, LakeContext};
use near_lake_primitives::actions::ActionMetaDataExt;
Expand Down
Loading

0 comments on commit 11fc78c

Please sign in to comment.