Documentation ¶
Index ¶
- func Base64Decode(data string) []byte
- func Base64Encode(data []byte) string
- func BytesToPrivateKey(privData []byte) *rsa.PrivateKey
- func BytesToPublicKey(pubData []byte) *rsa.PublicKey
- func DecryptAES(key, data []byte) []byte
- func DecryptRSA(priv *rsa.PrivateKey, data []byte) []byte
- func EncryptAES(key, data []byte) []byte
- func EncryptRSA(pub *rsa.PublicKey, data []byte) []byte
- func GenerateBytes(max uint) []byte
- func GenerateKey(bits uint) *rsa.PrivateKey
- func Get(key string) interface{}
- func HashPublicKey(pub *rsa.PublicKey) string
- func HashSum(data []byte) []byte
- func PrivateKeyToBytes(priv *rsa.PrivateKey) []byte
- func PrivateKeyToString(priv *rsa.PrivateKey) string
- func ProofIsValid(packHash []byte, diff uint, nonce uint64) bool
- func ProofOfWork(packHash []byte, diff uint) uint64
- func PublicKeyToBytes(pub *rsa.PublicKey) []byte
- func PublicKeyToString(pub *rsa.PublicKey) string
- func RaiseEntropy(info, salt []byte, bits int) []byte
- func SerializePackage(pack *Package) string
- func Set(settings SettingsType) []uint8
- func Sign(priv *rsa.PrivateKey, data []byte) []byte
- func StringToPrivateKey(privData string) *rsa.PrivateKey
- func StringToPublicKey(pubData string) *rsa.PublicKey
- func ToBytes(num uint64) []byte
- func Verify(pub *rsa.PublicKey, data, sign []byte) error
- type BodyPackage
- type Client
- func (client *Client) Connect(address string) error
- func (client *Client) Connections() []string
- func (client *Client) Decrypt(pack *Package) *Package
- func (client *Client) Disconnect(address string)
- func (client *Client) Encrypt(receiver *rsa.PublicKey, pack *Package) *Package
- func (client *Client) Handle(title string, pack *Package, handle func(*Client, *Package) string)
- func (client *Client) InConnections(address string) bool
- func (client *Client) PrivateKey() *rsa.PrivateKey
- func (client *Client) PublicKey() *rsa.PublicKey
- func (client *Client) RoutePackage(receiver *rsa.PublicKey, pack *Package, route []*rsa.PublicKey, ...) *Package
- func (client *Client) RunNode(address string) error
- func (client *Client) Send(receiver *rsa.PublicKey, pack *Package, route []*rsa.PublicKey, ...) (string, error)
- type HeadPackage
- type Package
- type SettingsType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶
func Base64Encode ¶
func BytesToPrivateKey ¶ added in v1.2.6
func BytesToPrivateKey(privData []byte) *rsa.PrivateKey
Used PKCS1.
func BytesToPublicKey ¶ added in v1.2.6
Used PKCS1.
func GenerateBytes ¶ added in v1.2.0
Generates a cryptographically strong pseudo-random sequence.
func GenerateKey ¶ added in v1.2.6
func GenerateKey(bits uint) *rsa.PrivateKey
Create private key by number of bits.
func HashPublicKey ¶ added in v1.2.6
HashPublicKey(x) = Base64Encode(HashSum(PublicKeyToBytes(x))).
func PrivateKeyToBytes ¶ added in v1.2.6
func PrivateKeyToBytes(priv *rsa.PrivateKey) []byte
Used PKCS1.
func PrivateKeyToString ¶ added in v1.2.6
func PrivateKeyToString(priv *rsa.PrivateKey) string
PrivateKeyToString(x) = Base64Encode(PrivateKeyToBytes(x)).
func ProofIsValid ¶ added in v1.2.1
Verifies the work of the proof of work function.
func ProofOfWork ¶
Proof of work by the method of finding the desired hash. Hash must start with 'diff' number of zero bits.
func PublicKeyToBytes ¶ added in v1.2.6
Used PKCS1.
func PublicKeyToString ¶ added in v1.2.6
PublicKeyToString(x) = Base64Encode(PublicKeyToBytes(pub)).
func RaiseEntropy ¶ added in v1.2.6
Increase entropy by multiple hashing.
func SerializePackage ¶ added in v1.2.2
Serialize with JSON format.
func Set ¶
func Set(settings SettingsType) []uint8
func StringToPrivateKey ¶ added in v1.2.6
func StringToPrivateKey(privData string) *rsa.PrivateKey
StringToPrivateKey(x) = BytesToPrivateKey(Base64Decode(x)).
func StringToPublicKey ¶ added in v1.2.6
StringToPublicKey(x) = BytesToPublicKey(Base64Decode(x)).
Types ¶
type BodyPackage ¶ added in v1.2.0
type Client ¶
type Client struct { F2F *friendToFriend // contains filtered or unexported fields }
Basic structure describing the user. Stores the private key and list of friends.
func NewClient ¶ added in v1.2.0
func NewClient(priv *rsa.PrivateKey, handle func(*Client, *Package)) *Client
Create client by private key as identification. Handle function is used when the network exists. Can be null.
func (*Client) Connections ¶
Get list of connection addresses.
func (*Client) Decrypt ¶ added in v1.2.3
Decrypt package with private key of receiver. No one else except the sender will be able to decrypt the package.
func (*Client) Disconnect ¶
Disconnect from node by address.
func (*Client) Encrypt ¶ added in v1.2.3
Encrypt package with public key of receiver. The package can be decrypted only if private key is known.
func (*Client) Handle ¶ added in v1.2.5
Handle package by title. If title equal title in package then go to handle function.
func (*Client) InConnections ¶
Check the existence of an address in the list of connections.
func (*Client) PrivateKey ¶ added in v1.2.6
func (client *Client) PrivateKey() *rsa.PrivateKey
Get private key from client object.
func (*Client) RoutePackage ¶ added in v1.2.6
func (client *Client) RoutePackage(receiver *rsa.PublicKey, pack *Package, route []*rsa.PublicKey, ppsender *rsa.PrivateKey) *Package
Function wrap package in multiple route. Need use pseudo sender if route not null.
type HeadPackage ¶ added in v1.2.0
type Package ¶
type Package struct { Head HeadPackage `json:"head"` Body BodyPackage `json:"body"` }
func DeserializePackage ¶ added in v1.2.2
Deserialize with JSON format.
func NewPackage ¶ added in v1.2.3
Create package: Head.Title = title, Body.Data = data.
type SettingsType ¶
type SettingsType map[string]interface{}