Documentation
¶
Index ¶
- Variables
- func AesDecrypt(crypted, key []byte) ([]byte, error)
- func AesEncrypt(origData, key []byte) ([]byte, error)
- func Base64UrlDecode(content string) ([]byte, error)
- func Base64UrlEncode(content []byte) string
- func CheckSign(req *http.Request, cred *Credentials) error
- func DecodeSign(signature string) ([]byte, error)
- func EncodeSign(src []byte) string
- func GetAddrByPubKey(key *ecdsa.PublicKey) (string, error)
- func GetEcdsaPriKeyByJsStr(keyStr string) (*ecdsa.PrivateKey, error)
- func GetEcdsaPubKeyByJsStr(keyStr string) (*ecdsa.PublicKey, error)
- func HashBySha256(data []byte) []byte
- func InferLanguage(mnemonic string) int
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) []byte
- func Sign(req *http.Request, cred *Credentials, opt *SignOptions) (string, error)
- func SignECDSA(k *ecdsa.PrivateKey, msg []byte) ([]byte, error)
- func VerifyAddrByPubKey(address string, pub *ecdsa.PublicKey) (bool, uint8)
- func VerifyECDSA(k *ecdsa.PublicKey, signature, msg []byte) (bool, error)
- func XassetSignECDSA(jsPrivtKey string, oriMsg []byte) (string, error)
- func XassetVerifyECDSA(jsPubKey, signature string, oriMsg []byte) (bool, error)
- type Account
- type Credentials
- type MnemLang
- type MnemStrgth
- type SignOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var ( BCE_AUTH_VERSION = "bce-auth-v1" SIGN_JOINER = "\n" SIGN_HEADER_JOINER = ";" DEFAULT_EXPIRE_SECONDS = 1800 DEFAULT_HEADERS_TO_SIGN = map[string]struct{}{ strings.ToLower("Host"): {}, strings.ToLower("Content-Length"): {}, strings.ToLower("Content-Type"): {}, strings.ToLower("Content-Md5"): {}, } )
Functions ¶
func Base64UrlDecode ¶ added in v1.0.12
func Base64UrlEncode ¶ added in v1.0.12
func GetEcdsaPriKeyByJsStr ¶
func GetEcdsaPriKeyByJsStr(keyStr string) (*ecdsa.PrivateKey, error)
从json格式私钥内容字符串产生ECC私钥
func GetEcdsaPubKeyByJsStr ¶
从json格式公钥内容字符串产生ECC公钥
func PKCS7Padding ¶ added in v1.0.12
func PKCS7UnPadding ¶ added in v1.0.12
func Sign ¶
func Sign(req *http.Request, cred *Credentials, opt *SignOptions) (string, error)
Sign - 签名
PARAMS:
- req: *http.Request for this sign
- cred: *BceCredentials to access the serice
- opt: *SignOptions for this sign algorithm
func VerifyAddrByPubKey ¶
验证钱包地址和公钥是否匹配
func VerifyECDSA ¶
使用ECC公钥来验证签名,验证统一签名的新签名函数
func XassetSignECDSA ¶
xasset签名完整方法 @jsPrivtKey: json格式的private key @oriMsg: 签名的原始数据
Types ¶
type Account ¶
type Account struct { // 钱包地址 Address string `json:"address,omitempy"` // 私钥 PrivateKey string `json:"private_key,omitempy"` // 公钥 PublicKey string `json:"public_key,omitempy"` // 助记词 Mnemonic string `json:"mnemonic,omitempy"` }
func NewXchainEcdsaAccount ¶
func NewXchainEcdsaAccount(strg MnemStrgth, lang MnemLang) (*Account, error)
新创建xuperchain ecdsa账户
type Credentials ¶
type Credentials struct { AppId int64 // app id AccessKeyId string // access key id to the service SecretAccessKey string // secret access key to the service }
func (*Credentials) String ¶
func (t *Credentials) String() string
type MnemLang ¶
type MnemLang int
助记词语言:英文、中文
const ( // 1:中文 MnemLangCN MnemLang // 2:英文 MnemLangEN )
type MnemStrgth ¶
type MnemStrgth int
助记词强度:弱、中、强
const ( // 1:弱(12个助记词) MnemStrgthWeak MnemStrgth // 2:中(18个助记词) MnemStrgthMedium // 3:强(24个助记词) MnemStrgthStrong )
type SignOptions ¶
SignOptions defines the data structure used by Signer
func (*SignOptions) String ¶
func (t *SignOptions) String() string
Click to show internal directories.
Click to hide internal directories.