Skip to content

Commit 9adb1a4

Browse files
committed
chore: update vetkd_public_key permission
1 parent 14d2283 commit 9adb1a4

File tree

4 files changed

+25
-31
lines changed

4 files changed

+25
-31
lines changed

Cargo.lock

Lines changed: 10 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ strip = true
1414
opt-level = 's'
1515

1616
[workspace.package]
17-
version = "0.8.7"
17+
version = "0.8.8"
1818
edition = "2021"
1919
repository = "https://github.com/ldclabs/ic-cose"
2020
keywords = ["config", "cbor", "canister", "icp", "encryption"]

src/ic_cose/examples/vetkeys.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ async fn main() {
3939
version: 1,
4040
};
4141

42-
let (vk, dkp) = cli.vetkey(&path).await.unwrap();
42+
let (vk, dpk) = cli.vetkey(&path).await.unwrap();
4343
println!("VetKey: {:?}", hex::encode(vk.signature_bytes()));
4444
// VetKey: "8a4554dec6eeb1ab95574005c477ed5a8dadb0acb5d4c7c911771a16d974bcd61db63bd2a89eeb174fc96b58ca9d5eca"
45-
println!("Derived Public Key: {:?}", hex::encode(dkp.serialize()));
45+
println!("Derived Public Key: {:?}", hex::encode(dpk.serialize()));
4646
// Derived Public Key: "81b09cdf3a525448978fd72532e19b9fbc8ec7d025af4b5fa2c1f85ef007fdb8946be1ccc288c623acf1bf1fa43cac5f1098012a4f91663eaa73894487c94b4b335af8a224e9e30ca136bad8bfdc2b7fc16f0424f66e88553713852ea04b27a8"
4747

4848
let ibe_seed: [u8; 32] = rand_bytes();
4949
let ibe_seed = IbeSeed::from_bytes(&ibe_seed).unwrap();
5050
let ibe_id = IbeIdentity::from_bytes(&path.key);
5151
let msg = b"Hello, LDC Labs!";
52-
let ciphertext = IbeCiphertext::encrypt(&dkp, &ibe_id, msg, &ibe_seed);
52+
let ciphertext = IbeCiphertext::encrypt(&dpk, &ibe_id, msg, &ibe_seed);
5353
let data = ciphertext.serialize();
5454
println!("Ciphertext: {:?}", hex::encode(&data));
5555

src/ic_cose_canister/src/api_cose.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,18 @@ async fn vetkd_public_key(path: SettingPath) -> Result<ByteBuf, String> {
130130
path.validate()?;
131131

132132
let caller = ic_cdk::api::msg_caller();
133-
let spk = store::SettingPathKey::from_path(path, caller);
134-
if !store::ns::has_kek_permission(&caller, &spk) {
135-
Err(format!(
136-
"vetkd_public_key: {} has no permission for {}",
137-
caller.to_text(),
138-
spk
139-
))?;
140-
}
133+
store::ns::with(&path.ns, |ns| {
134+
if !ns.can_read_namespace(&caller) {
135+
return Err(format!(
136+
"vetkd_public_key: {} has no permission for {}",
137+
caller.to_text(),
138+
path.ns
139+
))?;
140+
}
141+
Ok(())
142+
})?;
141143

144+
let spk = store::SettingPathKey::from_path(path, caller);
142145
let pk = store::ns::inner_vetkd_public_key(&spk).await?;
143146
Ok(ByteBuf::from(pk))
144147
}

0 commit comments

Comments
 (0)