3.2 KiB
Standard_Operations
Standard operations required for FLO Crypto, Blockchain API, Supernode WS, IndexedDB
This template contains standard operations that can be used for the following:
- FLO Globals
- FLO Crypto Operations
- FLO Blockchain API Operations
- FLO SuperNode Websocket Operations
- compact IndexedDB Operations
FLO Globals
floGlobals object contains the global variables and constants required for the operations. Make sure to add this object before any other scripts.
floGlobals contains the following properties :
-
blockchain: Indicates the blockchain ("FLO"or"FLO_TEST"). -
apiURL: Indicates the URL for blockchain API calls. -
adminID: Indicates the master admin FLO ID for the project. -
sendAmt: Indicates the default flo amount to be sent while sending transactions into the blockchain -
fee: Indicates the default fee amount to be deduced while sending transactions into the blockchain -
supernodes: Holder for the supernode list. Can be updated in runtime while retriving data from blockchain using API. Stored in the Object format,{ <supernodeFLOID> : { uri : <supernodeURI> ...(otherProperties) } ...(Other Supernodes) }
FLO Crypto Operations
floCrypto operations can be used to perform blockchain-cryptography methods. floCrypto operations are synchronized and return a value. Contains the following Operations.
Generate New FLO ID pair
floCrypto.generateNewID()
generateNewID generates a new flo ID and returns private-key, public-key and floID
Calculate Public Key Hex
getPubKeyHex returns public-key from given private-key
floCrypto.getPubKeyHex(privateKey)
- privateKey - private key in WIF format (Hex)
Calculate FLO ID
floCrypto.getFloIDfromPubkeyHex(publicKey)
getFloIDfromPubkeyHex returns flo-ID from public-key
- publicKey - public key hex value
Verify Private Key
floCrypto.verifyPrivKey(privateKey, pubKey_floID, *isfloID)
verifyPrivKey verify the private-key for the given public-key or flo-ID
- privateKey - private key in WIF format (Hex)
- pubKey_floID - public Key or flo ID
- isfloID - boolean value (true - compare as flo ID, false - compare as public key) (optional, default is true)
Validate FLO ID
floCrypto.validateAddr(floID)
validateAddr check if the given Address is valid or not
- floID - flo ID to validate
Data Encryption
floCrypto.encryptData(data, publicKey)
encryptData encrypts the given data using public-key
- data - data to encrypt
- publicKey - public key of the recipient
Data Decryption
floCrypto.decryptData(data, privateKey)
decryptData decrypts the given data using private-key
- data - encrypted data to decrypt (Object that was returned from encryptData)
- privateKey - private key of the recipient
Sign Data
floCrypto.signData(data, privateKey)
signData signs the data using the private key
- data - data to sign
- privateKey - private key of the signer
Verify Signature
floCrypto.decryptData(data, signature, publicKey)
decryptData verifies signatue of the data using public-key
- data - data of the given signature
- signature - signature of the data
- publicKey - public key of the signer