ecdsa-digital-signature

command
v0.0.0-...-a2a1f02 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: MIT Imports: 13 Imported by: 0

README

ecdsa-digital-signature example

To verify who a message is from, create and verify a digital signature using the crypto/ecdsa standard package.

Refer to the crypto/ecdsa package for more info.

GitHub Webpage

OVERVIEW

Digital signatures are based on elliptic curve cryptography (ECC) and are important for message validation.

The Elliptic Curve Digital Signature Algorithm is a great way to cryptographically sign a message.

This illustration may help,

IMAGE - ecdsa-digital-signature.jpg - IMAGE

RUN

go run ecdsa-digital-signature.go <FILENAME>
go run ecdsa-digital-signature.go test.txt

HOW IT WORKS

Generate ecdsa keys,

// GENERATE PRIVATE & PUBLIC KEY PAIR
curve := elliptic.P256()
privateKeyRaw, err := ecdsa.GenerateKey(curve, rand.Reader)

// EXTRACT PUBLIC KEY
publicKeyRaw := &privateKeyRaw.PublicKey

Create a digital signature,

// CREATE SIGNATURE
r, s, err := ecdsa.Sign(rand.Reader, senderPrivateKeyRaw, signHash)

signatureByte := r.Bytes()
signatureByte = append(signatureByte, s.Bytes()...)

Verify the digital signature,

// VERIFY SIGNATURE
verifyStatus := ecdsa.Verify(senderPublicKeyRaw, signhash, r, s)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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