All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.eqoty.secretk.wallet.Pubkey.kt Maven / Gradle / Ivy

Go to download

A Kotlin multiplatform REST client utilizing secret network's gRPC gateway endpoints.

There is a newer version: 6.4.1-rc
Show newest version
package io.eqoty.secretk.wallet

import io.eqoty.secretk.types.response.PubKeySecp256k1
import io.eqoty.secretk.utils.toByteString

fun encodeSecp256k1Pubkey(pubkey: UByteArray): PubKeySecp256k1 {
    if (pubkey.size != 33 || (pubkey[0] != 0x02u.toUByte() && pubkey[0] != 0x03.toUByte())) {
        throw Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03")
    }
    return PubKeySecp256k1(
        value = pubkey.toByteString().base64()
    )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy