Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
835f214
chore: make DIDEthr<P=()> generic w/ EthProvider trait, ABI helpers, …
mirceanis Mar 9, 2026
7650eb9
chore: add on-chain identityOwner check
mirceanis Mar 9, 2026
83fee37
feat: resolve address-based DID with changed owner
mirceanis Mar 9, 2026
8ff2eeb
feat: owner changed on pubkey DID omits #controllerKey
mirceanis Mar 9, 2026
f7e6684
test: owner unchanged pubkey DID retains #controllerKey
mirceanis Mar 9, 2026
330e754
test: multiple owner changes uses identityOwner() result
mirceanis Mar 9, 2026
43f7038
refactor: remove unused is_public_key_did param from resolve_with_owner
mirceanis Mar 9, 2026
5c295e8
feat: event history traversal via linked-list log walk
mirceanis Mar 9, 2026
03ce6fc
feat: integrate collect_events into resolver, call alongside identity…
mirceanis Mar 9, 2026
7d4a852
feat: veriKey delegate support with apply_events refactor
mirceanis Mar 9, 2026
35375da
test: sigAuth, expired, revoked, multiple delegates, owner+delegate i…
mirceanis Mar 9, 2026
9033f02
refactor: simplify delegate VM reference construction
mirceanis Mar 9, 2026
f4f3614
feat: secp256k1 veriKey encoding attribute support in apply_events
mirceanis Mar 9, 2026
2e1e265
test: attribute support — sigAuth, services (URL+JSON), expiry, share…
mirceanis Mar 9, 2026
1dfb4f3
feat: deactivation on null owner address
mirceanis Mar 9, 2026
cba9138
feat: add version_id/updated to Metadata, block_timestamps to MockPro…
mirceanis Mar 9, 2026
68ee02d
test: complete metadata tests — versionId/updated on deactivation, JS…
mirceanis Mar 9, 2026
39b7114
feat: add next_version_id/next_update to Metadata, collect_events ret…
mirceanis Mar 9, 2026
1aa69dc
test: MockProvider: support per-block identityOwner for historical re…
mirceanis Mar 9, 2026
4c52b0c
feat: historical resolution (?versionId=N)
mirceanis Mar 9, 2026
eda3460
refactor: clean up NetworkChain
mirceanis Mar 9, 2026
fec8d36
chore: add Eip712Method2021 to public-key DID documents
mirceanis Mar 9, 2026
c0a18f5
feat: update DID document event processing for spec compliance
mirceanis Mar 10, 2026
8ca6b9e
fix: collect_events cycle guard for same-block previousChange
mirceanis Mar 10, 2026
3827683
refactor: split lib.rs into focused modules
mirceanis Mar 10, 2026
bd8f910
refactor: simplify abi/network/resolver
mirceanis Mar 10, 2026
f70d335
perf: cache topic hashes; reduce vm.id() clones
mirceanis Mar 10, 2026
8335667
feat: add resolve_with_provider example for did:ethr resolution via H…
mirceanis Mar 13, 2026
b02b526
feat: improve resolve_with_provider CLI usability and error handling
mirceanis Mar 13, 2026
fec12ab
feat: support registry address selection for did:ethr resolution; add…
mirceanis Mar 13, 2026
61e544d
fix: ensure historical resolution uses target block timestamp for exp…
mirceanis Mar 23, 2026
64ccd32
chore: remove unused bs58 dependency; add comment clarifying DEFAULT_…
mirceanis Mar 23, 2026
5caf4db
fix: preserve intra-block event order by tracking log_index in event …
mirceanis Mar 23, 2026
879e9d6
fix: better handling of keyPurpose for `enc` keys
mirceanis Mar 23, 2026
3143b7e
fix: return None for AttributeChanged events with truncated value; ad…
mirceanis Mar 23, 2026
1af150c
feat: validate provider chain ID against DID network; add chain_id to…
mirceanis Mar 23, 2026
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
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
json-syntax.workspace = true
ssi-dids = { workspace = true, features = ["example"] }
did-ethr.workspace = true
ssi-dids-core.workspace = true
hex.workspace = true
reqwest = { version = "0.12", features = ["json"] }
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }

[package.metadata.docs.rs]
all-features = true
Expand Down
5 changes: 5 additions & 0 deletions crates/crypto/src/hashes/keccak.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use keccak_hash::keccak;

/// Compute the keccak256 hash of arbitrary bytes.
pub fn keccak256(data: &[u8]) -> [u8; 32] {
keccak(data).to_fixed_bytes()
}

pub fn bytes_to_lowerhex(bytes: &[u8]) -> String {
use std::fmt::Write;
bytes.iter().fold("0x".to_owned(), |mut s, byte| {
Expand Down
11 changes: 10 additions & 1 deletion crates/dids/core/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,19 @@ pub enum InvalidData {
}

/// Document metadata.
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)]
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Metadata {
#[serde(skip_serializing_if = "Option::is_none")]
pub deactivated: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub version_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub next_version_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub next_update: Option<String>,
}

#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
Expand Down
6 changes: 6 additions & 0 deletions crates/dids/methods/ethr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ documentation = "https://docs.rs/did-ethr/"
ssi-dids-core.workspace = true
ssi-caips = { workspace = true, features = ["eip"] }
ssi-jwk.workspace = true
ssi-core.workspace = true
iref.workspace = true
static-iref.workspace = true
thiserror.workspace = true
hex.workspace = true
serde_json.workspace = true
ssi-crypto = { workspace = true, features = ["keccak"] }
ssi-multicodec.workspace = true
multibase.workspace = true
chrono.workspace = true
indexmap.workspace = true

[dev-dependencies]
tokio = { version = "1.0", features = ["macros"] }
Expand Down
65 changes: 65 additions & 0 deletions crates/dids/methods/ethr/src/abi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
use chrono::{DateTime, Utc};
use ssi_crypto::hashes::keccak;

// --- ERC-1056 ABI selectors ---

/// `changed(address)` — selector 0xf96d0f9f
pub(crate) const CHANGED_SELECTOR: [u8; 4] = [0xf9, 0x6d, 0x0f, 0x9f];

/// `identityOwner(address)` — selector 0x8733d4e8
pub(crate) const IDENTITY_OWNER_SELECTOR: [u8; 4] = [0x87, 0x33, 0xd4, 0xe8];

/// Encode a 20-byte address as a 32-byte ABI-padded word
pub(crate) fn abi_encode_address(addr: &[u8; 20]) -> [u8; 32] {
let mut word = [0u8; 32];
word[12..].copy_from_slice(addr);
word
}

/// Build calldata: 4-byte selector + 32-byte padded address
pub(crate) fn encode_call(selector: [u8; 4], addr: &[u8; 20]) -> Vec<u8> {
let mut data = Vec::with_capacity(36);
data.extend_from_slice(&selector);
data.extend_from_slice(&abi_encode_address(addr));
data
}

/// Decode a 32-byte uint256 return value.
/// Returns an error if the value overflows u64 (high 24 bytes non-zero).
pub(crate) fn decode_uint256(data: &[u8]) -> Result<u64, &'static str> {
if data.len() < 32 {
return Err("uint256 data too short");
}
if data[..24].iter().any(|&b| b != 0) {
return Err("uint256 overflows u64");
}
let mut bytes = [0u8; 8];
bytes.copy_from_slice(&data[24..32]);
Ok(u64::from_be_bytes(bytes))
}

/// Decode a 32-byte ABI-encoded address return value
pub(crate) fn decode_address(data: &[u8]) -> [u8; 20] {
if data.len() < 32 {
return [0u8; 20];
}
let mut addr = [0u8; 20];
addr.copy_from_slice(&data[12..32]);
addr
}

/// Convert raw 20 bytes to an EIP-55 checksummed hex address string
pub(crate) fn format_address_eip55(addr: &[u8; 20]) -> String {
let lowercase = format!("0x{}", hex::encode(addr));
keccak::eip55_checksum_addr(&lowercase).unwrap_or(lowercase)
}

/// Format a Unix timestamp (seconds since epoch) as ISO 8601 UTC string
pub(crate) fn format_timestamp_iso8601(unix_secs: u64) -> String {
let secs = i64::try_from(unix_secs).ok();
secs.and_then(|s| DateTime::<Utc>::from_timestamp(s, 0))
.map(|dt| dt.format("%Y-%m-%dT%H:%M:%SZ").to_string())
.unwrap_or_else(|| "1970-01-01T00:00:00Z".to_string())
}

pub(crate) use keccak::keccak256;
Loading