Welcome back to the second installment of our weekly MynaWallet updates! This series is part of our ongoing commitment to keep our community, which includes our team, backers, and intrigued developers, fully informed. We’re thrilled to delve into what we’ve achieved this week.

Our milestones for the second week have been:

  • Starting developing the contract wallet prototype.
  • Starting researching gas optimization for on-chain RSA verification.
  • Continuing designing the contract architecture and functionalities.
  • Continuing researching ERC-4337, privacy-conscious technology and tools.

Our outcomes are:

  • The revised draft of the contract wallet architecture:
    • Diamond Storage
    • ERC-1271

Let’s deep dive into the topic.

The revised draft of the contract wallet architecture

Our goal is to maintain a straightforward architecture. Although there are various extensible frameworks available, such as modular accounts, we chose not to utilize them as they seemed overly complex for our specific use cases. Instead, we are directly incorporating select features into our implementation.

Diamond Storage

We began implementing changes to the contract architecture to accommodate the concept of Diamond Storage for managing contract storage. Upgradeable contracts require meticulous attention to avoid storage collisions. By incorporating Diamond Storage from the initial stages, we aim to make future contract upgrades safer and easier.

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.19;
 
library AccountStorage {
     bytes32 private constant _ACCOUNT_SLOT = keccak256("MynaWallet.AccountStorage");
 
     struct Layout {
         // base account storage
         bytes owner;
         uint256[50] gap0;
     }
     
     function layout() internal pure returns (Layout storage l) {
         bytes32 slot = _ACCOUNT_SLOT;
         assembly ("memory-safe") {
             l.slot := slot
         }
     }
}

ERC-1271

In our adaptation of ERC-1271, we’ve introduced an extension that interprets extra byte sequences appended to the signature data as defining the signature’s validity period. While the concept of time-bounded signature validity isn’t new, our approach is particularly influenced by the Soul Wallet’s implementation. This strategic choice allows us to standardize expiration logic by aligning the method of period verification with that used in the EntryPoint contract.

/**
 * @notice Verify if the signature is valid
 * @dev we update the signature validation logic to support time range validation
 * @param hash Hash of the data
 * @param signature Signature of the data
 * @return magicValue Magic value if the signature is valid or invalid id / invalid time range
*/
function isValidSignature(bytes32 hash, bytes calldata signature) external view returns (bytes4 magicValue) {
        if (signature.length > 0) {
            (uint256 _validationData, bool sigValid) = _isValidSignature(hash, signature);
            if (!sigValid) {
                return _INVALID_ID;
            }
            if (_validationData > 0) {
                ValidationData memory validationData = _parseValidationData(_validationData);
                bool outOfTimeRange =
                    (block.timestamp > validationData.validUntil) || (block.timestamp < validationData.validAfter);
                if (outOfTimeRange) {
                    return _INVALID_TIME_RANGE;
                }
            }
            return _MAGICVALUE;
        } else {
            return _INVALID_ID;
        }
}

Looking ahead

We’re actively enhancing MynaWallet’s capabilities. Our focus is on introducing Social Recovery and Trusted Recovery functionalities and refining the authentication process through Session Key functionalities. Furthermore, we are exploring the integration of Zero-Knowledge Proofs to ensure private account ownership verification without exposing users’ public keys from their Myna Card. In the coming week, our agenda includes benchmarking RSA signature verification and advancing contract development.

References

Contributors

Bonus

chibi

About a42x Inc.

a42x Inc. is developing a wallet system and digital auth infrastructure. Main achievement: Selected as a finalist at ETHGlobal Tokyo, one of the world’s largest blockchain developer competitions.

Recruitment of Developers/Researchers

At a42x Inc., we reinforce hiring in a wide range of positions, including iOS & Android app engineers, backend engineers, researchers, and business development. We look forward to applications from those with a strong interest and curiosity in technology and craftsmanship and a passion for creating products used in the real world. For details, please get in touch with the email address below.

Contact

info@a42x.co.jp