WIP: A Go implementation of RFC 6979's deterministic DSA/ECDSA signature scheme.
Find a file
2013-08-26 19:48:12 -07:00
.gitignore Initial commit 2013-08-20 17:32:22 -07:00
dsa.go Add full impl. 2013-08-20 17:35:15 -07:00
dsa_test.go Add full impl. 2013-08-20 17:35:15 -07:00
ecdsa.go Small, tender improvements. 2013-08-26 19:48:12 -07:00
ecdsa_test.go Add full impl. 2013-08-20 17:35:15 -07:00
LICENSE Fix license. 2013-08-20 17:34:56 -07:00
README.md Add links. 2013-08-20 17:49:14 -07:00
rfc6979.go Small, tender improvements. 2013-08-26 19:48:12 -07:00
rfc6979_test.go Add full impl. 2013-08-20 17:35:15 -07:00

rfc6979

A Go implementation of RFC 6979's deterministic DSA/ECDSA signature scheme.

package main

import (
	"crypto/ecdsa"
	"crypto/elliptic"
	"crypto/rand"
	"crypto/sha512"
	"fmt"
	"github.com/codahale/rfc6979"
)

func main() {
	// Generate a key pair.
	// You need a high-quality PRNG for this.
	k, _ := ecdsa.GenerateKey(elliptic.P521(), rand.Reader)

	// Hash a message.
	alg := sha512.New()
	alg.Write([]byte("I am a potato."))
	hash := alg.Sum(nil)

	// Sign the message. You don't need a PRNG for this.
	r, s, _ := rfc6979.SignECDSA(k, hash, sha512.New)
	fmt.Printf("Signature: %X%X", r, s)
}