@@ -80,56 +80,56 @@ func GetPaymentKey(accountKey bip32.XPrv, num uint32) bip32.XPrv {
8080 return accountKey .Derive (0 ).Derive (num )
8181}
8282
83- func GetPaymentVKey (paymentKey bip32.XPrv ) string {
83+ func GetPaymentVKey (paymentKey bip32.XPrv ) KeyFile {
8484 keyCbor , err := cbor .Marshal (paymentKey .Public ().PublicKey ())
8585 if err != nil {
8686 panic (err )
8787 }
88- return GetKeyFile (
89- "PaymentVerificationKeyShelley_ed25519" ,
90- "Payment Verification Key" ,
91- keyCbor ,
92- )
88+ return KeyFile {
89+ Type : "PaymentVerificationKeyShelley_ed25519" ,
90+ Description : "Payment Verification Key" ,
91+ CborHex : fmt . Sprintf ( "%x" , keyCbor ) ,
92+ }
9393}
9494
95- func GetPaymentSKey (paymentKey bip32.XPrv ) string {
95+ func GetPaymentSKey (paymentKey bip32.XPrv ) KeyFile {
9696 keyCbor , err := cbor .Marshal (GetExtendedPrivateKey (paymentKey , paymentKey .Public ().PublicKey ()))
9797 if err != nil {
9898 panic (err )
9999 }
100- return GetKeyFile (
101- "PaymentExtendedSigningKeyShelley_ed25519_bip32" ,
102- "Payment Signing Key" ,
103- keyCbor ,
104- )
100+ return KeyFile {
101+ Type : "PaymentExtendedSigningKeyShelley_ed25519_bip32" ,
102+ Description : "Payment Signing Key" ,
103+ CborHex : fmt . Sprintf ( "%x" , keyCbor ) ,
104+ }
105105}
106106
107107func GetStakeKey (accountKey bip32.XPrv , num uint32 ) bip32.XPrv {
108108 return accountKey .Derive (2 ).Derive (num )
109109}
110110
111- func GetStakeVKey (stakeKey bip32.XPrv ) string {
111+ func GetStakeVKey (stakeKey bip32.XPrv ) KeyFile {
112112 keyCbor , err := cbor .Marshal (stakeKey .Public ().PublicKey ())
113113 if err != nil {
114114 panic (err )
115115 }
116- return GetKeyFile (
117- "StakeVerificationKeyShelley_ed25519" ,
118- "Stake Verification Key" ,
119- keyCbor ,
120- )
116+ return KeyFile {
117+ Type : "StakeVerificationKeyShelley_ed25519" ,
118+ Description : "Stake Verification Key" ,
119+ CborHex : fmt . Sprintf ( "%x" , keyCbor ) ,
120+ }
121121}
122122
123- func GetStakeSKey (stakeKey bip32.XPrv ) string {
123+ func GetStakeSKey (stakeKey bip32.XPrv ) KeyFile {
124124 keyCbor , err := cbor .Marshal (GetExtendedPrivateKey (stakeKey , stakeKey .Public ().PublicKey ()))
125125 if err != nil {
126126 panic (err )
127127 }
128- return GetKeyFile (
129- "StakeExtendedSigningKeyShelley_ed25519_bip32" ,
130- "Stake Signing Key" ,
131- keyCbor ,
132- )
128+ return KeyFile {
129+ Type : "StakeExtendedSigningKeyShelley_ed25519_bip32" ,
130+ Description : "Stake Signing Key" ,
131+ CborHex : fmt . Sprintf ( "%x" , keyCbor ) ,
132+ }
133133}
134134
135135func GetAddress (accountKey bip32.XPrv , net string , num uint32 ) * address.BaseAddress {
@@ -161,14 +161,9 @@ func GetExtendedPrivateKey(privateKey []byte, publicKey []byte) bip32.XPrv {
161161 return xprv
162162}
163163
164- func GetKeyFile (keyType string , desc string , data []byte ) string {
165- tmp := KeyFile {
166- Type : keyType ,
167- Description : desc ,
168- CborHex : fmt .Sprintf ("%x" , data ),
169- }
164+ func GetKeyFile (keyFile KeyFile ) string {
170165 // Use 4 spaces for indent
171- ret , err := json .MarshalIndent (tmp , "" , " " )
166+ ret , err := json .MarshalIndent (keyFile , "" , " " )
172167 if err != nil {
173168 return ""
174169 }
@@ -202,8 +197,8 @@ func Run() {
202197 fmt .Printf ("PAYMENT_ADDRESS=%s\n " , addr .String ())
203198 fmt .Printf ("STAKE_ADDRESS=%s\n " , addr .ToReward ().String ())
204199
205- fmt .Printf ("payment.vkey=%s" , GetPaymentVKey (GetPaymentKey (accountKey , 0 )))
206- fmt .Printf ("payment.skey=%s" , GetPaymentSKey (GetPaymentKey (accountKey , 0 )))
207- fmt .Printf ("stake.vkey=%s" , GetStakeVKey (GetStakeKey (accountKey , 0 )))
208- fmt .Printf ("stake.vkey=%s" , GetStakeSKey (GetStakeKey (accountKey , 0 )))
200+ fmt .Printf ("payment.vkey=%s" , GetKeyFile ( GetPaymentVKey (GetPaymentKey (accountKey , 0 ) )))
201+ fmt .Printf ("payment.skey=%s" , GetKeyFile ( GetPaymentSKey (GetPaymentKey (accountKey , 0 ) )))
202+ fmt .Printf ("stake.vkey=%s" , GetKeyFile ( GetStakeVKey (GetStakeKey (accountKey , 0 ) )))
203+ fmt .Printf ("stake.vkey=%s" , GetKeyFile ( GetStakeSKey (GetStakeKey (accountKey , 0 ) )))
209204}
0 commit comments