account

package
v0.0.0-...-8887c1e Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitLocation

func CommitLocation(classicalPrivateKey kyber.Scalar, location []byte) (kyber.Scalar, kyber.Point, error)

CommitLocation function generates a cryptographic commitment to a location.

func DecodeLocationCommitment

func DecodeLocationCommitment(suite kyber.Group, commitment []byte) kyber.Point

func EncodeLocationCommitment

func EncodeLocationCommitment(suite kyber.Group, commitment kyber.Point) ([]byte, error)

func GenerateCryptoKeys

func GenerateCryptoKeys() (kyber.Group, kyber.Scalar, kyber.Point, error)

func GetDynamicPrecision

func GetDynamicPrecision() (float64, error)

GetDynamicPrecision provides a placeholder function for dynamic precision adjustment.

Types

type Account

type Account struct {
	Address string
	Balance float64
}

type AccountManager

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

AccountManager manages all accounts in the system

func NewAccountManager

func NewAccountManager() *AccountManager

NewAccountManager creates a new AccountManager

func (*AccountManager) CreateAccount

func (am *AccountManager) CreateAccount(address string, initialBalance float64) error

func (*AccountManager) GetBalance

func (am *AccountManager) GetBalance(address string) (float64, error)

func (*AccountManager) GetState

func (am *AccountManager) GetState() *state.Matrix

func (*AccountManager) PrintAccounts

func (am *AccountManager) PrintAccounts()

func (*AccountManager) Transfer

func (am *AccountManager) Transfer(from, to string, amount float64) error

type AddressInfo

type AddressInfo struct {
	PublicKey          string `json:"publicKey"`
	LocationCommitment string `json:"locationCommitment"`
	ZKPProof           string `json:"zkpProof"`
	NonceValue         string
	NonceHash          string
}

AddressInfo provides a serializable and usable representation of NetworkAddress.

func GenerateAddress

func GenerateAddress(lat, lon float64, bits int) (*AddressInfo, error)

GenerateAddress creates a new NetworkAddress and encapsulates it into AddressInfo.

func GenerateAddressesBatch

func GenerateAddressesBatch(coords [][2]float64, bits int) ([]*AddressInfo, error)

func GetOrGenerateAddress

func GetOrGenerateAddress(lat, lon float64, bits int) (*AddressInfo, error)

func (*AddressInfo) MarshalBinary

func (ai *AddressInfo) MarshalBinary() ([]byte, error)

func (*AddressInfo) MarshalJSON

func (ai *AddressInfo) MarshalJSON() ([]byte, error)

MarshalJSON customizes the JSON marshaling for AddressInfo.

func (*AddressInfo) UnmarshalBinary

func (ai *AddressInfo) UnmarshalBinary(data []byte) error

func (*AddressInfo) UnmarshalJSON

func (ai *AddressInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON customizes the JSON unmarshaling for AddressInfo.

type NetworkAddress

type NetworkAddress struct {
	AnonGeoLocation    SafeLatitudeLongitude
	LocationCommitment kyber.Point   `json:"locationCommitment"`
	ZKP                *libzk13.ZK13 `json:"-"`
	PrivateKey         kyber.Scalar  `json:"-"`
	PublicKey          kyber.Point   `json:"public_key"`
	P                  *big.Int
	Suite              kyber.Group
	Nonce              *state.Nonce
	// contains filtered or unexported fields
}

NetworkAddress includes cryptographic elements and an anonymized location.

func NewNetworkAddress

func NewNetworkAddress(lat, lon float64) (*NetworkAddress, error)

NewNetworkAddress initializes a NetworkAddress with given latitude and longitude.

func (*NetworkAddress) GenerateZKP

func (na *NetworkAddress) GenerateZKP(bits int) error

GenerateZKP generates a Zero-Knowledge Proof for the NetworkAddress.

type SafeLatitudeLongitude

type SafeLatitudeLongitude []int

SafeLatitudeLongitude represents an anonymized geographical location.

func ConvertToPrecisionGrid

func ConvertToPrecisionGrid(lat, lon, precision float64) (SafeLatitudeLongitude, error)

ConvertToPrecisionGrid function converts latitude and longitude into a precision grid.

func (SafeLatitudeLongitude) Bytes

func (s SafeLatitudeLongitude) Bytes() ([]byte, error)

Bytes serializes the SafeLatitudeLongitude into a byte slice.

func (*SafeLatitudeLongitude) Set

func (s *SafeLatitudeLongitude) Set(lat, lon, precision float64) error

Set updates the SafeLatitudeLongitude with new latitude and longitude values.

Jump to

Keyboard shortcuts

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