Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

[V2.0] DID fragments instead of MethodID #266

Merged
merged 24 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ members = [
"streams",
]

resolver = "2"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required because of an identity feature (Identity also needs this now)


[profile.dev]
incremental = true
4 changes: 2 additions & 2 deletions lets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tangle-client = ["iota-client/async", "futures", "iota-crypto/blake2b"]
# Enable the wasm-compatible IOTA-Tangle transport client (incompatile with `tangle-client` feature due to `iota-client/async` using `tokio`. Implies `std` feature)
tangle-client-wasm = ["iota-client/wasm", "futures"]
# Enable Iota Identity for use with Streams
did = ["identity", "serde"]
did = ["identity_iota", "serde"]

[dependencies]
# Local dependencies
Expand All @@ -37,6 +37,6 @@ hex = {version = "0.4", default-features = false}

# Optional dependencies
futures = {version = "0.3.8", default-features = false, optional = true}
identity = {git = "https://github.com/iotaledger/identity.rs", rev = "86edaad", default-features = false, features = ["async"], optional = true}
identity_iota = {git = "https://github.com/iotaledger/identity.rs", rev = "d3920c2", default-features = false, optional = true}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing that this rev already takes the new package name used for releasing to crates.io, I wonder if we couldn't actually use version = "0.6.1" instead of using the git rev. We will have to do it anyway at some point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didnt work due to an identity error internally when compiling :P

error[E0432]: unresolved import `identity_did::revocation`
  --> /home/brord/.cargo/registry/src/github.com-1ecc6299db9ec823/identity_iota_client-0.6.1/src/credential/credential_validator.rs:11:19
   |
11 | use identity_did::revocation::RevocationBitmap;
   |                   ^^^^^^^^^^ could not find `revocation` in `identity_did`

iota-client = {version = "1.1.1", default-features = false, optional = true}
serde = {version = "1.0", default-features = false, features = ["derive"], optional = true}
13 changes: 5 additions & 8 deletions lets/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,11 @@ impl AppAddr {
}

pub fn gen(identifier: &Identifier, base_topic: &Topic) -> AppAddr {
let mut addr = [0u8; 40];
let id_bytes = identifier.as_bytes();
// Create spongos to squeeze topic into final 8 bytes
let squeezed_topic: [u8; 8] = Spongos::<KeccakF1600>::init().sponge(base_topic);
assert_eq!(id_bytes.len(), 32, "identifier must be 32 bytes long");
addr[..32].copy_from_slice(id_bytes);
addr[32..].copy_from_slice(&squeezed_topic);
Self::new(addr)
let mut spongos = Spongos::<KeccakF1600>::init();
spongos.absorb(base_topic);
spongos.absorb(identifier);
spongos.commit();
spongos.squeeze()
}

/// Get the hexadecimal representation of the appaddr
Expand Down
282 changes: 0 additions & 282 deletions lets/src/id/did.rs

This file was deleted.

50 changes: 50 additions & 0 deletions lets/src/id/did/data_wrapper.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// 3rd-party
use serde::Serialize;

use identity_iota::{
crypto::{GetSignature, GetSignatureMut, Proof, SetSignature},
did::{MethodUriType, TryMethod},
};

#[derive(Serialize)]
pub(crate) struct DataWrapper<'a> {
data: &'a [u8],
signature: Option<Proof>,
}

impl<'a> DataWrapper<'a> {
pub(crate) fn new(data: &'a [u8]) -> Self {
Self { data, signature: None }
}

pub(crate) fn with_signature(mut self, signature: Proof) -> Self {
self.signature = Some(signature);
self
}

pub(crate) fn into_signature(self) -> Option<Proof> {
self.signature
}
}

impl<'a> GetSignature for DataWrapper<'a> {
fn signature(&self) -> Option<&Proof> {
self.signature.as_ref()
}
}

impl<'a> GetSignatureMut for DataWrapper<'a> {
fn signature_mut(&mut self) -> Option<&mut Proof> {
self.signature.as_mut()
}
}

impl<'a> SetSignature for DataWrapper<'a> {
fn set_signature(&mut self, signature: Proof) {
self.signature = Some(signature)
}
}

impl<'a> TryMethod for DataWrapper<'a> {
const TYPE: MethodUriType = MethodUriType::Absolute;
}
Loading