SHARE
TWEET

Untitled

a guest Feb 15th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "encoding/hex"
  5.     "fmt"
  6.  
  7.     "github.com/bytom/crypto/sm2/chainkd"
  8. )
  9.  
  10. func main() {
  11.     strMessage := "1234abcd"
  12.     byteMessage, _ := hex.DecodeString(strMessage)
  13.     strXprv := "c003f4bcccf9ad6f05ad2c84fa5ff98430eb8e73de5de232bc29334c7d074759d513bc370335cac51d77f0be5dfe84de024cfee562530b4d873b5f5e2ff4f57c"
  14.     byteXprv, _ := hex.DecodeString(strXprv)
  15.     xprv := new(chainkd.XPrv)
  16.     copy(xprv[:], byteXprv[:])
  17.  
  18.     xpub := xprv.XPub()
  19.     strXpub := hex.EncodeToString(xpub[:])
  20.  
  21.     sig := xprv.Sign(byteMessage)
  22.     strSig := hex.EncodeToString(sig[:])
  23.     fmt.Println("xprv:    ", strXprv)
  24.     fmt.Println("xpub:    ", strXpub)
  25.     fmt.Println("message: ", strMessage)
  26.     fmt.Println("sig:     ", strSig)
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top