account

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: Apache-2.0 Imports: 20 Imported by: 4

Documentation

Index

Constants

View Source
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 AtPadding

func AtPadding(ciphertext []byte, blockSize int) []byte

func DesDecrypt

func DesDecrypt(crypted, key []byte) ([]byte, error)

DesDecrypt des decrypt

func DesEncrypt

func DesEncrypt(origData, key []byte) ([]byte, error)

DesEncrypt des encrypt

func GenDIDKeyFromAccountJson added in v1.1.0

func GenDIDKeyFromAccountJson(accountJson, password string) (key interface{}, err error)

GenDIDKeyFromAccountJson generate ecdsa.Key or gm.Key by account type

func GenKeyFromAccountJson

func GenKeyFromAccountJson(accountJson, password string) (key interface{}, err error)

GenKeyFromAccountJson generate ecdsa.Key or gm.Key by account json

func NewAccount

func NewAccount(password string) (string, error)

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

func NewAccountDID(password string) (string, error)

NewAccountDID create account using ecdsa if password is empty, the encrypted field will be private key.

func NewAccountED25519

func NewAccountED25519(password string) (string, error)

NewAccountED25519 生成ed25519

func NewAccountJson

func NewAccountJson(acType, password string) (string, error)

NewAccountJson generate account json by account type

func NewAccountJsonFromPfx

func NewAccountJsonFromPfx(password string, pfx []byte) (string, error)

NewAccountJsonFromPfx create account json using pfx cert

func NewAccountR1

func NewAccountR1(password string) (string, error)

NewAccountR1 生成国密

func NewAccountSm2

func NewAccountSm2(password string) (string, error)

NewAccountSm2 生成国密

func NewDIDAccountJson added in v1.1.0

func NewDIDAccountJson(acType, password string) (string, error)

NewDIDAccountJson generate account json by account type

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func ParseAccountJson

func ParseAccountJson(accountJson, password string) (newAccountJson string, err error)

func ParseDIDAccountJson added in v1.1.0

func ParseDIDAccountJson(accountJson, password string) (newAccountJson string, err error)

func ZeroPadding

func ZeroPadding(ciphertext []byte, blockSize int) []byte

Types

type DIDKey

type DIDKey struct {
	Key Key
	// contains filtered or unexported fields
}

DIDKey used as didAccount

func NewDIDAccount

func NewDIDAccount(key Key, chainID, suffix string) (didKey *DIDKey)

func NewDIDAccountByType added in v1.4.0

func NewDIDAccountByType(acType, password string, chainID, suffix string) (*DIDKey, error)

NewDIDAccountByType new DID account by account type nolint

func NewDIDFromAccountJson added in v1.4.0

func NewDIDFromAccountJson(accountJson, password string, chainID, suffix string) (*DIDKey, error)

func NewDIDFromString added in v1.4.0

func NewDIDFromString(str string, password string) (*DIDKey, error)

NewDIDFromString new did key from string str {didAddress: "", account: "accountJSON"} nolint

func (*DIDKey) GetAddress

func (didKey *DIDKey) GetAddress() string

GetAddress return didAddress

func (*DIDKey) GetNormalKey

func (didKey *DIDKey) GetNormalKey() Key

GetNormalKey return thr real key to sign

func (*DIDKey) PrivateBytes

func (didKey *DIDKey) PrivateBytes() ([]byte, error)

PrivateBytes return privateKey

func (*DIDKey) PublicBytes

func (didKey *DIDKey) PublicBytes() ([]byte, error)

PublicBytes return publicKey

type ECDSAKey

type ECDSAKey struct {
	*asym.ECDSAPrivateKey
}

func NewAccountFromAccountJSON

func NewAccountFromAccountJSON(accountjson, password string) (key *ECDSAKey, err error)

NewAccountFromAccountJSON ECDSA Key结构体 Deprecated

func NewAccountFromPriv

func NewAccountFromPriv(priv string) (*ECDSAKey, error)

NewAccountFromPriv 从私钥字节数组得到ECDSA Key结构体

func NewAccountR1FromPriv

func NewAccountR1FromPriv(priv string) (*ECDSAKey, error)

NewAccountR1FromPriv 从私钥字节数组得到ECDSA Key结构体

func NewDIDAccountFromPriv added in v1.1.0

func NewDIDAccountFromPriv(priv string) (*ECDSAKey, error)

func (*ECDSAKey) GetAddress

func (key *ECDSAKey) GetAddress() common.Address

func (*ECDSAKey) PrivateBytes

func (key *ECDSAKey) PrivateBytes() ([]byte, error)

func (*ECDSAKey) PublicBytes

func (key *ECDSAKey) PublicBytes() ([]byte, error)

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

type PKIKey struct {
	crypto.Signer
	// contains filtered or unexported fields
}

func NewAccountFromCert

func NewAccountFromCert(pfx []byte, password string) (key *PKIKey, err error)

NewAccountFromCert new account from pfx cert

func NewAccountPKI

func NewAccountPKI(password string, pfx []byte) (key *PKIKey, err error)

NewAccountPKI create account using pfx cert

func (*PKIKey) GetAddress

func (key *PKIKey) GetAddress() common.Address

func (*PKIKey) GetEncodedPfx

func (key *PKIKey) GetEncodedPfx() string

func (*PKIKey) GetEncodedPrivKey

func (key *PKIKey) GetEncodedPrivKey() string

func (*PKIKey) GetNormalKey

func (key *PKIKey) GetNormalKey() Key

func (*PKIKey) PrivateBytes

func (key *PKIKey) PrivateBytes() ([]byte, error)

func (*PKIKey) PublicBytes

func (key *PKIKey) PublicBytes() ([]byte, error)

type SM2Key

type SM2Key struct {
	*gm.SM2PrivateKey
}

func NewAccountSm2FromAccountJSON

func NewAccountSm2FromAccountJSON(accountjson, password string) (key *SM2Key, err error)

NewAccountSm2FromAccountJSON 从账户JSON转为国密结构体 Deprecated

func NewAccountSm2FromPriv

func NewAccountSm2FromPriv(priv string) (*SM2Key, error)

NewAccountSm2FromPriv 从私钥字符串生成国密结构体

func (*SM2Key) GetAddress

func (key *SM2Key) GetAddress() common.Address

func (*SM2Key) PrivateBytes

func (key *SM2Key) PrivateBytes() ([]byte, error)

func (*SM2Key) PublicBytes

func (key *SM2Key) PublicBytes() ([]byte, error)

Jump to

Keyboard shortcuts

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