@pianity/arsnap

0.2.2 • Public • Published

Arweave Wallet (ArSnap)

discord arsnap npm package

Arweave Wallet (or ArSnap) is a Snap for MetaMask. It can be seen as an Arweave wallet manager, securely living inside of Metamask. It has an encrypted internal state (managed through the Snaps' API) that it uses to hold wallets, and exposes an API to allow dApps to organize and interact with those wallets. To know more about Arweave Wallet's API and learn how to build with it, head over to the adapter's doc.

Wallet Derivation

Arweave Wallet will by default generate an Arweave Wallet called "Default Wallet", that is derivated from user's Metamask account. This is achieved by using the Snaps function snap_getbip32entropy to obtain a secret that will be used to seed the wallet generation.

  1. Obtain the private key located at the following BIP32 path: m/44'/472'/0'. Arweave's wallets doesn't have any notion of "receiving addresses" or "change addresses" so the index only specifies the index of the actual wallet we're generating. The wallet at index 0' is automatically generated by Arweave Wallet during its initialization, which occurs after Arweave Wallet has been freshly installed and a dApp execute its first request.
  2. Feed the seed to a prng using the algorithm HMAC-DRBG using hmac-drbg and sha2.
  3. Provide this prng to rsa in order to generate an RSA key
  4. Convert this resulting key into a JWK, which is the standard format used to represent Arweave keys.

Steps 2 and 3 are implemented in arsnap-keygen, a Rust library compiled to WASM. It benefits from superior performance compared to pure JavaScript implementation. It's published as an NPM package at https://www.npmjs.com/package/@pianity/arsnap-keygen.

Note: It's currently possible to import Arweave wallets to store them inside Arweave Wallet although none of the wallets that it manages are exportable, and manually imported wallets will be lost and unrecoverable if Arweave Wallet is uninstalled. Every wallets generated by Arweave Wallet itself will be recoverable though, as they will be always derivated from the user's Metamask account as described above. Note that it's currently not possible to ask Arweave Wallet to derivate more Arweave wallets, other than the default one that it generates during its initialization. This will be added as a later feature: users will be able to derivate as many wallets as they want.

Readme

Keywords

none

Package Sidebar

Install

npm i @pianity/arsnap

Weekly Downloads

2,354

Version

0.2.2

License

MIT

Unpacked Size

727 kB

Total Files

5

Last publish

Collaborators

  • femaury
  • lancelot_owczarczak
  • noomity
  • kprimice42