wallet

package
Version: v0.0.0-...-214c9eb Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: MIT Imports: 25 Imported by: 3

Documentation

Overview

Package bls implements BLS aggregate signatures.

This package implements the scheme described in "Aggregate and Verifiably Encrypted Signatures from Bilinear Maps" by Boneh, Gentry, Lynn, and Shacham (Eurocrypt 2003): https://www.iacr.org/archive/eurocrypt2003/26560416/26560416.pdf.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteToPoint

func ByteToPoint(b []byte) (kyber.Point, error)

func ByteToScalar

func ByteToScalar(b []byte) (kyber.Scalar, error)

func BytesToAddress

func BytesToAddress(data []byte, shard uint32) string

BytesToAddress converts the bytes of the PublicKey into a wallet address

func CreateSchnorrKeys

func CreateSchnorrKeys() (kyber.Scalar, kyber.Point)

return x, p

func CreateSignature

func CreateSignature(Rs []kyber.Point, Ss []kyber.Scalar) ([]byte, []byte, error)

func EncryptWallet

func EncryptWallet(password []byte, wal *Wallet) ([]byte, error)

EncryptWallet returns a wallet encrypted with the key passed as argument

func GenerateParameter

func GenerateParameter() (kyber.Scalar, []byte, error)

generate k and calculate r

func GenerateVanityWallet

func GenerateVanityWallet(vanity string, userWallet string, shard uint8, vainityFound *bool, wg *sync.WaitGroup) error

GenerateVanityWallet create a wallet that start with "Dexm" + your_word

func GetShardFromAddress

func GetShardFromAddress(w string) (uint32, error)

func Hash

func Hash(s string) kyber.Scalar

func IsWalletValid

func IsWalletValid(wallet string) bool

IsWalletValid checks if a wallet is valid by checking the checksum

func JSWallet

func JSWallet(shard uint8) *js.Object

JSWallet returns a gopherjs wrapper to the wallet

func MakeSign

func MakeSign(x kyber.Scalar, k kyber.Scalar, message string, otherR []kyber.Point, otherP []kyber.Point) []byte

func PublicKey

func PublicKey(m string, rSignature kyber.Point, sSignature kyber.Scalar) kyber.Point

func Sign

func Sign(m string, x kyber.Scalar, otherR []kyber.Point, otherP []kyber.Point, k kyber.Scalar) kyber.Scalar

m: Message x: Private key

func SignatureValid

func SignatureValid(x509pub, r, s, data []byte) (bool, error)

SignatureValid checks if a signature is valid for a x509 encoded ecdsa pubkey

func Verify

func Verify(m string, rSignature kyber.Point, sSignature kyber.Scalar, P kyber.Point, R kyber.Point) bool

func VerifySignature

func VerifySignature(message string, rSignature kyber.Point, sSignature kyber.Scalar, allP []kyber.Point, allR []kyber.Point) bool

Types

type Wallet

type Wallet struct {
	PrivKey        *ecdsa.PrivateKey
	Shard          uint8
	Balance        int
	PrivKeySchnorr []byte
	PubKeySchnorr  []byte
}

Wallet is an internal representation of a private key

func GenerateWallet

func GenerateWallet(shard uint8) (*Wallet, error)

GenerateWallet generates a new random wallet with a 0 balance

func ImportWallet

func ImportWallet(filePath string) (*Wallet, error)

ImportWallet opens the file passed to it and tries to parse it as a private key and convert it into a Wallet struct

func (*Wallet) ExportWallet

func (w *Wallet) ExportWallet(filePath string) error

ExportWallet saves the internal Wallet structure to a file

func (*Wallet) GetEncodedWallet

func (w *Wallet) GetEncodedWallet() ([]byte, error)

GetEncodedWallet returns a JSON encoded wallet

func (*Wallet) GetPrivateKeySchnorr

func (w *Wallet) GetPrivateKeySchnorr() (kyber.Scalar, error)

GetPrivateKeySchnorr return the private schnorr key to the wallet

func (*Wallet) GetPubKey

func (w *Wallet) GetPubKey() ([]byte, error)

GetPubKey returns a x509 encoded public key for the wallet

func (*Wallet) GetPublicKeySchnorr

func (w *Wallet) GetPublicKeySchnorr() (kyber.Point, error)

GetPrivateKeySchnorr return the private schnorr key to the wallet

func (*Wallet) GetPublicKeySchnorrByte

func (w *Wallet) GetPublicKeySchnorrByte() []byte

GetPrivateKeySchnorr return the private schnorr key to the wallet

func (*Wallet) GetShardWallet

func (w *Wallet) GetShardWallet() uint8

GetShardWallet return the shard to the wallet

func (*Wallet) GetWallet

func (w *Wallet) GetWallet() (string, error)

GetWallet returns the address of a wallet

func (*Wallet) NewTransaction

func (w *Wallet) NewTransaction(recipient string, amount uint64, gas uint32, data []byte, shard uint32) ([]byte, error)

NewTransaction generates a signed transaction for the given arguments without broadcasting it to the newtwork

func (*Wallet) RawTransaction

func (w *Wallet) RawTransaction(recipient string, amount uint64, gas uint32, data []byte, shard uint32) (*protobufs.Transaction, error)

RawTransaction returns a struct with a transaction. Used in GopherJS to avoid protobuf which uses the unsupported unsafe

func (*Wallet) Sign

func (w *Wallet) Sign(data []byte) (r, s *big.Int, e error)

Sign signs the bytes passed to it with ECDSA

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL