digisig

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

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

Go to latest
Published: Jun 14, 2017 License: MIT Imports: 5 Imported by: 0

README

digisig

Digital Signure Scheme

This is an implementation of the Schnorr signature based on Linear groups. For the linear groups, see RFC-3526.

https://godoc.org/github.com/mad-day/digisig

package main

import "io"
import "fmt"
import "github.com/mad-day/digisig"

import "golang.org/x/crypto/sha3"

import "golang.org/x/crypto/blake2b"
import "github.com/mad-day/digisig/blake2butil"

func Message(f io.Writer) {
	fmt.Fprintln(f,"Hello World!")
	fmt.Fprintln(f,"Hello World!")
	fmt.Fprintln(f,"Hello World!")
	fmt.Fprintln(f,"Hello World!")
	fmt.Fprintln(f,"Hello World!")
	fmt.Fprintln(f,"Hello World!")
}

func Message2(f io.Writer) {
	fmt.Fprintln(f,"Hello World!")
	fmt.Fprintln(f,"Hello World!")
	fmt.Fprintln(f,"Hello World.")
	fmt.Fprintln(f,"Hello World!")
	fmt.Fprintln(f,"Hello World!")
	fmt.Fprintln(f,"Hello World!")
}

func main() {
	random := sha3.NewShake256()
	random.Write([]byte("12345"))
	pk,e := new(digisig.PrivateKey).SetGroup(digisig.Modp18).Generate(random)
	if e!=nil { fmt.Println(e); return }
	pub := pk.PublicKey()
	
	sig,e := digisig.NewSigner(pk,blake2b.New512,blake2butil.PreKey,random)
	if e!=nil { fmt.Println(e); return }
	
	Message(sig)
	E,S := sig.Sign()
	//fmt.Printf("E=%x\nS=%x\n",E,S)
	
	ver,e := digisig.NewVerifier(E,S,pub,blake2b.New512,blake2butil.PreKey)
	if e!=nil { fmt.Println(e); return }
	Message(ver)
	E2,ok := ver.Verify()
	
	fmt.Println()
	fmt.Println()
	fmt.Println()
	fmt.Printf("E=%x\nS=%x\n",E,S)
	fmt.Printf("E=%x\nok=%v\n",E2,ok)
	
	//fmt.Println(pk)
	//fmt.Println(pub)
}

Documentation

Index

Constants

View Source
const (
	Modp5  = 5  /* 1536-bit MODP Group */
	Modp14 = 14 /* 2048-bit MODP Group */
	Modp15 = 15 /* 3072-bit MODP Group */
	Modp16 = 16 /* 4096-bit MODP Group */
	Modp17 = 17 /* 6144-bit MODP Group */
	Modp18 = 18 /* 8192-bit MODP Group */
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MAC

type MAC func(key []byte) (hash.Hash, error)

type Prek

type Prek func(key []byte) []byte

nil will result in "func(key []byte) []byte { return key }"

type PrivateKey

type PrivateKey struct {
	Group  int
	Secret *big.Int
}

func (*PrivateKey) Generate

func (p *PrivateKey) Generate(r io.Reader) (*PrivateKey, error)

func (*PrivateKey) PublicKey

func (p *PrivateKey) PublicKey() *PublicKey

func (*PrivateKey) SetGroup

func (p *PrivateKey) SetGroup(g int) *PrivateKey

func (*PrivateKey) String

func (p *PrivateKey) String() string

type PublicKey

type PublicKey struct {
	Group  int
	Public *big.Int
}

func (*PublicKey) Base

func (p *PublicKey) Base() *PublicKey

func (*PublicKey) Exp

func (p *PublicKey) Exp(i *big.Int) *PublicKey

func (*PublicKey) ModInverse

func (p *PublicKey) ModInverse() *PublicKey

func (*PublicKey) Mul

func (p *PublicKey) Mul(o *PublicKey) *PublicKey

func (*PublicKey) String

func (p *PublicKey) String() string

type Signer

type Signer struct {
	io.Writer
	// contains filtered or unexported fields
}

func NewSigner

func NewSigner(priv *PrivateKey, mac MAC, prep Prek, ra io.Reader) (*Signer, error)

func (*Signer) Sign

func (s *Signer) Sign() (E *big.Int, S *big.Int)

type Verifier

type Verifier struct {
	io.Writer
	// contains filtered or unexported fields
}

func NewVerifier

func NewVerifier(E, S *big.Int, pub *PublicKey, mac MAC, prep Prek) (v *Verifier, err error)

func (*Verifier) Verify

func (v *Verifier) Verify() (*big.Int, bool)

Directories

Path Synopsis
Utility to use with blake2b MAC.
Utility to use with blake2b MAC.
Utility to use with blake2b MAC.
Utility to use with blake2b MAC.

Jump to

Keyboard shortcuts

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