社交恢复钱包

2023-06-17  本文已影响0人  雪落无留痕

社交恢复钱包主要避免账户密钥丢失的风险,钱包采用智能合约形式,合约中添加了guardians, 可以在用户丢失必私钥的情况下,guardian可以按照指定规则恢得用户的账户。采用ZK技术,主要隐私guardian的地址,增强隐私性。

多签钱包

多签钱包起源于Bitcoin, 目前以太坊上存在多签钱包,例如Gnosis Safe. 例如以太坊基金会使用 4-of-7 多签钱包。

多签钱包对普通用户来说并不方便,如何存放多签的密钥,例如存放在用户多个设备中,一个在电脑中,一个在手机,还有一个作为备份。若用户单独一个设备丢失并不会损失资金,同时丢失依然会有安全问题。

Social Recovery Wallet

社交恢复钱包主要特点:

在正常情况下,社交恢复钱包和普通钱包一样,用户用signing key对交易签名,发起交易。

若用户signing key 丢失,可以通过社交功能介入恢复,通过guardians 根据要求签一笔特殊的交易,改变合约中注册的signing pubkey.

guardian的选择方式:

为了降低guardians 相互串通的风险,guardians相互之间应该不知道彼此的身份, 可以通过两种方式解决:

最好从不同社交圈选择guardians.

对于signing key 被盗的情形,可以将资金转移存放到vault中,采用signing keyvault中取走资金需要一周的延迟,在这种情况下,guardians可以撤销这笔交易。

目前带有社交恢复功能的钱包

Demo 版

社交恢复钱包主要有几个函数:

    function addGuardian(bytes32 _firstHalfOfHash, bytes32 _secondHalfOfHash) external onlyOwner {
        firstHash = _firstHalfOfHash;
        secondHash = _secondHalfOfHash;
        emit AddGuardian(firstHash, secondHash);
    }

     /// @dev This function is used to get the wallet balance for any ERC20 or ETH.
    /// @param _token is the address of an ERC20 token or 0x0 for ETH.
    function balance(address _token) external view returns (uint256) {
        if (_token != address(0)) {
            return IERC20(_token).balanceOf(address(this));
        } else {
            return address(this).balance;
        }
    }

    /// @dev Transfers the specified asset to the recipient's address.
    /// @param _to is the recipient's address.
    /// @param _token is the address of an ERC20 token or 0x0 for ETH.
    /// @param _amount is the amount of assets to be transferred in base units.
    function transfer(address payable _to, address _token, uint _amount) external onlyOwner {
        require(_to != address(0), "destination cannot be the 0 address");

        // address(0) is used to denote ETH
        if (_token == address(0)) {
            _to.sendValue(_amount);
        } else {
            IERC20(_token).safeTransfer(_to, _amount);
        }
        emit Transferred(_to, _token, _amount);
    }

    function zkRecover(address payable _recoveryAddress, bytes32[] calldata proof) external returns (bool) {
        (uint[2] memory a, uint[2][2] memory b, uint[2] memory c, uint[3] memory inputs) = extractProof(proof);

        require(firstHash == bytes32(inputs[0]), 'guardian not approved');
        require(secondHash == bytes32(inputs[1]), 'guardian not approved');

        bool isValid = IProofValidator(validatorContract).verifyTx(a, b, c, inputs);
        require(isValid == true, 'proof failed');
    
        _transferOwnership(_recoveryAddress);
    }

参考:https://devpost.com/software/zksocialrecovery

Argent wallet

https://www.argent.xyz

Argent 钱包是一个基于智能合约实现的钱包,用户保留一个EOA账户,作为智能合约钱包的owner。 用户的资产ETH, ERC20, ERC721, ERC1155 保存在智能合约钱包中。通过这种模块,可以灵活定义智能合约钱包的逻辑,提升用户的使用体验和钱包安全性。

使钱包可以被恢复,转移,锁定和升级。

Guardians

Argent钱包并不限制guardian的来源,可以是其它朋友的Argent 钱包或EOA, 或者硬件钱包,或者第三方服务。

钱包的owner用户可以添加或移除guardian.

guardian主要用来锁定,解锁,或者触发钱包恢复过程。

Locking

当钱包owner 丢失的时候,可以请求guardians 锁定钱包,有5天的锁定期。在钱包锁定的时候,只能执行有限的操作,例如解锁,钱包恢复,撤销guardians

Recovery

当钱包owner丢失其它密钥的时候,可以请未发起恢复过程,恢复钱包需要ceiling(n/2)个签名,其中nguardian的个数;

Argent钱包通过代理合约实现,代理合约由Wallet Factory创建,BaseWallet为实现合约。

参考:https://github.com/argentlabs/argent-contracts/blob/develop/specifications/specifications.pdf

Loopring钱包也带有社交恢复功能。

zkWallet

https://zkwallet.simplicy.io/

zkWallet 通过zk技术实现guardian 地址隐私性,通过利用Semaphore协议,允许用户在不泄露身份的情况下,证明群成员关系,从而可以发起投票或者授权其它操作。

[站外图片上传中...(image-e6e717-1687076882467)]

参考:https://github.com/zkWallet/zkWallet-docs

关键挑战

社区恢复钱包主要面临两个问题:

这两个问题都可以通过L2的账户抽象实现解决。

参考

https://news.marsbit.cc/20230521073903612386.html

https://devpost.com/software/zksocialrecovery

https://github.com/thomas-waite/zkSocialRecovery

https://vitalik.ca/general/2021/01/11/recovery.html?ref=hackernoon.com

https://gnosis-safe.io/

https://www.argent.xyz/blog/a-new-era-for-crypto-security/

https://github.com/rishotics/zkSocialRecovery

https://github.com/zkWallet

上一篇下一篇

猜你喜欢

热点阅读