bip0340

package
v1.0.5010 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 获取 Cipher 类型
	GetCipherFromName = pkcs8.GetCipherFromName
	// 获取 hash 类型
	GetHashFromName = pkcs8.GetHashFromName
)
View Source
var (
	ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key")
	ErrNotECPublicKey      = errors.New("key is not a valid BIP0340 public key")
	ErrNotECPrivateKey     = errors.New("key is not a valid BIP0340 private key")
)

Functions

This section is empty.

Types

type BIP0340

type BIP0340 struct {

	// 错误
	Errors []error
	// contains filtered or unexported fields
}

*

  • BIP0340 *
  • @create 2024-12-24
  • @author deatil

func FromBase64String

func FromBase64String(data string) BIP0340

Base64

func FromBytes

func FromBytes(data []byte) BIP0340

字节

func FromHexString

func FromHexString(data string) BIP0340

Hex

func FromPKCS1PrivateKey

func FromPKCS1PrivateKey(key []byte) BIP0340

私钥

func FromPKCS1PrivateKeyWithPassword

func FromPKCS1PrivateKeyWithPassword(key []byte, password string) BIP0340

私钥带密码

func FromPKCS8PrivateKey

func FromPKCS8PrivateKey(key []byte) BIP0340

PKCS8 私钥

func FromPKCS8PrivateKeyWithPassword

func FromPKCS8PrivateKeyWithPassword(key []byte, password string) BIP0340

PKCS8 私钥带密码

func FromPrivateKey

func FromPrivateKey(key []byte) BIP0340

私钥

func FromPrivateKeyWithPassword

func FromPrivateKeyWithPassword(key []byte, password string) BIP0340

私钥

func FromPublicKey

func FromPublicKey(key []byte) BIP0340

公钥

func FromString

func FromString(data string) BIP0340

字符

func GenerateKey

func GenerateKey(curve string) BIP0340

生成密钥 可选 [P521 | P384 | P256 | P224 | S256]

func GenerateKeyWithSeed

func GenerateKeyWithSeed(reader io.Reader, curve string) BIP0340

生成密钥 可选 [P521 | P384 | P256 | P224 | S256]

func New

func New() BIP0340

构造函数

func NewBIP0340

func NewBIP0340() BIP0340

构造函数

func (BIP0340) AppendError

func (this BIP0340) AppendError(err ...error) BIP0340

添加错误

func (BIP0340) CheckKeyPair

func (this BIP0340) CheckKeyPair() bool

检测公钥私钥是否匹配

func (BIP0340) CreatePKCS1PrivateKey

func (this BIP0340) CreatePKCS1PrivateKey() BIP0340

生成私钥 pem 数据

func (BIP0340) CreatePKCS1PrivateKeyWithPassword

func (this BIP0340) CreatePKCS1PrivateKeyWithPassword(password string, opts ...string) BIP0340

生成私钥带密码 pem 数据

func (BIP0340) CreatePKCS8PrivateKey

func (this BIP0340) CreatePKCS8PrivateKey() BIP0340

生成 PKCS8 私钥 pem 数据

func (BIP0340) CreatePKCS8PrivateKeyWithPassword

func (this BIP0340) CreatePKCS8PrivateKeyWithPassword(password string, opts ...any) BIP0340

生成 PKCS8 私钥带密码 pem 数据 CreatePKCS8PrivateKeyWithPassword("123", "AES256CBC", "SHA256")

func (BIP0340) CreatePrivateKey

func (this BIP0340) CreatePrivateKey() BIP0340

生成私钥 pem 数据, PKCS1 别名 使用: obj := New().WithCurve("P521").GenerateKey() priKey := obj.CreatePrivateKey().ToKeyString()

func (BIP0340) CreatePrivateKeyWithPassword

func (this BIP0340) CreatePrivateKeyWithPassword(password string, opts ...string) BIP0340

生成私钥带密码 pem 数据, PKCS1 别名 CreatePrivateKeyWithPassword("123", "AES256CBC") PEMCipher: DESCBC | DESEDE3CBC | AES128CBC | AES192CBC | AES256CBC

func (BIP0340) CreatePublicKey

func (this BIP0340) CreatePublicKey() BIP0340

生成公钥 pem 数据

func (BIP0340) Error

func (this BIP0340) Error() error

获取错误

func (BIP0340) FromBase64String

func (this BIP0340) FromBase64String(data string) BIP0340

Base64

func (BIP0340) FromBytes

func (this BIP0340) FromBytes(data []byte) BIP0340

字节

func (BIP0340) FromHexString

func (this BIP0340) FromHexString(data string) BIP0340

Hex

func (BIP0340) FromPKCS1PrivateKey

func (this BIP0340) FromPKCS1PrivateKey(key []byte) BIP0340

私钥

func (BIP0340) FromPKCS1PrivateKeyDer

func (this BIP0340) FromPKCS1PrivateKeyDer(der []byte) BIP0340

DER 私钥

func (BIP0340) FromPKCS1PrivateKeyWithPassword

func (this BIP0340) FromPKCS1PrivateKeyWithPassword(key []byte, password string) BIP0340

私钥带密码

func (BIP0340) FromPKCS8PrivateKey

func (this BIP0340) FromPKCS8PrivateKey(key []byte) BIP0340

PKCS8 私钥

func (BIP0340) FromPKCS8PrivateKeyDer

func (this BIP0340) FromPKCS8PrivateKeyDer(der []byte) BIP0340

DER 私钥

func (BIP0340) FromPKCS8PrivateKeyWithPassword

func (this BIP0340) FromPKCS8PrivateKeyWithPassword(key []byte, password string) BIP0340

Pkcs8WithPassword

func (BIP0340) FromPrivateKey

func (this BIP0340) FromPrivateKey(key []byte) BIP0340

私钥

func (BIP0340) FromPrivateKeyBytes

func (this BIP0340) FromPrivateKeyBytes(priByte []byte) BIP0340

明文私钥生成私钥结构体 需要设置对应的 curve

func (BIP0340) FromPrivateKeyString

func (this BIP0340) FromPrivateKeyString(keyString string) BIP0340

私钥明文,需要设置对应的 curve private-key: 07e4********;

func (BIP0340) FromPrivateKeyWithPassword

func (this BIP0340) FromPrivateKeyWithPassword(key []byte, password string) BIP0340

私钥带密码

func (BIP0340) FromPublicKey

func (this BIP0340) FromPublicKey(key []byte) BIP0340

公钥

func (BIP0340) FromPublicKeyBytes

func (this BIP0340) FromPublicKeyBytes(pub []byte) BIP0340

公钥明文, hex 或者 base64 解码后 需要设置对应的 curve

func (BIP0340) FromPublicKeyCompressString

func (this BIP0340) FromPublicKeyCompressString(key string) BIP0340

公钥明文压缩 需要设置对应的 curve public-key hex: 027c******** || 036c********

func (BIP0340) FromPublicKeyDer

func (this BIP0340) FromPublicKeyDer(der []byte) BIP0340

DER 公钥

func (BIP0340) FromPublicKeyString

func (this BIP0340) FromPublicKeyString(key string) BIP0340

公钥明文,需要设置对应的 curve

func (BIP0340) FromPublicKeyUncompressString

func (this BIP0340) FromPublicKeyUncompressString(key string) BIP0340

公钥明文未压缩 需要设置对应的 curve public-key hex: 047c********.

func (BIP0340) FromPublicKeyXYBytes

func (this BIP0340) FromPublicKeyXYBytes(xBytes, yBytes []byte) BIP0340

公钥字符对,需要设置对应的 curve

func (BIP0340) FromPublicKeyXYString

func (this BIP0340) FromPublicKeyXYString(xString string, yString string) BIP0340

公钥 x,y 16进制字符对 需要设置对应的 curve [xString: xHexString, yString: yHexString]

func (BIP0340) FromString

func (this BIP0340) FromString(data string) BIP0340

字符

func (BIP0340) GenerateKey

func (this BIP0340) GenerateKey() BIP0340

生成密钥

func (BIP0340) GenerateKeyWithSeed

func (this BIP0340) GenerateKeyWithSeed(reader io.Reader) BIP0340

生成密钥

func (BIP0340) GetCurve

func (this BIP0340) GetCurve() elliptic.Curve

get Curve

func (BIP0340) GetData

func (this BIP0340) GetData() []byte

get data

func (BIP0340) GetEncoding

func (this BIP0340) GetEncoding() EncodingType

get Encoding type

func (BIP0340) GetErrors

func (this BIP0340) GetErrors() []error

get errors

func (BIP0340) GetKeyData

func (this BIP0340) GetKeyData() []byte

get keyData

func (BIP0340) GetParsedData

func (this BIP0340) GetParsedData() []byte

get parsedData

func (BIP0340) GetPrivateKey

func (this BIP0340) GetPrivateKey() *bip0340.PrivateKey

get PrivateKey

func (BIP0340) GetPrivateKeyCurve

func (this BIP0340) GetPrivateKeyCurve() elliptic.Curve

get PrivateKey Curve

func (BIP0340) GetPrivateKeyDString

func (this BIP0340) GetPrivateKeyDString() string

get PrivateKey D hex string

func (BIP0340) GetPrivateKeyString

func (this BIP0340) GetPrivateKeyString() string

get PrivateKey data hex string

func (BIP0340) GetPublicKey

func (this BIP0340) GetPublicKey() *bip0340.PublicKey

get PublicKey

func (BIP0340) GetPublicKeyCompressString

func (this BIP0340) GetPublicKeyCompressString() string

get PublicKey Compress Hex string

func (BIP0340) GetPublicKeyCurve

func (this BIP0340) GetPublicKeyCurve() elliptic.Curve

get PublicKey Curve

func (BIP0340) GetPublicKeyUncompressString

func (this BIP0340) GetPublicKeyUncompressString() string

get PublicKey Uncompress Hex string

func (BIP0340) GetPublicKeyXString

func (this BIP0340) GetPublicKeyXString() string

get PublicKey X hex string

func (BIP0340) GetPublicKeyXYString

func (this BIP0340) GetPublicKeyXYString() string

get PublicKey X and Y Hex string

func (BIP0340) GetPublicKeyYString

func (this BIP0340) GetPublicKeyYString() string

get PublicKey Y hex string

func (BIP0340) GetSignHash

func (this BIP0340) GetSignHash() HashFunc

get signHash type

func (BIP0340) GetVerify

func (this BIP0340) GetVerify() bool

get verify data

func (BIP0340) MakeKeyDer

func (this BIP0340) MakeKeyDer() BIP0340

生成密钥 der 数据

func (BIP0340) MakePublicKey

func (this BIP0340) MakePublicKey() BIP0340

生成公钥

func (BIP0340) OnError

func (this BIP0340) OnError(fn Bip0340ErrorFunc) BIP0340

引出错误信息

func (BIP0340) ParsePKCS1PrivateKeyFromPEM

func (this BIP0340) ParsePKCS1PrivateKeyFromPEM(key []byte) (*bip0340.PrivateKey, error)

解析私钥

func (BIP0340) ParsePKCS1PrivateKeyFromPEMWithPassword

func (this BIP0340) ParsePKCS1PrivateKeyFromPEMWithPassword(key []byte, password string) (*bip0340.PrivateKey, error)

解析私钥带密码

func (BIP0340) ParsePKCS8PrivateKeyFromPEM

func (this BIP0340) ParsePKCS8PrivateKeyFromPEM(key []byte) (*bip0340.PrivateKey, error)

解析私钥

func (BIP0340) ParsePKCS8PrivateKeyFromPEMWithPassword

func (this BIP0340) ParsePKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*bip0340.PrivateKey, error)

解析 PKCS8 带密码的私钥

func (BIP0340) ParsePublicKeyFromPEM

func (this BIP0340) ParsePublicKeyFromPEM(key []byte) (*bip0340.PublicKey, error)

解析公钥

func (BIP0340) SetCurve

func (this BIP0340) SetCurve(curve string) BIP0340

设置曲线类型 可选参数: [ P521 | P384 | P256 | P224 | S256 ]

func (BIP0340) SetSignHash

func (this BIP0340) SetSignHash(name string) BIP0340

设置 hash 类型

func (BIP0340) Sign

func (this BIP0340) Sign() BIP0340

私钥签名

func (BIP0340) SignASN1

func (this BIP0340) SignASN1() BIP0340

私钥签名 ASN1

func (BIP0340) SignBytes

func (this BIP0340) SignBytes() BIP0340

私钥签名 Bytes

func (BIP0340) ToBase64String

func (this BIP0340) ToBase64String() string

输出Base64

func (BIP0340) ToBytes

func (this BIP0340) ToBytes() []byte

输出字节

func (BIP0340) ToHexString

func (this BIP0340) ToHexString() string

输出Hex

func (BIP0340) ToKeyBytes

func (this BIP0340) ToKeyBytes() []byte

私钥/公钥

func (BIP0340) ToKeyString

func (this BIP0340) ToKeyString() string

私钥/公钥

func (BIP0340) ToString

func (this BIP0340) ToString() string

输出字符

func (BIP0340) ToVerify

func (this BIP0340) ToVerify() bool

验证结果

func (BIP0340) ToVerifyInt

func (this BIP0340) ToVerifyInt() int

验证结果,返回 int 类型

func (BIP0340) Verify

func (this BIP0340) Verify(data []byte) BIP0340

公钥验证 使用原始数据[data]对比签名后数据

func (BIP0340) VerifyASN1

func (this BIP0340) VerifyASN1(data []byte) BIP0340

公钥验证 ASN1 使用原始数据[data]对比签名后数据

func (BIP0340) VerifyBytes

func (this BIP0340) VerifyBytes(data []byte) BIP0340

公钥验证 Bytes 使用原始数据[data]对比签名后数据

func (BIP0340) WithCurve

func (this BIP0340) WithCurve(curve elliptic.Curve) BIP0340

设置曲线类型

func (BIP0340) WithData

func (this BIP0340) WithData(data []byte) BIP0340

设置 data

func (BIP0340) WithEncoding

func (this BIP0340) WithEncoding(encoding EncodingType) BIP0340

设置编码方式

func (BIP0340) WithEncodingASN1

func (this BIP0340) WithEncodingASN1() BIP0340

设置 ASN1 编码方式

func (BIP0340) WithEncodingBytes

func (this BIP0340) WithEncodingBytes() BIP0340

设置明文编码方式

func (BIP0340) WithErrors

func (this BIP0340) WithErrors(errs []error) BIP0340

设置错误

func (BIP0340) WithParsedData

func (this BIP0340) WithParsedData(data []byte) BIP0340

设置 parsedData

func (BIP0340) WithPrivateKey

func (this BIP0340) WithPrivateKey(data *bip0340.PrivateKey) BIP0340

设置 PrivateKey

func (BIP0340) WithPublicKey

func (this BIP0340) WithPublicKey(data *bip0340.PublicKey) BIP0340

设置 PublicKey

func (BIP0340) WithSignHash

func (this BIP0340) WithSignHash(hash HashFunc) BIP0340

设置 hash 类型

func (BIP0340) WithVerify

func (this BIP0340) WithVerify(data bool) BIP0340

设置验证结果

type Bip0340ErrorFunc

type Bip0340ErrorFunc = func([]error)

错误方法

type EncodingType

type EncodingType uint

数据编码方式 marshal data type

const (
	EncodingASN1 EncodingType = 1 + iota
	EncodingBytes
)

type HashFunc

type HashFunc = func() hash.Hash

HashFunc

type Opts

type Opts = pkcs8.Opts

配置

type PBKDF2Opts

type PBKDF2Opts = pkcs8.PBKDF2Opts

PBKDF2 配置

type ScryptOpts

type ScryptOpts = pkcs8.ScryptOpts

Scrypt 配置

Jump to

Keyboard shortcuts

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