Skip to content

Source Account Auth: Pass source account into the host in InvokeHostFunctionOp #3546

@sisuresh

Description

@sisuresh

The reasoning for this is to get a msg.sender-like signing flow in soroban, allowing a user to sign a single payload.

  • The HostFunction enum will get two new values-
    • HOST_FN_CALL_WITH_SOURCE - Same as HOST_FN_CALL, but will also pass along the source account to the host. Contracts can treat this source as msg.sender since it already passed signature verification in stellar-core.
    • HOST_FN_CREATE_CONTRACT_WITH_SOURCE - This will create a contract using the new HashIDPreimage::ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE, which will use the source account and a user provided salt.

The new xdr should look like -

enum HostFunction
{
    HOST_FN_CALL = 0,
    HOST_FN_CREATE_CONTRACT = 1,
    // New
    HOST_FN_CALL_WITH_SOURCE = 2,
    HOST_FN_CREATE_CONTRACT_WITH_SOURCE = 3,
};

union HashIDPreimage switch (EnvelopeType type)
...
case ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519:
    struct
    {
        uint256 ed25519;
        uint256 salt;
    } ed25519ContractID;
case ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT:
    struct
    {
        Hash contractID;
        uint256 salt;
    } contractID;

//New 
case ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE:
    struct
    {
        AccountID sourceAccount;
        uint256 salt;
    } sourceContractID;
};

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions