Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local key format ? #53

Open
Sceat opened this issue Nov 16, 2024 · 3 comments
Open

Local key format ? #53

Sceat opened this issue Nov 16, 2024 · 3 comments

Comments

@Sceat
Copy link

Sceat commented Nov 16, 2024

I've been trying to run the tool but can't find what format is expected in the signer-config.local settings 🤔

@Sceat
Copy link
Author

Sceat commented Nov 17, 2024

Figured it out actually

function sui_key_to_gas_station(sui_priv_key) {
  const { schema, secretKey } = decodeSuiPrivateKey(sui_priv_key)
  const flag =
    schema === 'ED25519' ? 0x00 : schema === 'Secp256k1' ? 0x01 : 0x02
  return toBase64(Uint8Array.from([flag, ...secretKey]))
}

@lxfind
Copy link
Collaborator

lxfind commented Nov 18, 2024

Thanks for asking! I will add this to the docs too.

@klren0312
Copy link

Figured it out actually

function sui_key_to_gas_station(sui_priv_key) {
  const { schema, secretKey } = decodeSuiPrivateKey(sui_priv_key)
  const flag =
    schema === 'ED25519' ? 0x00 : schema === 'Secp256k1' ? 0x01 : 0x02
  return toBase64(Uint8Array.from([flag, ...secretKey]))
}

thank you

import { decodeSuiPrivateKey } from "@mysten/sui/cryptography"
import { toBase64 } from "@mysten/sui/utils"

const sui_key_to_gas_station = (sui_priv_key: string) => {
  const { schema, secretKey } = decodeSuiPrivateKey(sui_priv_key)
  const flag =
    schema === 'ED25519' ? 0x00 : schema === 'Secp256k1' ? 0x01 : 0x02
  return toBase64(Uint8Array.from([flag, ...secretKey]))
}
const gas_station_key = sui_key_to_gas_station('your private key')
console.log(gas_station_key)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants