Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

into_sub_account should check seed length #8564

@shawntabrizi

Description

@shawntabrizi

Currently, into_sub_account directly encodes the seed data into the generated account id bytes.

We do not check that the seed data is greater than the length of the account id type, and thus do not check that some of the data may be truncated and not used to seed an account. This can obviously be bad since all of the seed information should be used to generate a unique account, and any truncation could lead to unintended account collisions.

into_sub_account should return a result, and only generate an account if the seed data would fit completely into the account id space.

Otherwise, hash_into_sub_account can be introduced which takes a hash of the seed data and uses that to generate as much data as needed for the account.

We must review all uses of into_sub_account to make sure they would not suddenly stop working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Z2-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.Z6-mentorAn easy task where a mentor is available. Please indicate in the issue who the mentor could be.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions