Library for migrating Sui addresses to new version from user public keys

A lot of you have expressed concern regarding the latest devnet update and your address changing. While it is generally frowned upon to rely on persistent data on a network that’s wiping its state 1-2x a month, various projects made the decision to do so. With the way addresses are derived changing in the latest update, many of you fear that this data linked to your previous address, may they be NFTs or something else, is lost.

Because of this, Origin Byte have developed tooling to help out with this issue:

key-migration

Library for migrating Sui addresses to new version from user public keys.

Projects which rely on persisting data across wipes generally rely on being able to restore data by airdropping objects into a list of saved addresses. This will break in Sui 0.28 as the saved addresses will no longer be valid addresses. This library allows you to generate pre-0.28 and 0.28 addresses for a user-provided public key so that they can be updated.

This library exposes two functions:

  • generateEd25519Address(public_key): [oldAddress, newAddress]
  • generateSecp256k1Address(public_key): [oldAddress, newAddress]

Correct working of the library can be verified using:

npm install
node tests.js

Obtaining Public Keys from Private Keys

Installing the CLI (you will need to install Node):

git clone https://github.com/Origin-Byte/key-migration.git
cd key-migration
npm i

If you have a private key from sui.keystore you can call the CLI without providing the signature schema as there is a prepended byte that can be used to select the correct schema.

node public-key.js {PRIVATE_KEY}

If you need to provide the schema, valid inputs are ED25519 and Secp256k1.

node public-key.js {PRIVATE_KEY} ED25519

public-key.js assumes that all keys are encoded in base64 unless they are prepended with 0x in which case they will be interpreted as hexadecimal.

9 Likes

That is so relieving and helpful. I hope projects can execute this

1 Like

This calmed me down a bit). I hope the projects will take advantage of this.