btcutil

package
v1.66.3 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2022 License: BSD-3-Clause Imports: 6 Imported by: 15

README

btcutil

Utility functions for Bitcoin elliptic curve cryptography.

Install with

go get github.com/mndrix/btcutil

Documentation

Overview

Package btcutil Utility functions for Bitcoin elliptic curve cryptography.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(a, b *ecdsa.PublicKey) *ecdsa.PublicKey

Add Adds two points to create a third. Points are represented as ECDSA public keys.

func BlindMessage

func BlindMessage(rState *BlindRequesterState, Q, R *ecdsa.PublicKey, m *big.Int) *big.Int

BlindMessage Calculates a blinded version of message m

func BlindSession

func BlindSession(sState *BlindSignerState) (*ecdsa.PublicKey, *ecdsa.PublicKey)

BlindSession Request that the signer start a blind signature protocol. Returns the signer's public key and an EC point named R.

func BlindSign

func BlindSign(sState *BlindSignerState, R *ecdsa.PublicKey, mHat *big.Int) *big.Int

BlindSign Signs a blinded message

func BlindVerify

func BlindVerify(Q *ecdsa.PublicKey, sig *BlindSignature) bool

BlindVerify 不清楚干嘛的

func ECDH

func ECDH(priv *ecdsa.PrivateKey, pub *ecdsa.PublicKey) *big.Int

ECDH Calculate a shared secret using elliptic curve Diffie-Hellman

func GenerateKey

func GenerateKey(rand io.Reader) (*ecdsa.PrivateKey, error)

GenerateKey generates a public and private key pair

func KeysEqual

func KeysEqual(a, b *ecdsa.PublicKey) bool

KeysEqual check key equal

func RandFieldElement

func RandFieldElement(rand io.Reader) (k *big.Int, err error)

RandFieldElement returns a random element of the field underlying the given curve using the procedure given in [NSA] A.2.1.

Implementation copied from Go's crypto/ecdsa package since the function wasn't public. Modified to always use secp256k1 curve.

func ScalarBaseMult

func ScalarBaseMult(k *big.Int) *ecdsa.PublicKey

ScalarBaseMult Multiplies the base G by a large integer. The resulting point is represented as an ECDSA public key since that's typically how they're used.

func ScalarMult

func ScalarMult(k *big.Int, B *ecdsa.PublicKey) *ecdsa.PublicKey

ScalarMult Multiply a large integer and a point. The resulting point is represented as an ECDSA public key.

func Secp256k1

func Secp256k1() elliptic.Curve

Secp256k1 create curve object

Types

type BlindRequesterState

type BlindRequesterState struct {

	// shareable stuff
	F    *ecdsa.PublicKey
	X0   *big.Int //
	Mhat *big.Int // called m̂ in the paper
	// contains filtered or unexported fields
}

BlindRequesterState State

type BlindSignature

type BlindSignature struct {
	M, S *big.Int // called m and s in the paper
	F    *ecdsa.PublicKey
}

BlindSignature Based on algorithm described in An Efficient Blind Signature Scheme Based on the Elliptic Curve Discrete Logarithm Problem by Nikooghadam and Zakerolhosseini

func BlindExtract

func BlindExtract(rState *BlindRequesterState, sHat *big.Int) *BlindSignature

BlindExtract Extract true signature from the blind signature

type BlindSignerState

type BlindSignerState struct {

	// shareable stuff
	Q *ecdsa.PublicKey
	// contains filtered or unexported fields
}

BlindSignerState blind signer state

type KoblitzCurve

type KoblitzCurve struct {
	P       *big.Int // the order of the underlying field
	N       *big.Int // the order of the base point
	B       *big.Int // the constant of the KoblitzCurve equation
	Gx, Gy  *big.Int // (x,y) of the base point
	BitSize int      // the size of the underlying field
}

KoblitzCurve A Koblitz Curve with a=0.

func (*KoblitzCurve) Add

func (curve *KoblitzCurve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

Add add

func (*KoblitzCurve) Double

func (curve *KoblitzCurve) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

Double double

func (*KoblitzCurve) IsOnCurve

func (curve *KoblitzCurve) IsOnCurve(x, y *big.Int) bool

IsOnCurve check is on curve

func (*KoblitzCurve) Params

func (curve *KoblitzCurve) Params() *elliptic.CurveParams

Params 获取参数列表

func (*KoblitzCurve) ScalarBaseMult

func (curve *KoblitzCurve) ScalarBaseMult(k []byte) (*big.Int, *big.Int)

ScalarBaseMult multiple

func (*KoblitzCurve) ScalarMult

func (curve *KoblitzCurve) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)

ScalarMult scalar multiple

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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