Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. import scala.util.Failure
  2. import scala.util.Success
  3.  
  4. import com.google.common.primitives.Bytes
  5. import com.google.common.primitives.Ints
  6.  
  7. import scorex.crypto.EllipticCurveImpl
  8. import scorex.crypto.encode.Base58
  9. import scorex.crypto.hash.SecureCryptographicHash
  10. import scorex.waves.crypto.HashChain
  11.  
  12. object WalletGenerator extends App {
  13. val walletSeed =
  14. Base58.decode(
  15. "paste here your base58 encoded walletSeed from settings.json") match {
  16. case Success(walletSeed) => {
  17. for (nonce <- 0 to 9) {
  18. val keySeed = SecureCryptographicHash(Bytes.concat(Ints.toByteArray(nonce), walletSeed))
  19. val pair = EllipticCurveImpl.createKeyPair(keySeed)
  20. val (privateKey, publicKey) = EllipticCurveImpl.createKeyPair(keySeed)
  21. val publicKeyHash = HashChain.hash(publicKey).take(20)
  22. val withoutChecksum: Array[Byte] = 1.toByte +: 'T'.toByte +: publicKeyHash
  23. val address = withoutChecksum ++ HashChain.hash(publicKey).take(4)
  24. println(s"address: ${Base58.encode(address)}, publicKey: ${Base58.encode(publicKey)}, privateKey: ${Base58.encode(privateKey)}")
  25. }
  26. }
  27. case Failure(e) => println("base58 seed decode failed")
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement