tordn

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 6 Imported by: 0

README

tordn


GoDoc Build Status Go Report Card Coverage Status


The Onion Router Domain Name

Package tordn provides the ability to generate tor version 3 onion address for the hidden service

Example

package main

import (
	"fmt"
	"github.com/mkawserm/tordn"
)

func main() {

	v3domainName := &tordn.V3{}

	// generate random v3 tor domain name
	publicKey, privateKey, onionAddress, err := v3domainName.GenerateTORDomainName(nil)
	if err == nil {
		fmt.Printf("Public Key:")
		fmt.Println(publicKey)

		fmt.Printf("Private Key:")
		fmt.Println(privateKey)

		fmt.Printf("Onion Address:")
		fmt.Println(string(onionAddress))
	}
}

DEVELOPER NOTE

1. Benchmark memory profile
    
    Create memory benchmark
     
    `go test -bench=. -memprofile=mem.out`

    Top  profile
         
    `go tool pprof -alloc_objects -top -cum mem.out`
    
    Line by line profile
    
    `go tool pprof -alloc_objects -list=<BenchmarkName> mem.out`

2. Escape Analysis
    
    `go test -gcflags '-m -m'`
    
3. Test coverage

    `go test -coverprofile=cover.out`
    
4. Race condition detection

    `go test -race`

Documentation

Overview

Package tordn provides the ability to generate tor v3 onion address.

By Md Kawser Munshi

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeV3OnionAddressWithExtension

func MakeV3OnionAddressWithExtension(publicKey []byte) []byte

MakeV3OnionAddressWithExtension generates tor v3 onion address with .onion extension

func PublicKeyToV3Address

func PublicKeyToV3Address(publicKey []byte) []byte

PublicKeyToV3Address generates tor v3 onion address from the publicKey

Types

type TORDomainNameGenerator

type TORDomainNameGenerator interface {

	// GenerateTORDomainName generates tor domain using the secret key.
	//
	// Implementations must handle nil secretKey
	GenerateTORDomainName(secretKey io.Reader) (publicKey []byte, privateKey []byte, onionAddress []byte, err error)
}

TORDomainNameGenerator basic interface

type V3

type V3 struct {
}

V3 TOR address generator

func (*V3) GenerateTORDomainName

func (g *V3) GenerateTORDomainName(secretKey io.Reader) (publicKey []byte, privateKey []byte, onionAddress []byte, err error)

GenerateTORDomainName implements TORDomainNameGenerator interface

Generate tor v3 domain name using the secretKey.

Example

Generate v3 tor domain name

package main

import (
	"bytes"
	"fmt"
	"github.com/mkawserm/tordn"
)

func main() {

	v3domainName := &tordn.V3{}

	// generate random v3 tor domain name
	publicKey, privateKey, onionAddress, err := v3domainName.GenerateTORDomainName(nil)
	if err == nil {
		fmt.Printf("Public Key:")
		fmt.Println(publicKey)

		fmt.Printf("Private Key:")
		fmt.Println(privateKey)

		fmt.Printf("Onion Address:")
		fmt.Println(string(onionAddress))
	}

	secretKey := []byte("eipuopkyhrisvmrlbghubnlxunzkwoij")
	publicKey1, privateKey1, onionAddress1, err1 := v3domainName.GenerateTORDomainName(bytes.NewReader(secretKey))
	if err1 == nil {
		fmt.Printf("Public Key:")
		fmt.Println(publicKey1)

		fmt.Printf("Private Key:")
		fmt.Println(privateKey1)

		fmt.Printf("Onion Address:")
		fmt.Println(string(onionAddress1))
	}
}
Output:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL