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

io.p8e.crypto.PBSigner.kt Maven / Gradle / Ivy

Go to download

A collection of services and libraries that iteract and run Provenance Java based contracts.

The newest version!
package io.provenance.engine.crypto

import io.p8e.crypto.Hash
import io.provenance.pbc.clients.StdPubKey
import io.provenance.pbc.clients.StdSignature
import org.kethereum.crypto.getCompressedPublicKey
import org.kethereum.crypto.impl.ec.EllipticCurveSigner
import org.kethereum.model.ECKeyPair

object PbSigner {
    fun signerFor(keyPair: ECKeyPair): (ByteArray) -> List = { bytes ->
        bytes.let {
            Hash.sha256(it)
        }.let {
            StdSignature(
                pub_key = StdPubKey("tendermint/PubKeySecp256k1", keyPair.getCompressedPublicKey()),
                signature = EllipticCurveSigner().sign(it, keyPair.privateKey.key, true).encodeAsBTC()
            )
        }.let {
            listOf(it)
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy