Documentation ¶
Index ¶
- Constants
- func AtPadding(ciphertext []byte, blockSize int) []byte
- func DesDecrypt(crypted, key []byte) ([]byte, error)
- func DesEncrypt(origData, key []byte) ([]byte, error)
- func GenDIDKeyFromAccountJson(accountJson, password string) (key interface{}, err error)
- func GenKeyFromAccountJson(accountJson, password string) (key interface{}, err error)
- func NewAccount(password string) (string, error)
- func NewAccountDID(password string) (string, error)
- func NewAccountED25519(password string) (string, error)
- func NewAccountJson(acType, password string) (string, error)
- func NewAccountJsonFromPfx(password string, pfx []byte) (string, error)
- func NewAccountR1(password string) (string, error)
- func NewAccountSm2(password string) (string, error)
- func NewDIDAccountJson(acType, password string) (string, error)
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) []byte
- func ParseAccountJson(accountJson, password string) (newAccountJson string, err error)
- func ParseDIDAccountJson(accountJson, password string) (newAccountJson string, err error)
- func ZeroPadding(ciphertext []byte, blockSize int) []byte
- type DIDKey
- func NewDIDAccount(key Key, chainID, suffix string) (didKey *DIDKey)
- func NewDIDAccountByType(acType, password string, chainID, suffix string) (*DIDKey, error)
- func NewDIDFromAccountJson(accountJson, password string, chainID, suffix string) (*DIDKey, error)
- func NewDIDFromString(str string, password string) (*DIDKey, error)
- type ECDSAKey
- type ED25519Key
- type Key
- type PKIKey
- type SM2Key
Constants ¶
const ( ECKDF2 = "0x01" ECDES = "0x02" ECRAW = "0x03" ECAES = "0x04" EC3DES = "0x05" SMSM4 = "0x11" SMDES = "0x12" SMRAW = "0x13" SMAES = "0x14" SM3DES = "0x15" ED25519DES = "0x21" ED25519RAW = "0x22" ED25519AES = "0x23" ED255193DES = "0x24" ECKDF2R1 = "0x011" ECDESR1 = "0x021" ECRAWR1 = "0x031" ECAESR1 = "0x041" EC3DESR1 = "0x051" PKI = "0x41" V1 = "1.0" V2 = "2.0" V3 = "3.0" V4 = "4.0" DIDPREFIX = "did:hpc:" )
Variables ¶
This section is empty.
Functions ¶
func GenDIDKeyFromAccountJson ¶ added in v1.1.0
GenDIDKeyFromAccountJson generate ecdsa.Key or gm.Key by account type
func GenKeyFromAccountJson ¶
GenKeyFromAccountJson generate ecdsa.Key or gm.Key by account json
func NewAccount ¶
NewAccount create account using ecdsa if password is empty, the encrypted field will be private key. if want to create did account , use NewAccountDID instead.
func NewAccountDID ¶ added in v1.1.0
NewAccountDID create account using ecdsa if password is empty, the encrypted field will be private key.
func NewAccountED25519 ¶
NewAccountED25519 生成ed25519
func NewAccountJson ¶
NewAccountJson generate account json by account type
func NewAccountJsonFromPfx ¶
NewAccountJsonFromPfx create account json using pfx cert
func NewDIDAccountJson ¶ added in v1.1.0
NewDIDAccountJson generate account json by account type
func PKCS5Padding ¶
func PKCS5UnPadding ¶
func ParseAccountJson ¶
func ParseDIDAccountJson ¶ added in v1.1.0
func ZeroPadding ¶
Types ¶
type DIDKey ¶
type DIDKey struct { Key Key // contains filtered or unexported fields }
DIDKey used as didAccount
func NewDIDAccount ¶
func NewDIDAccountByType ¶ added in v1.4.0
NewDIDAccountByType new DID account by account type nolint
func NewDIDFromAccountJson ¶ added in v1.4.0
func NewDIDFromString ¶ added in v1.4.0
NewDIDFromString new did key from string str {didAddress: "", account: "accountJSON"} nolint
func (*DIDKey) GetNormalKey ¶
GetNormalKey return thr real key to sign
func (*DIDKey) PrivateBytes ¶
PrivateBytes return privateKey
func (*DIDKey) PublicBytes ¶
PublicBytes return publicKey
type ECDSAKey ¶
type ECDSAKey struct {
*asym.ECDSAPrivateKey
}
func NewAccountFromAccountJSON ¶
NewAccountFromAccountJSON ECDSA Key结构体 Deprecated
func NewAccountFromPriv ¶
NewAccountFromPriv 从私钥字节数组得到ECDSA Key结构体
func NewAccountR1FromPriv ¶
NewAccountR1FromPriv 从私钥字节数组得到ECDSA Key结构体
func NewDIDAccountFromPriv ¶ added in v1.1.0
func (*ECDSAKey) GetAddress ¶
func (*ECDSAKey) PrivateBytes ¶
func (*ECDSAKey) PublicBytes ¶
type ED25519Key ¶
type ED25519Key struct {
*ed25519.EDDSAPrivateKey
}
func (*ED25519Key) GetAddress ¶
func (key *ED25519Key) GetAddress() common.Address
func (*ED25519Key) PrivateBytes ¶
func (key *ED25519Key) PrivateBytes() ([]byte, error)
func (*ED25519Key) PublicBytes ¶
func (key *ED25519Key) PublicBytes() ([]byte, error)
type Key ¶
type Key interface { crypto.Signer GetAddress() common.Address PublicBytes() ([]byte, error) PrivateBytes() ([]byte, error) }
Key account key
type PKIKey ¶
func NewAccountFromCert ¶
NewAccountFromCert new account from pfx cert
func NewAccountPKI ¶
NewAccountPKI create account using pfx cert
func (*PKIKey) GetAddress ¶
func (*PKIKey) GetEncodedPfx ¶
func (*PKIKey) GetEncodedPrivKey ¶
func (*PKIKey) GetNormalKey ¶
func (*PKIKey) PrivateBytes ¶
func (*PKIKey) PublicBytes ¶
type SM2Key ¶
type SM2Key struct {
*gm.SM2PrivateKey
}
func NewAccountSm2FromAccountJSON ¶
NewAccountSm2FromAccountJSON 从账户JSON转为国密结构体 Deprecated
func NewAccountSm2FromPriv ¶
NewAccountSm2FromPriv 从私钥字符串生成国密结构体