-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
81 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/io/provenance/p8e/plugin/JavaKeyPairSigner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.provenance.p8e.plugin | ||
|
||
import com.google.protobuf.ByteString | ||
import cosmos.crypto.secp256k1.Keys | ||
import io.provenance.client.grpc.Signer | ||
import io.provenance.scope.encryption.util.getAddress | ||
import tech.figure.hdwallet.common.hashing.sha256 | ||
import tech.figure.hdwallet.ec.extensions.toECPrivateKey | ||
import tech.figure.hdwallet.ec.extensions.toECPublicKey | ||
import tech.figure.hdwallet.signer.BCECSigner | ||
import java.security.KeyPair | ||
|
||
class JavaKeyPairSigner(private val keyPair: KeyPair, private val mainNet: Boolean) : Signer { | ||
override fun address(): String = keyPair.public.getAddress(mainNet) | ||
|
||
override fun pubKey(): Keys.PubKey = Keys.PubKey | ||
.newBuilder() | ||
.setKey(ByteString.copyFrom(keyPair.public.toECPublicKey().compressed())) | ||
.build() | ||
|
||
override fun sign(data: ByteArray): ByteArray = | ||
BCECSigner() | ||
.sign(keyPair.private.toECPrivateKey(), data.sha256()) | ||
.encodeAsBTC() | ||
.toByteArray() | ||
} |
Oops, something went wrong.