fireblocklib

package
v1.9.10 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	None = 0

	InvalidAuthentication = 10
	InvalidKey            = 11
	InvalidCard           = 12
	InvalidProof          = 13
	InvalidSignature      = 14
	InvalidPassphrase     = 15
	InvalidProject        = 16
	InvalidHash           = 17
	InvalidFile           = 18
	InvalidJSON           = 19
	InvalidEncoding       = 21
	NetworkError          = 30
	NetworkError404       = 31
	NoFile                = 32
	SignError             = 40
	APIError              = 50
	AlreadyExist          = 60

	UnknownError    = 90
	UnknownElement  = 91
	UnknownProvider = 92

	EthOpError      = 100
	EthNotEnoughGas = 101

	NotYetImplemented = 127
)

Errors

Variables

View Source
var ServerURL = "https://fireblock.io"

ServerURL is the url of the service

Functions

func B32ToECDSA

func B32ToECDSA(b32 string) string

B32ToECDSA convert B32 to ECDSA

func B32ToPGP

func B32ToPGP(b32 string) string

B32ToPGP convert bytes32 to pgp

func B32Type

func B32Type(b32 string) string

B32Type return type of key

func CheckAllCard

func CheckAllCard(card, cardID string) (string, string, string, error)

CheckAllCard verify sha3(card)==cardId then the proofs and return useruid, pubkey, ktype check the key in the blockchain

func CheckCard

func CheckCard(card, cardID string) (string, string, string, error)

CheckCard verify sha3(card)==cardId then the proofs and return useruid, keyuid, ktype Don't check the key in the blockchain

func CheckGithub

func CheckGithub(url, ghUID, useruid, fingerprint string) bool

CheckGithub Check github proof

func CheckHTTPS

func CheckHTTPS(url, dnsUID, useruid, fingerprint string) bool

CheckHTTPS check website with a https proof

func CheckLinkedin

func CheckLinkedin(url, lkUID, useruid, fingerprint string) bool

CheckLinkedin check a linkedin proof

func CheckTwitter

func CheckTwitter(url, twUID, useruid, fingerprint string) bool

CheckTwitter check twitter proof

func DelStore

func DelStore(name string)

DelStore delete a store

func ECDSAExport

func ECDSAExport(privkey string) (string, error)

ECDSAExport export a JSON key into a base64url key

func ECDSAFingerprint

func ECDSAFingerprint(key string) (string, error)

ECDSAFingerprint compute a fingerprint

func ECDSAImport

func ECDSAImport(b64u string) (string, error)

ECDSAImport import a base64 encoded url key

func ECDSASign

func ECDSASign(privkey, message string) (string, error)

ECDSASign sign with ECDSA algo

func ECDSAToB32

func ECDSAToB32(ecdsa string) string

ECDSAToB32 convert ecdsa to b32

func ECDSAVerify

func ECDSAVerify(pubkey, message, signature string) (bool, error)

ECDSAVerify verify a signed message

func HTTPCard

func HTTPCard(keyuid, token string) (string, error)

HTTPCard API

func HTTPKey

func HTTPKey(keyuid string) (string, error)

HTTPKey API request on fireblock.io for a key

func IsInBatch

func IsInBatch(data, hash string) bool

IsInBatch check if hash is in batch

func IsSha256

func IsSha256(value string) bool

IsSha256 return true if it's a sha256

func Keccak256

func Keccak256(text string) string

Keccak256 return keccak256 value of a string

func ListFilesInDirectory

func ListFilesInDirectory(root string) ([]string, error)

ListFilesInDirectory recursive

func LoadB64U

func LoadB64U(data string) (string, string, error)

LoadB64U load a base64url private key

func LoadFioContent

func LoadFioContent(content string) (ktype, keyuid, privkey, pubkey string, err error)

LoadFioContent load a fio content

func LoadFioFile

func LoadFioFile(filepath string) (string, string, string, string, error)

LoadFioFile load a fio file

func PGPExport

func PGPExport(key string) string

PGPExport pgp armored priv key into base64url string

func PGPFingerprint

func PGPFingerprint(key string) (string, error)

PGPFingerprint get fingerprint of pgp key

func PGPImport

func PGPImport(key string) (string, error)

PGPImport toto

func PGPSign

func PGPSign(message, privkey, passphrase string) (string, error)

PGPSign clearsign a message

func PGPToB32

func PGPToB32(pgp string) string

PGPToB32 convert PGP key to bytes32

func PGPVerify

func PGPVerify(signature, message, pubkey string) (bool, error)

PGPVerify a clearsign message

func PostWithToken

func PostWithToken(c *http.Client, url string, token string, body io.Reader) (resp *http.Response, err error)

PostWithToken post

func RawSha256

func RawSha256(text string) []byte

RawSha256 return sha256 without '0x' prefix

func Sha1

func Sha1(text string) string

Sha1 return sha1 value of a string

func Sha256

func Sha256(text string) string

Sha256 return sha256 value of a string

func Sha256B

func Sha256B(data []byte) [32]byte

Sha256B return sha256

func Sha256File

func Sha256File(filepath string) (string, error)

Sha256File compute the sha256 of a file

func VerifySignature

func VerifySignature(ktype, pubkey, message, signature string) (bool, error)

VerifySignature verify signature

Types

type BatchElem

type BatchElem struct {
	Hash     string `json:"h"`
	Filename string `json:"f,omitempty"`
	Type     string `json:"t,omitempty"`
	Size     int64  `json:"s"`
}

BatchElem batch element

type CardData

type CardData struct {
	ID   string `json:"id"`
	Card string `json:"card"`
}

CardData http request struct

type CardReq

type CardReq struct {
	Keyuid string `json:"keyuid"`
}

CardReq http request

type ECDSAFIO

type ECDSAFIO struct {
	Keys []json.RawMessage `json:"keys"`
}

ECDSAFIO ecdsa fio

type ECDSAJWK

type ECDSAJWK struct {
	Crv    string   `json:"crv"`
	Kty    string   `json:"kty"`
	X      string   `json:"x"`
	Y      string   `json:"y"`
	D      string   `json:"d,omitempty"`
	Keyops []string `json:"key_ops,omitempty"`
}

ECDSAJWK ecdsa jwk

type ErrorRes

type ErrorRes struct {
	ID     string `json:"id"`
	Detail string `json:"detail"`
}

ErrorRes is a common struct used in json errors

type FBKError

type FBKError struct {
	// contains filtered or unexported fields
}

FBKError struct

func NewFBKError

func NewFBKError(text string, code int) *FBKError

NewFBKError default Constructor

func (*FBKError) Error

func (e *FBKError) Error() string

func (*FBKError) Type

func (e *FBKError) Type() int

Type type

type GistData

type GistData struct {
	Owner  OwnerData       `json:"owner"`
	ForkOf json.RawMessage `json:"fork_of"`
}

GistData Gist information

type JSONRes

type JSONRes struct {
	Errors []ErrorRes      `json:"errors"`
	Data   json.RawMessage `json:"data"`
}

JSONRes is a common struct used in json response

type JWKKey

type JWKKey struct {
	D      string   `json:"d,omitempty"`
	Crv    string   `json:"crv"`
	Ext    bool     `json:"ext"`
	KeyOps []string `json:"key_ops"`
	Kty    string   `json:"kty"`
	X      string   `json:"x"`
	Y      string   `json:"y"`
}

JWKKey a key

type KeyFIO

type KeyFIO struct {
	Pubkey  string `json:"pubkey"`
	Privkey string `json:"privkey"`
	KeyUID  string `json:"keyuid"`
	KType   string `json:"ktype"`
}

KeyFIO key fio

type KeyResponseData

type KeyResponseData struct {
	ID  string        `json:"id"`
	Key []interface{} `json:"key"`
}

KeyResponseData is a common struct used in success response

type Metadata

type Metadata struct {
	Kind     string `json:"kind,omitempty"`
	Filename string `json:"filename,omitempty"`
	Type     string `json:"type,omitempty"`
	Size     int64  `json:"size"`
}

Metadata meta data

func MetadataFile

func MetadataFile(filepath string) (Metadata, error)

MetadataFile extract Metadata from file

type OwnerData

type OwnerData struct {
	Login string `json:"login"`
}

OwnerData login

type ProviderData

type ProviderData struct {
	UID      string `json:"uid"`
	Provider string `json:"provider"`
	Date     string `json:"date"`
	Proof    string `json:"proof"`
}

ProviderData provider struct

type ProviderInfo

type ProviderInfo struct {
	UID string
	// contains filtered or unexported fields
}

type ProviderState

type ProviderState struct {
	UID, Proof, Status string
}

type ProviderStates

type ProviderStates struct {
	Twitter, Github, Linkedin, Https ProviderState
}

func VerifyCard

func VerifyCard(card, pkeyUID, pktype string) (pstates *ProviderStates, err error)

status, provider states, error

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store object

func GetStore

func GetStore(name string) *Store

GetStore get store

func NewStore

func NewStore(name string) *Store

NewStore initialize states

func (*Store) GetBool

func (store *Store) GetBool(key string, def bool) bool

GetBool returns value or def if no value

func (*Store) GetString

func (store *Store) GetString(key, def string) string

GetString returns value or def if no value

func (*Store) SetBool

func (store *Store) SetBool(key string, value bool)

SetBool sets or overwrites a value

func (*Store) SetString

func (store *Store) SetString(key, value string)

SetString sets or overwrites a value

Jump to

Keyboard shortcuts

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