-
Notifications
You must be signed in to change notification settings - Fork 79
did:ethr spec compliance #698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mirceanis
wants to merge
36
commits into
spruceid:main
Choose a base branch
from
mirceanis:did-ethr-spec-compliance
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 31 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 7650eb9
chore: add on-chain identityOwner check
mirceanis 83fee37
feat: resolve address-based DID with changed owner
mirceanis 8ff2eeb
feat: owner changed on pubkey DID omits #controllerKey
mirceanis f7e6684
test: owner unchanged pubkey DID retains #controllerKey
mirceanis 330e754
test: multiple owner changes uses identityOwner() result
mirceanis 43f7038
refactor: remove unused is_public_key_did param from resolve_with_owner
mirceanis 5c295e8
feat: event history traversal via linked-list log walk
mirceanis 03ce6fc
feat: integrate collect_events into resolver, call alongside identity…
mirceanis 7d4a852
feat: veriKey delegate support with apply_events refactor
mirceanis 35375da
test: sigAuth, expired, revoked, multiple delegates, owner+delegate i…
mirceanis 9033f02
refactor: simplify delegate VM reference construction
mirceanis f4f3614
feat: secp256k1 veriKey encoding attribute support in apply_events
mirceanis 2e1e265
test: attribute support — sigAuth, services (URL+JSON), expiry, share…
mirceanis 1dfb4f3
feat: deactivation on null owner address
mirceanis cba9138
feat: add version_id/updated to Metadata, block_timestamps to MockPro…
mirceanis 68ee02d
test: complete metadata tests — versionId/updated on deactivation, JS…
mirceanis 39b7114
feat: add next_version_id/next_update to Metadata, collect_events ret…
mirceanis 1aa69dc
test: MockProvider: support per-block identityOwner for historical re…
mirceanis 4c52b0c
feat: historical resolution (?versionId=N)
mirceanis eda3460
refactor: clean up NetworkChain
mirceanis fec8d36
chore: add Eip712Method2021 to public-key DID documents
mirceanis c0a18f5
feat: update DID document event processing for spec compliance
mirceanis 8ca6b9e
fix: collect_events cycle guard for same-block previousChange
mirceanis 3827683
refactor: split lib.rs into focused modules
mirceanis bd8f910
refactor: simplify abi/network/resolver
mirceanis f70d335
perf: cache topic hashes; reduce vm.id() clones
mirceanis 8335667
feat: add resolve_with_provider example for did:ethr resolution via H…
mirceanis b02b526
feat: improve resolve_with_provider CLI usability and error handling
mirceanis fec12ab
feat: support registry address selection for did:ethr resolution; add…
mirceanis 61e544d
fix: ensure historical resolution uses target block timestamp for exp…
mirceanis 64ccd32
chore: remove unused bs58 dependency; add comment clarifying DEFAULT_…
mirceanis 5caf4db
fix: preserve intra-block event order by tracking log_index in event …
mirceanis 879e9d6
fix: better handling of keyPurpose for `enc` keys
mirceanis 3143b7e
fix: return None for AttributeChanged events with truncated value; ad…
mirceanis 1af150c
feat: validate provider chain ID against DID network; add chain_id to…
mirceanis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.