Skip to content

Commit c1da6cf

Browse files
authored
Update ERC-7627: To reduce gas costs, the variable type was changed.
Merged by EIP-Bot.
1 parent 4800bc3 commit c1da6cf

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

ERCS/erc-7627.md

+17-11
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ pragma solidity ^0.8.0;
3939
4040
interface IERC7627 {
4141
42+
enum PublicKeyAlgorithm { RSA, ECDSA, ED25519, DSA, DH, ECDH, X25519 }
43+
4244
// Events
4345
4446
/**
@@ -48,7 +50,7 @@ interface IERC7627 {
4850
* @param sessionId The session ID of the message.
4951
* @param encryptedMessage The encrypted message.
5052
*/
51-
event MessageSent(address indexed from, address indexed to, string sessionId, bytes encryptedMessage);
53+
event MessageSent(address indexed from, address indexed to, bytes32 sessionId, bytes encryptedMessage);
5254
5355
/**
5456
* @dev Event emitted when a user updates their public key.
@@ -65,15 +67,15 @@ interface IERC7627 {
6567
* @param _publicKey The public key of the user.
6668
* @param _algorithm The algorithm used for the public key.
6769
*/
68-
function updatePublicKey(bytes memory _publicKey, PublicKeyAlgorithm _algorithm) external;
70+
function updatePublicKey(bytes calldata _publicKey, PublicKeyAlgorithm _algorithm) external;
6971
7072
/**
7173
* @dev Function to send an encrypted message from one user to another.
7274
* @param _to The address of the recipient.
7375
* @param _sessionId The session ID of the message.
7476
* @param _encryptedMessage The encrypted message.
7577
*/
76-
function sendMessage(address _to, string memory _sessionId, bytes memory _encryptedMessage) external;
78+
function sendMessage(address _to, bytes32 _sessionId, bytes calldata _encryptedMessage) external;
7779
7880
/**
7981
* @dev Function to retrieve a user's public key and algorithm.
@@ -87,7 +89,7 @@ interface IERC7627 {
8789

8890
## Rationale
8991

90-
Traditional messaging lacks security and transparency for blockchain communication. The choice of asymmetric encryption ensures the confidentiality and integrity of messages, which is why we opted for this encryption method. Providing a unified interface enables easy integration of encrypted communication into smart contracts, thereby fostering innovation. Encrypted messaging guarantees adherence to best practices in data security. The interface supports various encryption methods, enhancing adaptability. Event tracking enhances the observability and auditability of the contract, aiding compliance efforts. Standardization promotes interoperability, facilitating seamless communication across platforms.
92+
Traditional messaging lacks security and transparency for blockchain communication. The choice of asymmetric encryption ensures the confidentiality and integrity of messages, which is why we opted for this encryption method. Providing a unified interface enables easy integration of encrypted communication into smart contracts, thereby fostering innovation. Encrypted messaging guarantees adherence to best practices in data security. Due to security reasons, public keys need to be regularly updated, hence we have added a feature that allows users to autonomously update their public keys. The interface supports various encryption methods, enhancing adaptability. Event tracking enhances the observability and auditability of the contract, aiding compliance efforts. Standardization promotes interoperability, facilitating seamless communication across platforms.
9193

9294
## Reference Implementation
9395

@@ -105,18 +107,18 @@ contract ERC7627 {
105107
106108
mapping(address => UserInfo) public pk;
107109
108-
event MessageSent(address indexed from, address indexed to, string sessionId, bytes encryptedMessage);
110+
event MessageSent(address indexed from, address indexed to, bytes32 sessionId, bytes encryptedMessage);
109111
event PublicKeyUpdated(address indexed user, bytes newPublicKey, PublicKeyAlgorithm algorithm);
110112
111113
// Function to register a user with their public key
112-
function updatePublicKey(bytes memory _publicKey, PublicKeyAlgorithm _algorithm) public {
114+
function updatePublicKey(bytes calldata _publicKey, PublicKeyAlgorithm _algorithm) public {
113115
pk[msg.sender].publicKey = _publicKey;
114116
pk[msg.sender].algorithm = _algorithm;
115117
emit PublicKeyUpdated(msg.sender, _publicKey, _algorithm);
116118
}
117119
118120
// Function to send an encrypted message from one user to another
119-
function sendMessage(address _to, string memory _sessionId, bytes memory _encryptedMessage) public {
121+
function sendMessage(address _to, bytes32 _sessionId, bytes calldata _encryptedMessage) public {
120122
emit MessageSent(msg.sender, _to, _sessionId, _encryptedMessage);
121123
}
122124
@@ -130,13 +132,17 @@ contract ERC7627 {
130132

131133
## Security Considerations
132134

133-
1. Utilization of Latest Secure Encryption Algorithms: When selecting encryption algorithms, it is essential to stay informed about the latest security news and recommendations. Avoid using asymmetric encryption algorithms with known vulnerabilities or those not recommended to ensure the confidentiality and integrity of messages. Regularly update encryption algorithms to address evolving security threats.
135+
### 1. Utilization of Latest Secure Encryption Algorithms:
136+
When selecting encryption algorithms, it is essential to stay informed about the latest security news and recommendations. Avoid using asymmetric encryption algorithms with known vulnerabilities or those not recommended to ensure the confidentiality and integrity of messages. Regularly update encryption algorithms to address evolving security threats.
134137

135-
2. Strict Encryption Using Public Keys for Message Content: To maintain message confidentiality, the content of sent messages must be strictly encrypted using the recipient's public key. Any plaintext information transmitted could lead to information leakage and security risks. Encrypt message content at all times during transmission and storage to prevent unauthorized access to sensitive information.
138+
### 2. Strict Encryption Using Public Keys for Message Content:
139+
To maintain message confidentiality, the content of sent messages must be strictly encrypted using the recipient's public key. Any plaintext information transmitted could lead to information leakage and security risks. Encrypt message content at all times during transmission and storage to prevent unauthorized access to sensitive information.
136140

137-
3. Key Management and Protection: Robust key management and protection measures are necessary for both user public and private keys. Ensure secure storage and transmission of keys to prevent leakage and tampering. Employ multi-factor authentication and key rotation strategies to enhance key security and regularly assess key management processes to mitigate potential security risks.
141+
### 3. Key Management and Protection:
142+
Robust key management and protection measures are necessary for both user public and private keys. Ensure secure storage and transmission of keys to prevent leakage and tampering. Employ multi-factor authentication and key rotation strategies to enhance key security and regularly assess key management processes to mitigate potential security risks.
138143

139-
4. Auditing and Monitoring: Implement auditing and monitoring mechanisms to track message sending and receiving, as well as key usage. Promptly identify anomalous activities and potential security threats and take appropriate response measures. Record critical operations and events for security incident investigation and traceability purposes.
144+
### 4. Auditing and Monitoring:
145+
Implement auditing and monitoring mechanisms to track message sending and receiving, as well as key usage. Promptly identify anomalous activities and potential security threats and take appropriate response measures. Record critical operations and events for security incident investigation and traceability purposes.
140146

141147
## Copyright
142148

0 commit comments

Comments
 (0)