Skip to content

[Feature Request] Reduce bundle size (poseidon hash)Β #578

@yeptos

Description

@yeptos

πŸš€ Feature Request Description

Motivation

Currently the sdk has the bundle size of over 500KB (minified and gzipped). 421KB come from poseidon-lite the Poseidon hash const table, but used only while deriving Keyless accounts. Since the sdk usually gets included in the initial bundle of the dapps, this affects negatively to page load speed for end users.

https://bundlephobia.com/package/poseidon-lite@0.3.0
https://bundlephobia.com/package/@aptos-labs/ts-sdk@1.33.0

Possible Solutions

  1. Make the poseidon-lite optional dependency and dynamically load the module when deriving Keyless account, or right before it's used

  2. Optionally allow offloading idCommitment derivation to pepper service? (if it makes sense security wise)

$$\text{idCommitment} = poseidonHash(\text{aud}, \text{uidKey}, \text{uidVal}, r)$$

Additional context

  • Due to the bundle size, in our dApp, we dynamically import (await import) the entire ts sdk module to reduce the initial page load delay (hope we no longer have to do this in the future).
  • Can we also somehow use built in fetch (undici on node, browser built in fetch on web) and remove axios?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions