Documentation ¶
Index ¶
Constants ¶
const ( CommitmentLen = 32 ScriptHashLen = 32 AmountLen = 8 AmountPad = 24 AssetIDLen = 32 StateLen = 128 SaltLen = 32 )
const NanosPerILX = 1e9
const NullifierSize = hash.HashSize
Variables ¶
var ErrIDStrSize = fmt.Errorf("max ID string length is %v bytes", hash.HashSize*2)
var IlliumCoinID = NewID(bytes.Repeat([]byte{0x00}, 32))
Functions ¶
func RandomSalt ¶
RandomSalt generates a random number that is less than the lurk max field element.
Types ¶
type Amount ¶
type Amount uint64
Amount represents the base illium monetary unit (nanoillium or nanos). The total number of nanoillium issued is not expected to overflow an uint64 for 250 years from genesis.
type HexEncodable ¶
type HexEncodable []byte
func (HexEncodable) MarshalJSON ¶
func (h HexEncodable) MarshalJSON() ([]byte, error)
func (*HexEncodable) UnmarshalJSON ¶
func (h *HexEncodable) UnmarshalJSON(data []byte) error
type ID ¶
func NewIDFromData ¶
func NewIDFromString ¶
func (ID) Compare ¶
Compare returns 1 if hash > target, -1 if hash < target and 0 if hash == target.
func (*ID) MarshalJSON ¶
func (*ID) UnmarshalJSON ¶
type LockingParams ¶
type LockingParams [][]byte
func (*LockingParams) ToExpr ¶
func (lp *LockingParams) ToExpr() (string, error)
type LockingScript ¶
LockingScript represents a utxo script in which coins are locked.
func (*LockingScript) Deserialize ¶
func (ul *LockingScript) Deserialize(ser []byte) error
Deserialize turns a serialized byte slice back into an LockingScript
func (*LockingScript) Hash ¶
func (u *LockingScript) Hash() (ID, error)
Hash returns the Lurk Commitment hash of the locking script
func (*LockingScript) Serialize ¶
func (u *LockingScript) Serialize() []byte
Serialize returns the locking script serialized as a byte slice
type Nullifier ¶
func CalculateNullifier ¶
func CalculateNullifier(commitmentIndex uint64, salt [32]byte, scriptCommitment []byte, lockingParams ...[]byte) (Nullifier, error)
CalculateNullifier calculates and returns the nullifier for the given inputs.
func NewNullifier ¶
func NewNullifierFromString ¶
func (*Nullifier) MarshalJSON ¶
func (*Nullifier) UnmarshalJSON ¶
type Serializable ¶
type SpendNote ¶
SpendNote holds all the data that makes up an output commitment.
func (*SpendNote) Commitment ¶
Commitment builds a Lurk list expression out of the note data and returns the Lurk Commitment hash.
func (*SpendNote) Deserialize ¶
Deserialize turns a serialized byte slice back into a SpendNote
func (*SpendNote) Serialize ¶
Serialize returns the note serialized as a byte array. This format is suitable for encrypting and including in a transaction output.
func (*SpendNote) ToPublicCiphertext ¶
ToPublicCiphertext returns the note serialization format used by the PublicAddressScript.
type State ¶
type State [][]byte
State represents the state field out an output note.
There are two different representations of the state:
- Inside a lurk program it is a list expression of field elements
- Outside a lurk program we serialize it as a byte slice when encrypting the output note.
func (*State) Deserialize ¶
Deserialize will deserialize the slice into the State.
func (*State) Serialize ¶
Serialize serializes the state into a format that can be encrypted and used as the ciphertext in a Transaction.
Each element is prepended with the element's length. If pad is true and the serialized length is less than 128, zeros will be appended.
A length byte of zero is treated as a delimiter.
func (*State) ToExpr ¶
ToExpr converts the state to a lurk expression for use inside the lurk program.
Boolean: Elements with a len of 1 will be treated as a bool.
Uint64: Elements with len of 2-8 will be treated as a uint64.
Num: Elements with a len of 9-31 will be treated as a big endian lurk num.
Hash: If the element is len 32 it will be treated as a hex string prefixed with 0x. Lurk interprets this the same as Num.