Created
September 18, 2018 02:41
-
-
Save gz-c/7f9018a8742133280685671bfcff80b6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package main | |
import ( | |
"encoding/hex" | |
"fmt" | |
"github.com/skycoin/skycoin/src/cipher" | |
"github.com/skycoin/skycoin/src/cipher/base58" | |
) | |
func main() { | |
p, s := cipher.GenerateKeyPair() | |
fmt.Println("Private key:", s.Hex()) | |
fmt.Println("Public key:", p.Hex()) | |
ph1 := cipher.SumSHA256(p[:]) | |
fmt.Println("PKhash1:", ph1.Hex()) | |
ph2 := cipher.SumSHA256(ph1[:]) | |
fmt.Println("PKHash2:", ph2.Hex()) | |
rp := cipher.HashRipemd160(ph2[:]) | |
fmt.Println("PKRipe:", hex.EncodeToString(rp[:])) | |
rpv := append(rp[:], 0x00) | |
fmt.Println("PKRipeV:", hex.EncodeToString(rpv)) | |
rpvh := cipher.SumSHA256(rpv[:]) | |
fmt.Println("PKRipeVH:", rpvh.Hex()) | |
chk := rpvh[:4] | |
fmt.Println("Checksum:", hex.EncodeToString(chk)) | |
rpvc := append(rpv, chk...) | |
fmt.Println("PKRipeVC:", hex.EncodeToString(rpvc)) | |
addr := base58.Hex2Base58(rpvc) | |
fmt.Println("Base58:", string(addr)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment