Skip to content

Try constructor improvements for Delegations/ delegated roles  #2071

Open
@jku

Description

@jku

Currently creating e.g. succinct delegations looks like this

BIT_LENGTH = int(math.log2(NUMBER_OF_BINS))
succinct_roles = SuccinctRoles(
    keyids=[bins_key.keyid],
    threshold=THRESHOLD,
    bit_length=BIT_LENGTH,
    name_prefix=NAME_PREFIX,
)
delegations_keys_info: Dict[str, Key] = {}
delegations_keys_info[bins_key.keyid] = bins_key

targets.signed.delegations = Delegations(
    delegations_keys_info, roles=None, succinct_roles=succinct_roles
)

Looks bad, i'm sure we could get that to something a bit like:

targets.signed.delegations = Delegations(SuccinctRoles.new(NUMBER_OF_BINS, NAME_PREFIX))
targets.add_key(bins_key)

Or alternatively

targets.signed.delegations = Delegations.new_succint(NUMBER_OF_BINS, NAME_PREFIX)
targets.add_key(bins_key)

What makes sense probably depends on what the other delegation types (most importantly paths delegation) will look like...

Metadata

Metadata

Assignees

No one assigned

    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