Skip to content

Add ERC: HD wallet In Treasury Management #978

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
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

elizabethxiaoyu
Copy link

When opening a pull request to submit a new EIP, please use the suggested template: https://github.com/ethereum/EIPs/blob/master/eip-template.md

We have a GitHub bot that automatically merges some PRs. It will merge yours immediately if certain criteria are met:

  • The PR edits only existing draft PRs.
  • The build passes.
  • Your GitHub username or email address is listed in the 'author' header of all affected PRs, inside .
  • If matching on email address, the email address is the one publicly listed on your GitHub profile.

@eip-review-bot
Copy link
Collaborator

eip-review-bot commented Mar 17, 2025

File ERCS/erc-7908.md

Requires 1 more reviewers from @g11tech, @SamWilsn, @xinbenlv

@eip-review-bot eip-review-bot changed the title New ERCTreasury hd wallet proposal Add ERC: Deterministic Account Hierarchy In Treasury Management Mar 17, 2025
@elizabethxiaoyu
Copy link
Author

Comment on lines 88 to 104
```python
entity_hash = sha256(f"ENTITY:{entity}".encode()).digest()
entity_index = (int.from_bytes(entity_hash[:4], "big") % 2**31) + 2**31 # 2^31 ≤ index < 2^32
```

2. **Department Index Calculation**

- **MUST** compute `department_id` as:

```python
dept_hash = sha256(f"DEPT:{entity_hash}:{department}".encode()).digest()
dept_index = (int.from_bytes(dept_hash[:4], "big") % 2^31) + 2^31
```

3. **Output Constraints**

- Generated indices **MUST** be integers in `[2^31, 2^32-1]` to enforce hardened derivation.

Choose a reason for hiding this comment

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

The current calculation method in this proposal is (89-90):

entity_hash = sha256(f"ENTITY:{entity}".encode()).digest()  
entity_index = (int.from_bytes(entity_hash[:4], "big") % 2**31) + 2**31

Some problems to this:

Range Limitation: looking at line 104 it states indices must be in the range [2^31, 2^32-1] for hardened derivation, the modulo operation unnecessarily restricts the possible values, reducing entropy.
Entropy Loss: Taking the modulo of the hash value with 2^31 means we're only using approximately 30 bits of entropy from the original 32 bits (4 bytes), potentially increasing collision risk.
Implementation Inconsistency: The code example uses % 2^31 which in Python would be interpreted as a bitwise XOR operation rather than exponentiation (should be % 2**31)?

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your comments, I have optimized logic in the last pr: remain 32 bits to decrease collision risk and modify typo


6. **Account Index (**`account_index`**)**

- **MUST** use non-hardened derivation to allow unified account management.

Choose a reason for hiding this comment

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

What happens if the parent public key is compromised?

Copy link
Author

@elizabethxiaoyu elizabethxiaoyu Mar 18, 2025

Choose a reason for hiding this comment

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

The design of unreinforced derivation makes it possible for the parent private key to be derived once both of the following conditions are met:

  1. The parent public key (xpub) and chain code are known (xpub is public).
  2. A child private key is leaked.
    but convenience and risk need to balance~ and risk notify has been added in chapter "Security Considerations"

Comment on lines 25 to 28
This proposal aims to provide a standardized method for on-chain treasury management of institutional assets, ensuring
secure private key generation, hierarchical management, and departmental permission isolation while supporting asset
security and transaction efficiency in multi-chain environments. By defining a unified derivation path and security
mechanisms, this proposal offers an efficient and secure solution for treasury management.

Choose a reason for hiding this comment

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

Suggested change
This proposal aims to provide a standardized method for on-chain treasury management of institutional assets, ensuring
secure private key generation, hierarchical management, and departmental permission isolation while supporting asset
security and transaction efficiency in multi-chain environments. By defining a unified derivation path and security
mechanisms, this proposal offers an efficient and secure solution for treasury management.
This proposal aims to provide a standardized method for on-chain treasury management of institutional assets, ensuring secure private key generation, hierarchical management, and departmental permission isolation while supporting asset security and transaction efficiency in multi-chain environments. By defining a unified derivation path and security mechanisms, this proposal offers an efficient and secure solution for treasury management.

Copy link
Author

Choose a reason for hiding this comment

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

updated

Comment on lines 32 to 35
With the rapid development of blockchain and DeFi, secure management of on-chain assets has become critical. Traditional
private key management struggles to meet the security demands of large organizations in complex scenarios, where
hierarchical key management, permission controls, and multi-signature mechanisms are essential. This proposal provides a
standardized solution for institutional treasury management, ensuring asset security and transaction efficiency.

Choose a reason for hiding this comment

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

Suggested change
With the rapid development of blockchain and DeFi, secure management of on-chain assets has become critical. Traditional
private key management struggles to meet the security demands of large organizations in complex scenarios, where
hierarchical key management, permission controls, and multi-signature mechanisms are essential. This proposal provides a
standardized solution for institutional treasury management, ensuring asset security and transaction efficiency.
With the rapid development of blockchain and DeFi, secure management of on-chain assets has become critical. Traditional private key management struggles to meet the security demands of large organizations in complex scenarios, where hierarchical key management, permission controls, and multi-signature mechanisms are essential. This proposal provides a standardized solution for institutional treasury management, ensuring asset security and transaction efficiency.

Copy link
Author

Choose a reason for hiding this comment

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

updated

Comment on lines 382 to 384
For treasury managers, hierarchical deterministic wallet management is more convenient, but it requires additional
consideration of protective measures for the master key, such as schemes for splitting and storing mnemonic phrases or
master keys.

Choose a reason for hiding this comment

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

Suggested change
For treasury managers, hierarchical deterministic wallet management is more convenient, but it requires additional
consideration of protective measures for the master key, such as schemes for splitting and storing mnemonic phrases or
master keys.
For treasury managers, hierarchical deterministic wallet management is more convenient, but it requires additional consideration of protective measures for the master key, such as schemes for splitting and storing mnemonic phrases or master keys.

Copy link
Author

Choose a reason for hiding this comment

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

updated

@elizabethxiaoyu
Copy link
Author

@eip-review-bot can scan again?

@github-actions github-actions bot added w-ci and removed w-ci labels Mar 19, 2025
@eip-review-bot eip-review-bot changed the title Add ERC: Deterministic Account Hierarchy In Treasury Management Add ERC: HD wallet In Treasury Management Mar 19, 2025
@github-actions github-actions bot added w-ci and removed w-ci labels Mar 19, 2025
@github-actions github-actions bot removed the w-ci label Mar 19, 2025
Copy link

The commit cf60b35 (as a parent of 7f90365) contains errors.
Please inspect the Run Summary for details.

@github-actions github-actions bot added the w-ci label Mar 19, 2025
@github-actions github-actions bot removed the w-ci label Mar 19, 2025
@elizabethxiaoyu
Copy link
Author

@eip-review-bot @g11tech @SamWilsn @xinbenlv , could you kindly review this pull request? All checks have been successfully completed. Thank you!

@SamWilsn
Copy link
Contributor

Friendly reminder to keep technical discussion on the discussion thread and not on the pull requests. Discussions here should only be for formatting and editorial comments. It's too easy to lose context across pull requests otherwise.

@elizabethxiaoyu
Copy link
Author

elizabethxiaoyu commented Apr 8, 2025

Friendly reminder to keep technical discussion on the discussion thread and not on the pull requests. Discussions here should only be for formatting and editorial comments. It's too easy to lose context across pull requests otherwise.

Hi,SamWilsn @SamWilsn , can kindly help to pass merge request? I have already passed all auto checks. Thank you very much~

@elizabethxiaoyu elizabethxiaoyu changed the title Add ERC: HD wallet In Treasury Management Add ERC-7908: HD wallet In Treasury Management Apr 8, 2025
@eip-review-bot eip-review-bot changed the title Add ERC-7908: HD wallet In Treasury Management Add ERC: HD wallet In Treasury Management Apr 17, 2025
@elizabethxiaoyu elizabethxiaoyu changed the title Add ERC: HD wallet In Treasury Management ERC-7908: HD wallet In Treasury Management Apr 24, 2025
@eip-review-bot eip-review-bot changed the title ERC-7908: HD wallet In Treasury Management Add ERC: HD wallet In Treasury Management Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants