Skip to content

Commit

Permalink
fix: fix ecdh_cose_encrypted_key API
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Nov 4, 2024
1 parent be30ba3 commit e800f3a
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ strip = true
opt-level = 's'

[workspace.package]
version = "0.3.5"
version = "0.3.6"
edition = "2021"
repository = "https://github.com/ldclabs/ic-cose"
keywords = ["config", "cbor", "canister", "icp", "encryption"]
Expand Down
6 changes: 3 additions & 3 deletions src/ic_cose_canister/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl Setting {
}

// SettingPathKey: (namespace name, 0 or 1, subject, setting name, version)
#[derive(Clone, Deserialize, Serialize, Ord, PartialOrd, Eq, PartialEq)]
#[derive(Clone, Debug, Deserialize, Serialize, Ord, PartialOrd, Eq, PartialEq)]
pub struct SettingPathKey(pub String, pub u8, pub Principal, pub ByteBuf, pub u32);

impl SettingPathKey {
Expand Down Expand Up @@ -689,9 +689,9 @@ pub mod ns {
pub fn inner_derive_kek(spk: &SettingPathKey, key_id: &[u8]) -> Result<[u8; 32], String> {
state::with(|s| {
let pk = s
.schnorr_secp256k1_public_key
.schnorr_ed25519_public_key
.as_ref()
.ok_or("no schnorr secp256k1 public key")?;
.ok_or("no schnorr ed25519 public key")?;

let derivation_path = vec![
b"COSE_Symmetric_Key".to_vec(),
Expand Down
2 changes: 1 addition & 1 deletion src/ic_cose_types/src/cose/ecdh.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use x25519_dalek::{PublicKey, SharedSecret, StaticSecret};
pub use x25519_dalek::{PublicKey, SharedSecret, StaticSecret};

pub fn ecdh_x25519(secret: [u8; 32], their_public: [u8; 32]) -> (SharedSecret, PublicKey) {
let secret = StaticSecret::from(secret);
Expand Down
1 change: 0 additions & 1 deletion src/ic_cose_types/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub mod state;

pub use setting::SettingPath;

// should update to ICRC3Map
pub type MapValue =
BTreeMap<String, icrc_ledger_types::icrc::generic_metadata_value::MetadataValue>;

Expand Down
4 changes: 2 additions & 2 deletions src/ic_cose_types/src/types/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct NamespaceInfo {
pub gas_balance: u128, // cycles
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
#[derive(CandidType, Clone, Debug, Default, Deserialize, Serialize)]
pub struct CreateNamespaceInput {
pub name: String,
pub visibility: u8, // 0: private; 1: public
Expand Down Expand Up @@ -58,7 +58,7 @@ impl CreateNamespaceInput {
}
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
#[derive(CandidType, Clone, Debug, Default, Deserialize, Serialize)]
pub struct UpdateNamespaceInput {
pub name: String,
pub desc: Option<String>,
Expand Down
8 changes: 4 additions & 4 deletions src/ic_cose_types/src/types/setting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct SettingInfo {
pub payload: Option<ByteBuf>, // encrypted or plain payload
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
#[derive(CandidType, Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
pub struct SettingPath {
pub ns: String,
pub user_owned: bool,
Expand All @@ -47,7 +47,7 @@ pub fn try_decode_payload(payload: &[u8]) -> Result<Value, String> {
from_reader(payload).map_err(|err| format!("decode CBOR payload failed: {:?}", err))
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
#[derive(CandidType, Clone, Debug, Default, Deserialize, Serialize)]
pub struct CreateSettingInput {
pub payload: Option<ByteBuf>,
pub desc: Option<String>,
Expand Down Expand Up @@ -84,7 +84,7 @@ pub struct CreateSettingOutput {
pub version: u32,
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
#[derive(CandidType, Clone, Debug, Default, Deserialize, Serialize)]
pub struct UpdateSettingInfoInput {
pub desc: Option<String>,
pub status: Option<i8>,
Expand All @@ -107,7 +107,7 @@ impl UpdateSettingInfoInput {
}
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
#[derive(CandidType, Clone, Debug, Default, Deserialize, Serialize)]
pub struct UpdateSettingPayloadInput {
pub payload: Option<ByteBuf>, // plain or encrypted payload
pub status: Option<i8>,
Expand Down

0 comments on commit e800f3a

Please sign in to comment.