cairo-contracts icon indicating copy to clipboard operation
cairo-contracts copied to clipboard

Add basic multisig Account

Open martriay opened this issue 4 years ago • 6 comments

This should be implemented in the is_valid_signature function.

This is how it looks for single signature accounts:

@view
func is_valid_signature{
        storage_ptr: Storage*,
        pedersen_ptr: HashBuiltin*,
        ecdsa_ptr: SignatureBuiltin*,
        syscall_ptr: felt*,
        range_check_ptr
    } (
        hash: felt,
        signature_len: felt,
        signature: felt*
    ) -> ():
    assert_initialized()
    let (_public_key) = public_key.read()
    # This interface expects a signature pointer and length to make
    # no assumption about signature validation schemes.
    # But this implementation does, and it expects a (sig_r, sig_s) pair.
    let sig_r = signature[0]
    let sig_s = signature[1]

    verify_ecdsa_signature(
        message=hash,
        public_key=_public_key,
        signature_r=sig_r,
        signature_s=sig_s)

    return ()
end

martriay avatar Oct 23 '21 20:10 martriay

One possible implementation can be found in argent's account contract.

It performs each check separately, which is basically the same logic but for a privileged signer.

validate_signer_signature(message_hash, signatures, signatures_len, 0)
validate_guardian_signature(message_hash, signatures, signatures_len, 1)

martriay avatar Oct 26 '21 16:10 martriay

@martriay may i work on this issue?

TAdev0 avatar Jan 31 '24 10:01 TAdev0

Really appreciate the energy! But let's focus on closing the other PRs first :)

martriay avatar Jan 31 '24 17:01 martriay

@martriay hi, tell me when we're good to start working on this feature, if no one else is working on it yet :)

TAdev0 avatar Feb 22 '24 15:02 TAdev0

sure! although i believe this one is a bit heavy on design, so i would focus on that way before opening any full implementation PR -- of course it makes sense to fiddle around with code while designing, just a warning on not overdoing it like tests or full implementations if we notice it's a bad design path

martriay avatar Feb 22 '24 23:02 martriay

some challenges i foresee here is having a different storage struct due to having multiple and not a single owner as our current designs, and how to manage the code duplication if we were to have two different components, etc

martriay avatar Feb 22 '24 23:02 martriay