<commit_before>/* gobtcaddr v1.0
 * vsergeev
 * https://github.com/vsergeev/gobtcaddr
 * MIT Licensed
 */

package main

import (
	"encoding/base64"
	"fmt"
	"github.com/vsergeev/gobtcaddr/btckey"
	"log"
	"os"
)

func byteString(b []byte) (s string) {
	s = ""
	for i := 0; i < len(b); i++ {
		s += fmt.Sprintf("%02X", b[i])
	}
	return s
}

func main() {
	/* Redirect fatal errors to stderr */
	log.SetOutput(os.Stderr)

	var priv btckey.PrivateKey
	var err error

	/* Import WIF from first argument */
	if len(os.Args) > 1 {
		err = priv.FromWIF(os.Args[1])
		if err != nil {
			log.Fatalf("Importing WIF: %s\n", err)
		}
	} else {
		/* Generate a new Bitcoin keypair */
		priv, err = btckey.GenerateKey()
		if err != nil {
			log.Fatalf("Generating keypair: %s\n", err)
		}
	}

	/* Convert to Address */
	address := priv.ToAddress(0x00)
	/* Convert to Public Key Bytes (65 bytes) */
	pub_bytes := priv.PublicKey.ToBytes()
	pub_bytes_str := byteString(pub_bytes)
	pub_bytes_b64 := base64.StdEncoding.EncodeToString(pub_bytes)

	/* Convert to WIF */
	wif := priv.ToWIF()
	/* Convert to Private Key Bytes (32 bytes) */
	pri_bytes := priv.ToBytes()
	pri_bytes_str := byteString(pri_bytes)
	pri_bytes_b64 := base64.StdEncoding.EncodeToString(pri_bytes)

	fmt.Printf("     Bitcoin Address: %s\n", address)
	fmt.Printf("    Public Key Bytes: %s\n", pub_bytes_str[0:65])
	fmt.Printf("                      %s\n", pub_bytes_str[65:])
	fmt.Printf("   Public Key Base64: %s\n", pub_bytes_b64)
	fmt.Println()
	fmt.Printf("     Private Key WIF: %s\n", wif)
	fmt.Printf("   Private Key Bytes: %s\n", pri_bytes_str)
	fmt.Printf("  Private Key Base64: %s\n", pri_bytes_b64)
}
<commit_msg>add compressed public key support to cli tool<commit_after>/* gobtcaddr v1.0
 * vsergeev
 * https://github.com/vsergeev/gobtcaddr
 * MIT Licensed
 */

package main

import (
	"encoding/base64"
	"fmt"
	"github.com/vsergeev/gobtcaddr/btckey"
	"log"
	"os"
)

func byteString(b []byte) (s string) {
	s = ""
	for i := 0; i < len(b); i++ {
		s += fmt.Sprintf("%02X", b[i])
	}
	return s
}

func main() {
	/* Redirect fatal errors to stderr */
	log.SetOutput(os.Stderr)

	var priv btckey.PrivateKey
	var err error

	/* Import WIF from first argument */
	if len(os.Args) > 1 {
		err = priv.FromWIF(os.Args[1])
		if err != nil {
			log.Fatalf("Importing WIF: %s\n", err)
		}
	} else {
		/* Generate a new Bitcoin keypair */
		priv, err = btckey.GenerateKey()
		if err != nil {
			log.Fatalf("Generating keypair: %s\n", err)
		}
	}

	/* Convert to Compressed Address */
	address_compressed := priv.ToAddress()
	/* Convert to Public Key Compressed Bytes (33 bytes) */
	pub_bytes_compressed := priv.PublicKey.ToBytes()
	pub_bytes_compressed_str := byteString(pub_bytes_compressed)
	pub_bytes_compressed_b64 := base64.StdEncoding.EncodeToString(pub_bytes_compressed)

	/* Convert to Uncompressed Address */
	address_uncompressed := priv.ToAddressUncompressed()
	/* Convert to Public Key Uncompresed Bytes (65 bytes) */
	pub_bytes_uncompressed := priv.PublicKey.ToBytesUncompressed()
	pub_bytes_uncompressed_str := byteString(pub_bytes_uncompressed)
	pub_bytes_uncompressed_b64 := base64.StdEncoding.EncodeToString(pub_bytes_uncompressed)

	/* Convert to WIF */
	wif := priv.ToWIF()
	/* Convert to Private Key Bytes (32 bytes) */
	pri_bytes := priv.ToBytes()
	pri_bytes_str := byteString(pri_bytes)
	pri_bytes_b64 := base64.StdEncoding.EncodeToString(pri_bytes)

	fmt.Printf("Bitcoin Address (Compressed)        %s\n", address_compressed)
	fmt.Printf("Public Key Bytes (Compressed)       %s\n", pub_bytes_compressed_str)
	fmt.Printf("Public Key Base64 (Compressed)      %s\n", pub_bytes_compressed_b64)
	fmt.Println()
	fmt.Printf("Bitcoin Address (Uncompressed)      %s\n", address_uncompressed)
	fmt.Printf("Public Key Bytes (Uncompressed)     %s\n", pub_bytes_uncompressed_str[0:65])
	fmt.Printf("                                    %s\n", pub_bytes_uncompressed_str[65:])
	fmt.Printf("Public Key Base64 (Uncompressed)    %s\n", pub_bytes_uncompressed_b64)
	fmt.Println()
	fmt.Printf("Private Key WIF                     %s\n", wif)
	fmt.Printf("Private Key Bytes                   %s\n", pri_bytes_str)
	fmt.Printf("Private Key Base64                  %s\n", pri_bytes_b64)
}

{'fraction_non_alphanumeric': 0.14069877242681775, 'fraction_numerical': 0.019121813031161474, 'mean_word_length': 3.6104461371055496, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1602870', 'n_tokens_mistral': 1677, 'n_tokens_neox': 1605, 'n_words': 352}