Documentation ¶
Index ¶
- Constants
- Variables
- func IsSigVerificationErr(err error) bool
- type Address
- func (a Address) GhostPrivateKey(mask crypto.PublicKey, outputIndex uint64) crypto.PrivateKey
- func (a Address) GhostPublicKey(r crypto.PrivateKey, outputIndex uint64) crypto.PublicKey
- func (a Address) KeyStore() string
- func (a Address) MarshalJSON() ([]byte, error)
- func (a Address) SignJWTToken(typ JWTKeyType) (string, error)
- func (a Address) String() string
- func (a *Address) UnmarshalJSON(b []byte) error
- type CosiSignature
- type HXSingingPrivateKey
- type HXSingingPublicKey
- type Input
- type JWTClaim
- type JWTKeyType
- type Output
- type Script
- type SigningMethodHX
- type Snapshot
- type Transaction
- type UTXO
- type UTXOReader
Constants ¶
View Source
const ( Operator0 = 0x00 Operator64 = 0x40 OperatorSum = 0xfe OperatorCmp = 0xff )
View Source
const HXKeyStore = "HXKS"
View Source
const HXNetwork = "HX"
Symobl
Variables ¶
View Source
var (
ErrSigVerification = errors.New(errMsgVerificationFailed)
)
Functions ¶
func IsSigVerificationErr ¶ added in v0.2.1
Types ¶
type Address ¶ added in v0.0.2
type Address struct { PrivateSpendKey crypto.PrivateKey PrivateViewKey crypto.PrivateKey PrivateEncryptKey crypto.EPrivateKey PublicSpendKey crypto.PublicKey PublicViewKey crypto.PublicKey PublicEncryptKey crypto.EPublicKey }
地址数据结构,由三对密钥构成,分别为 SpendKey,ViewKey,和EncryptKey
func NewAddress ¶ added in v0.0.2
生成新的地址, 地址有3对密钥构成,分别是 Spend Key、 View Key 和 Encrypt Key
Spend Key 和 View Key 主要是在恒信的区块链网络中使用 Ecrypt Key 主要作用是用于对 数据仓库中加密数据的密钥进行密钥交换
三个密钥都不可以泄漏
func (Address) GhostPrivateKey ¶ added in v0.0.2
使用签名方的 Private SpendKey 和 ViewKey 生成用来签名 Private Key
func (Address) GhostPublicKey ¶ added in v0.0.2
使用接受方的 SpendKey 和 ViewKey 生成用来转账的 Public Key
func (Address) MarshalJSON ¶ added in v0.0.2
生成地址的字符串
func (Address) SignJWTToken ¶ added in v0.0.2
func (a Address) SignJWTToken(typ JWTKeyType) (string, error)
{ "iss": "HXxxxx", // 用户的Address "exp": 123, // 过期时间 "iat": 123, // 当前时间 "nc": "nonce", // 随机的nonce用于防重放 "sig": "xxx" // 签名 }
func (Address) String ¶ added in v0.0.2
根据用户的地址生成对外的交易地址 地址的格式规定如下 Address: HX + Base58(Public Spend Key + Public View Key + Public EncryptKey + CRC)
func (*Address) UnmarshalJSON ¶ added in v0.0.2
通过字符串恢复地址 自己有公钥可用,私钥并没有什么用处
type CosiSignature ¶ added in v0.2.2
type HXSingingPrivateKey ¶ added in v0.2.1
type HXSingingPublicKey ¶ added in v0.2.1
type JWTClaim ¶ added in v0.0.2
type JWTClaim struct { jwt.StandardClaims Nonce string `json:"jti,omitempty"` Signature string `json:"sig,omitempty"` Address *Address `json:"-"` }
func ParseJWTToken ¶ added in v0.0.2
func ParseJWTToken(typ JWTKeyType, token string) (*JWTClaim, error)
type JWTKeyType ¶ added in v0.0.2
type JWTKeyType int
const ( JWTKeyTypeVK JWTKeyType = iota JWTKeyTypeSK JWTKeyTypeEK )
type Script ¶
type Script []uint8
func NewThresholdScript ¶
func (Script) MarshalJSON ¶
func (*Script) UnmarshalJSON ¶
func (Script) VerifyFormat ¶
type SigningMethodHX ¶ added in v0.2.1
type SigningMethodHX struct{}
func (SigningMethodHX) Alg ¶ added in v0.2.1
func (k SigningMethodHX) Alg() string
func (SigningMethodHX) Sign ¶ added in v0.2.1
func (k SigningMethodHX) Sign(signingString string, key interface{}) (string, error)
func (SigningMethodHX) Verify ¶ added in v0.2.1
func (k SigningMethodHX) Verify(signingString, signature string, key interface{}) error
type Snapshot ¶
type Snapshot struct { Hash string `json:"hash"` Transaction *Transaction `json:"transaction,omitempty"` Topology int64 `json:"topology"` Timestamp int64 `json:"timestamp"` Signature *CosiSignature `json:"signature,omitempty"` }
type Transaction ¶
type Transaction struct { Hash *crypto.Hash `json:"hash,omitempty" msgpack:"-"` Version uint8 `json:"version"` Asset crypto.Hash `json:"asset"` Inputs []*Input `json:"inputs"` Outputs []*Output `json:"outputs"` Extra []byte `json:"extra,omitempty"` Signatures [][]crypto.Signature `json:"signatures,omitempty" msgpack:",omitempty"` Snapshot *crypto.Hash `json:"snapshot,omitempty" msgpack:"-"` }
func (*Transaction) MsgpackMarshal ¶
func (t *Transaction) MsgpackMarshal() ([]byte, error)
func (*Transaction) MsgpackMarshalPayload ¶
func (t *Transaction) MsgpackMarshalPayload() ([]byte, error)
func (*Transaction) TransactionHash ¶
func (t *Transaction) TransactionHash() (crypto.Hash, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.