summaryrefslogtreecommitdiffstats
path: root/adenosine-pds/src/crypto.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-11-04 19:16:01 -0700
committerBryan Newbold <bnewbold@robocracy.org>2022-11-04 19:16:01 -0700
commitbc8493998d90799551c5e0703bbb4a6e69d2478a (patch)
tree482d0360ae7f395568e3cdf0fd48d2e5313e9eb9 /adenosine-pds/src/crypto.rs
parent5f220855db95d006e4168356759a5b871899d759 (diff)
downloadadenosine-bc8493998d90799551c5e0703bbb4a6e69d2478a.tar.gz
adenosine-bc8493998d90799551c5e0703bbb4a6e69d2478a.zip
pds: basic repo CRUD coming together
Diffstat (limited to 'adenosine-pds/src/crypto.rs')
-rw-r--r--adenosine-pds/src/crypto.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/adenosine-pds/src/crypto.rs b/adenosine-pds/src/crypto.rs
index 0720c07..1fa6f4c 100644
--- a/adenosine-pds/src/crypto.rs
+++ b/adenosine-pds/src/crypto.rs
@@ -6,7 +6,6 @@ use p256;
use p256::ecdsa::signature::{Signer, Verifier};
use std::str::FromStr;
use ucan::builder::UcanBuilder;
-use ucan::crypto::KeyMaterial;
// Need to:
//
@@ -66,12 +65,12 @@ impl KeyPair {
}
/// This is currently just an un-validated token; we don't actually verify these.
- pub fn ucan(&self) -> Result<String> {
+ pub fn ucan(&self, did: &str) -> Result<String> {
let key_material = self.ucan_keymaterial();
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?;
- rt.block_on(build_ucan(key_material))
+ rt.block_on(build_ucan(key_material, did))
}
pub fn to_hex(&self) -> String {
@@ -85,10 +84,10 @@ impl KeyPair {
}
}
-async fn build_ucan(key_material: P256KeyMaterial) -> Result<String> {
+async fn build_ucan(key_material: P256KeyMaterial, did: &str) -> Result<String> {
let token_string = UcanBuilder::default()
.issued_by(&key_material)
- .for_audience(key_material.get_did().await.unwrap().as_str())
+ .for_audience(did)
.with_nonce()
.with_lifetime(60 * 60 * 24 * 90)
.build()?