Skip to content

Commit

Permalink
chore: cleanup dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Aug 21, 2024
1 parent 57e8be5 commit 5933422
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 388 deletions.
278 changes: 51 additions & 227 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,21 @@ strip = true
opt-level = 's'

[workspace.package]
version = "0.1.0"
version = "0.1.1"
edition = "2021"
repository = "https://github.com/ldclabs/ic-cose"
keywords = ["config", "cbor", "canister", "icp", "encryption"]
categories = ["web-programming"]
license = "MIT OR Apache-2.0"

[workspace.dependencies]
async-trait = "0.1"
bytes = "1"
base64 = "0.21"
candid = "0.10"
ciborium = "0.2"
ciborium-io = "0.2"
futures = "0.3"
futures-util = "0.3"
log = "0.4"
serde = "1"
serde_bytes = "0.11"
serde_json = { version = "1", features = ["preserve_order"] }
structured-logger = "1"
tokio = { version = "1", features = ["full"] }
k256 = { version = "0.13", features = ["ecdsa", "schnorr"] }
ed25519-dalek = "2"
x25519-dalek = { version = "2", features = ["static_secrets"] }
hex = "0.4"
hmac = "0.12"
sha2 = "0.10"
sha3 = "0.10"
Expand All @@ -43,11 +32,6 @@ ic-cdk = "0.15"
ic-cdk-timers = "0.8"
ic-stable-structures = "0.6"
icrc-ledger-types = "0.1"
ic-http-certification = { version = "2.5", features = ["serde"] }
anyhow = "1"
crc32fast = "1.4"
url = "2.5"
once_cell = "1.19"
getrandom = { version = "0.2", features = ["custom"] }
coset = "0.3.8"
aes-gcm = "0.10"
14 changes: 0 additions & 14 deletions src/ic_cose_canister/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,14 @@ license.workspace = true
crate-type = ["cdylib"]

[dependencies]
bytes = { workspace = true }
candid = { workspace = true }
ciborium = { workspace = true }
sha2 = { workspace = true }
sha3 = { workspace = true }
ic-cdk = { workspace = true }
hex = { workspace = true }
hmac = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_bytes = { workspace = true }
base64 = { workspace = true }
num-traits = { workspace = true }
once_cell = { workspace = true }
ic-cdk-timers = { workspace = true }
ic-stable-structures = { workspace = true }
ic-http-certification = { workspace = true }
ed25519-dalek = { workspace = true }
x25519-dalek = { workspace = true }
lazy_static = "1.4"
getrandom = { version = "0.2", features = ["custom"] }
ic_cose_types = { path = "../ic_cose_types", version = "0.1" }
ic-crypto-extended-bip32 = { git = "https://github.com/dfinity/ic/", rev = "d19fa446ab35780b2c6d8b82ea32d808cca558d5" }
ic-crypto-ed25519 = { git = "https://github.com/dfinity/ic/", rev = "d19fa446ab35780b2c6d8b82ea32d808cca558d5" }
icrc-ledger-types = { git = "https://github.com/dfinity/ic/", rev = "d19fa446ab35780b2c6d8b82ea32d808cca558d5" }
14 changes: 9 additions & 5 deletions src/ic_cose_canister/src/api_cose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use ic_cose_types::{
CosePath, ECDHInput, ECDHOutput, PublicKeyInput, PublicKeyOutput, SchnorrAlgorithm,
SignIdentityInput, SignInput,
},
validate_key, ByteN, MILLISECONDS,
validate_key, MILLISECONDS,
};
use serde_bytes::ByteBuf;
use serde_bytes::{ByteArray, ByteBuf};

use crate::{is_authenticated, rand_bytes, store};

Expand Down Expand Up @@ -135,7 +135,7 @@ async fn vetkd_public_key(path: CosePath) -> Result<ByteBuf, String> {
}

#[ic_cdk::update(guard = "is_authenticated")]
async fn vetkd_encrypted_key(path: CosePath, public_key: ByteN<48>) -> Result<ByteBuf, String> {
async fn vetkd_encrypted_key(path: CosePath, public_key: ByteArray<48>) -> Result<ByteBuf, String> {
path.validate()?;

let caller = ic_cdk::caller();
Expand All @@ -148,7 +148,11 @@ async fn vetkd_encrypted_key(path: CosePath, public_key: ByteN<48>) -> Result<By
Ok(())
})?;

let ek =
store::ns::inner_vetkd_encrypted_key(&spk, key_id.into_vec(), public_key.into()).await?;
let ek = store::ns::inner_vetkd_encrypted_key(
&spk,
key_id.into_vec(),
public_key.into_array().into(),
)
.await?;
Ok(ByteBuf::from(ek))
}
4 changes: 2 additions & 2 deletions src/ic_cose_canister/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use candid::Principal;
use ic_cose_types::{
format_error, types::namespace::*, types::setting::*, types::state::StateInfo, types::*, ByteN,
format_error, types::namespace::*, types::setting::*, types::state::StateInfo, types::*,
ANONYMOUS,
};
use serde_bytes::ByteBuf;
use serde_bytes::{ByteArray, ByteBuf};
use std::collections::BTreeSet;

mod api_admin;
Expand Down
4 changes: 0 additions & 4 deletions src/ic_cose_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ categories.workspace = true
license.workspace = true

[dependencies]
base64 = { workspace = true }
candid = { workspace = true }
hex = { workspace = true }
serde = { workspace = true }
serde_bytes = { workspace = true }
crc32fast = { workspace = true }
num-traits = { workspace = true }
url = { workspace = true }
ciborium = { workspace = true }
icrc-ledger-types = { workspace = true }
k256 = { workspace = true }
Expand Down
105 changes: 0 additions & 105 deletions src/ic_cose_types/src/bytes.rs

This file was deleted.

6 changes: 0 additions & 6 deletions src/ic_cose_types/src/cose/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ where
format!("{:?}", err)
}

pub fn crc32(data: &[u8]) -> u32 {
let mut h = crc32fast::Hasher::new();
h.update(data);
h.finalize()
}

pub fn sha256(data: &[u8]) -> [u8; 32] {
let mut hasher = sha2::Sha256::new();
hasher.update(data);
Expand Down
2 changes: 0 additions & 2 deletions src/ic_cose_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ use ciborium::into_writer;
use serde::Serialize;
use std::{collections::BTreeSet, ops::Deref};

pub mod bytes;
pub mod cose;
pub mod types;

pub use bytes::*;
pub use cose::format_error;

pub static ANONYMOUS: Principal = Principal::anonymous();
Expand Down
12 changes: 6 additions & 6 deletions src/ic_cose_types/src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use candid::{CandidType, Principal};
use serde::{Deserialize, Serialize};
use serde_bytes::ByteBuf;
use serde_bytes::{ByteArray, ByteBuf};
use std::collections::BTreeMap;

pub mod namespace;
pub mod setting;
pub mod state;

use crate::{bytes::ByteN, validate_key};
use crate::validate_key;

// should update to ICRC3Map
pub type MapValue =
Expand Down Expand Up @@ -48,14 +48,14 @@ pub struct SignIdentityInput {

#[derive(CandidType, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct ECDHInput {
pub nonce: ByteN<12>, // should be random for each request
pub public_key: ByteN<32>, // client side ECDH public key
pub nonce: ByteArray<12>, // should be random for each request
pub public_key: ByteArray<32>, // client side ECDH public key
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct ECDHOutput<T> {
pub payload: T, // should be random for each request
pub public_key: ByteN<32>, // server side ECDH public key
pub payload: T, // should be random for each request
pub public_key: ByteArray<32>, // server side ECDH public key
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
Expand Down

0 comments on commit 5933422

Please sign in to comment.