hsig0

package module
v0.0.0-...-eca10c3 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: MIT Imports: 11 Imported by: 2

README

HSig0

Go library to validate dns messages using Handshake sig0. You can use it to resolve names over the handshake network and verify them using the node's public key.

Usage

package main

import (
	"fmt"
	"github.com/buffrr/hsig0"
	"github.com/miekg/dns"
	"log"
)

func main() {
	k, err := hsig0.ParsePublicKey("aj7bjss4ae6hd3kdxzl4f6klirzla377uifxu5mnzczzk2v7p76ek")
	if err != nil {
		log.Fatal(err)
	}

	// basic dns query
	client := new(dns.Client)
	query := new(dns.Msg)
	query.SetQuestion("proofofconcept.", dns.TypeA)

	msg, _, err := client.Exchange(query, "192.168.1.21:8181") // node ip:port
	if err != nil {
		log.Fatal(err)
	}

	if err := hsig0.Verify(msg, k) ; err != nil {
		log.Fatal(err)
	}

	fmt.Println("Success ✔️")
	fmt.Println(msg)
}

Other languages

License

MIT

Documentation

Index

Constants

View Source
const BLAKE2bSECP256K1 = dns.PRIVATEDNS

handshake sig0 algorithm

Variables

This section is empty.

Functions

func Verify

func Verify(msg *dns.Msg, k *PublicKey) error

Verify validates the message using the key k.

Types

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

func ParsePublicKey

func ParsePublicKey(key string) (*PublicKey, error)

ParsePublicKey parses the node public key

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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