Documentation ¶
Index ¶
- Constants
- Variables
- func DecryptCBC(data, iv []byte, key SharedKey) ([]byte, error)
- func EncryptCBC(data, iv []byte, key SharedKey) ([]byte, error)
- func GenerateMnemonic(length int, language string) (string, error)
- func SignMsg(privKey PrivateKey, msg []byte) []byte
- func ToSeed(mnemonic, password string) []byte
- func VerifyMsg(pubKey PublicKey, originMsg, signMsg []byte) bool
- type CryptoJson
- type Keypair
- type Keystore
- type PrivateKey
- func (pk PrivateKey) Bytes() []byte
- func (pk PrivateKey) GetPubKey() PublicKey
- func (pk PrivateKey) HexString() string
- func (pk *PrivateKey) LoadFromBytes(d []byte) error
- func (pk *PrivateKey) LoadFromHex(s string) error
- func (pk PrivateKey) SignMsg(msg []byte) []byte
- func (pk PrivateKey) ToEd25519PrivKey() ed25519.PrivateKey
- type PublicKey
- type SharedKey
Constants ¶
View Source
const ( EntropyBits128 int = 128 EntropyBits160 int = 160 EntropyBits192 int = 192 EntropyBits224 int = 224 EntropyBits256 int = 256 )
View Source
const ( // StandardScryptN is the N parameter of Scrypt encryption algorithm, using 256MB // memory and taking approximately 1s CPU time on a modern processor. StandardScryptN = 1 << 18 // StandardScryptP is the P parameter of Scrypt encryption algorithm, using 256MB // memory and taking approximately 1s CPU time on a modern processor. StandardScryptP = 1 // LightScryptN is the N parameter of Scrypt encryption algorithm, using 4MB // memory and taking approximately 100ms CPU time on a modern processor. LightScryptN = 1 << 12 // LightScryptP is the P parameter of Scrypt encryption algorithm, using 4MB // memory and taking approximately 100ms CPU time on a modern processor. LightScryptP = 6 )
View Source
const PrivateKeyLength int = ed25519.PrivateKeySize
View Source
const PublicKeyLength int = ed25519.PublicKeySize
Variables ¶
View Source
var (
ErrDecrypt = errors.New("could not decrypt key with given password")
)
Functions ¶
func GenerateMnemonic ¶
GenerateMnemonic 生成助记词 length 助记词长度 language 助记词语言 cn:中文简体,en:英语
func SignMsg ¶
func SignMsg(privKey PrivateKey, msg []byte) []byte
Types ¶
type CryptoJson ¶
type Keypair ¶
type Keypair struct {
// contains filtered or unexported fields
}
func LoadFromPrivKeyBytes ¶
func (Keypair) PrivateKey ¶
func (kp Keypair) PrivateKey() PrivateKey
func (Keypair) SaveAsKeystore ¶
type Keystore ¶
type Keystore struct { PubKey string Crypto CryptoJson `json:"crtpto"` // contains filtered or unexported fields }
func LoadKeystore ¶
type PrivateKey ¶
type PrivateKey [PrivateKeyLength]byte
func NewPrivateKey ¶
func NewPrivateKey(seed []byte) PrivateKey
func (PrivateKey) Bytes ¶
func (pk PrivateKey) Bytes() []byte
func (PrivateKey) GetPubKey ¶
func (pk PrivateKey) GetPubKey() PublicKey
func (PrivateKey) HexString ¶
func (pk PrivateKey) HexString() string
func (*PrivateKey) LoadFromBytes ¶
func (pk *PrivateKey) LoadFromBytes(d []byte) error
func (*PrivateKey) LoadFromHex ¶
func (pk *PrivateKey) LoadFromHex(s string) error
func (PrivateKey) SignMsg ¶
func (pk PrivateKey) SignMsg(msg []byte) []byte
func (PrivateKey) ToEd25519PrivKey ¶
func (pk PrivateKey) ToEd25519PrivKey() ed25519.PrivateKey
type SharedKey ¶
type SharedKey [32]byte
func SharedSecret ¶
func SharedSecret(privK PrivateKey, pubK PublicKey) (SharedKey, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.