secp256k1

package
v0.0.0-...-f8b7a73 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 License: GPL-3.0, BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

包secp256k1包装比特币secp256k1 c库。

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMsgLen       = errors.New("invalid message length, need 32 bytes")
	ErrInvalidSignatureLen = errors.New("invalid signature length")
	ErrInvalidRecoveryID   = errors.New("invalid signature recovery id")
	ErrInvalidKey          = errors.New("invalid private key")
	ErrInvalidPubkey       = errors.New("invalid public key")
	ErrSignFailed          = errors.New("signing failed")
	ErrRecoverFailed       = errors.New("recovery failed")
)

Functions

func CompressPubkey

func CompressPubkey(x, y *big.Int) []byte

compresspubkey将公钥编码为33字节的压缩格式。

func DecompressPubkey

func DecompressPubkey(pubkey []byte) (x, y *big.Int)

DecompressPubkey parses a public key in the 33-byte compressed format. 如果公钥有效,则返回非零坐标。

func RecoverPubkey

func RecoverPubkey(msg []byte, sig []byte) ([]byte, error)

recoverpubkey返回签名者的公钥。 msg必须是要签名的消息的32字节哈希。 SIG必须是包含 作为最后一个元素的恢复ID。

func Sign

func Sign(msg []byte, seckey []byte) ([]byte, error)

签名创建可恢复的ECDSA签名。 生成的签名采用65字节的格式,其中v为0或1。

调用者负责确保不能选择消息 由攻击者直接攻击。通常最好使用密码 在将任何输入传递给此函数之前,对其执行哈希函数。

func VerifySignature

func VerifySignature(pubkey, msg, signature []byte) bool

验证签名检查给定的PUBKEY在消息上创建签名。 签名应采用[R S]格式。

Types

type BitCurve

type BitCurve struct {
	P       *big.Int //基础字段的顺序
	N       *big.Int //基点顺序
	B       *big.Int //比特库夫方程的常数
	Gx, Gy  *big.Int //基点的(x,y)
	BitSize int      //基础字段的大小
}

Bitcurve表示a=0的Koblitz曲线。 See http://www.hyperelliptic.org/EFD/g1p/auto-shortw.html

func S256

func S256() *BitCurve

s256返回一个实现secp256k1的bitcurve。

func (*BitCurve) Add

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

add返回(x1,y1)和(x2,y2)的和

func (*BitCurve) Double

func (BitCurve *BitCurve) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

双回路2*(x,y)

func (*BitCurve) IsOnCurve

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

如果给定的(x,y)位于比特币上,isoncurve返回true。

func (*BitCurve) Marshal

func (BitCurve *BitCurve) Marshal(x, y *big.Int) []byte

marshal将点转换为ANSI第4.3.6节中指定的格式 X962.

func (*BitCurve) Params

func (BitCurve *BitCurve) Params() *elliptic.CurveParams

func (*BitCurve) ScalarBaseMult

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

scalarbasemult返回k*g,其中g是组的基点,k是 大尾数形式的整数。

func (*BitCurve) ScalarMult

func (BitCurve *BitCurve) ScalarMult(Bx, By *big.Int, scalar []byte) (*big.Int, *big.Int)

func (*BitCurve) Unmarshal

func (BitCurve *BitCurve) Unmarshal(data []byte) (x, y *big.Int)

unmarshal将一个点(由marshal序列化)转换为x,y对。论 误差,x= nIL。

Jump to

Keyboard shortcuts

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