Documentation
¶
Index ¶
- Constants
- func CommitAmount(amount, mask ristretto.Scalar) ristretto.Point
- func DecryptAmount(encAmount ristretto.Scalar, R ristretto.Point, index uint32, ...) ristretto.Scalar
- func DecryptMask(encMask ristretto.Scalar, R ristretto.Point, index uint32, ...) ristretto.Scalar
- func EncryptAmount(amount, r ristretto.Scalar, index uint32, pubViewKey key.PublicView) ristretto.Scalar
- func EncryptMask(mask, r ristretto.Scalar, index uint32, pubViewKey key.PublicView) ristretto.Scalar
- func ShouldEncryptValues(tx Transaction) bool
- type Bid
- type Coinbase
- func (c *Coinbase) AddReward(pubKey key.PublicKey, amount ristretto.Scalar) error
- func (c *Coinbase) CalculateHash() ([]byte, error)
- func (c *Coinbase) Equals(t Transaction) bool
- func (c *Coinbase) LockTime() uint64
- func (c *Coinbase) SetTxPubKey(r ristretto.Scalar)
- func (c *Coinbase) StandardTx() *Standard
- func (c *Coinbase) Type() TxType
- type FetchDecoys
- type Input
- type Inputs
- type Output
- type Outputs
- type Stake
- type Standard
- func (s *Standard) AddDecoys(numMixins int, f FetchDecoys) error
- func (s *Standard) AddInput(i *Input) error
- func (s *Standard) AddOutput(pubAddr key.PublicAddress, amount ristretto.Scalar) error
- func (s *Standard) CalculateHash() ([]byte, error)
- func (s *Standard) Equals(t Transaction) bool
- func (s *Standard) LockTime() uint64
- func (s *Standard) Prove() error
- func (s *Standard) ProveRangeProof() error
- func (s *Standard) StandardTx() *Standard
- func (s *Standard) Type() TxType
- type Timelock
- type Transaction
- type TxType
- type TypeInfo
Constants ¶
const GenesisExpirationHeight = 250001
GenesisExpirationHeight sets the heigth for expiration of the Genesis block
const MaxLockTime = 250000
MaxLockTime sets the maximum lock time to 250000 blocks
Variables ¶
This section is empty.
Functions ¶
func CommitAmount ¶
CommitAmount creates a commitment for the specifie amount
func DecryptAmount ¶
func DecryptAmount(encAmount ristretto.Scalar, R ristretto.Point, index uint32, privViewKey key.PrivateView) ristretto.Scalar
DecryptAmount decAmount = EncAmount - H(H(H(R*PrivViewKey || index)))
func DecryptMask ¶
func DecryptMask(encMask ristretto.Scalar, R ristretto.Point, index uint32, privViewKey key.PrivateView) ristretto.Scalar
DecryptMask decMask = Encmask - H(H(r*PubViewKey || index))
func EncryptAmount ¶
func EncryptAmount(amount, r ristretto.Scalar, index uint32, pubViewKey key.PublicView) ristretto.Scalar
EncryptAmount encAmount = amount + H(H(H(r*PubViewKey || index)))
func EncryptMask ¶
func EncryptMask(mask, r ristretto.Scalar, index uint32, pubViewKey key.PublicView) ristretto.Scalar
EncryptMask encMask = mask + H(H(r*PubViewKey || index))
func ShouldEncryptValues ¶
func ShouldEncryptValues(tx Transaction) bool
ShouldEncryptValues returns whether a transaction should be encrypted
Types ¶
type Bid ¶
Bid transaction
func (*Bid) CalculateHash ¶
CalculateHash calculates the hash
func (*Bid) StandardTx ¶
StandardTx returns the standard transaction form of this bid
type Coinbase ¶
type Coinbase struct {
//// Encoded fields
TxType
R ristretto.Point
Score []byte
Proof []byte
Rewards Outputs
TxID []byte
// contains filtered or unexported fields
}
Coinbase transaction
func NewCoinbase ¶
NewCoinbase creates a new coinbase
func (*Coinbase) CalculateHash ¶
CalculateHash calculates the hash of the coinbase tx
func (*Coinbase) Equals ¶
func (c *Coinbase) Equals(t Transaction) bool
Equals tests if a transaction is equal to this coinbase tx
func (*Coinbase) SetTxPubKey ¶
SetTxPubKey sets the public key of the transaction
func (*Coinbase) StandardTx ¶
StandardTx returns the Standard form of the transaction
type FetchDecoys ¶
FetchDecoys is a function that creates a decoy (ring signature) by camuflaging the actual public key of the signer among a collection of public keys
type Input ¶
type Input struct {
// One-time pubkey of the receiver
// Each input will contain a one-time pubkey
// Only the private key assosciated with this
// public key can unlock the funds available at this utxo
PubKey key.StealthAddress
// PseudoCommitment refers to a commitment which commits to the same amount
// as our `Commitment` value, however the mask value is changed. This is to be used in proving
// that the sumInputs-SumOutputs = 0
PseudoCommitment ristretto.Point
// Proof is zk proof that proves that the signer knows the one-time pubkey assosciated with
// an input in the ring. The secondary key in the key-vector is used as an intermediate process
// for the balance proof. This will use a pseudo-commitment s.t. C = Comm(amount, r)
// However, in order for the proof to work we need to know all inputs and outputs in the tx.
// Proof will output a signature and a keyimage
Proof *mlsag.DualKey
Signature *mlsag.Signature
KeyImage ristretto.Point
// contains filtered or unexported fields
}
Input of a transaction
func NewInput ¶
NewInput creates a new transaction input / XXX: maybe we should take an dusk-tx-output and the privkey We can then derive the amount, mask from the encrypted amounts We can derive the mask from encryptedMask, as it is deterministic we can also derive the pubkey
type Inputs ¶
type Inputs []*Input
Inputs is a slice of pointers to a set of `input`'s
func (Inputs) HasDuplicates ¶
HasDuplicates checks whether any of the inputs contain duplciates This is done by checking their keyImages
type Output ¶
type Output struct {
// Commitment to the amount and the mask value
// This will be generated by the rangeproof
Commitment ristretto.Point
// PubKey refers to the destination key of the receiver
// One-time pubkey of the receiver
// Each input will contain a one-time pubkey
// Only the private key assosciated with this
// public key can unlock the funds available at this utxo
PubKey key.StealthAddress
// Index denotes the position that this output is in the
// transaction. This is different to the Offset which denotes the
// position that this output is in, from the start from the blockchain
Index uint32
EncryptedAmount ristretto.Scalar
EncryptedMask ristretto.Scalar
// contains filtered or unexported fields
}
Output of a transaction
type Outputs ¶
type Outputs []*Output
Outputs is a slice of pointers to a set of `input`'s
func (Outputs) HasDuplicates ¶
HasDuplicates checks whether an output contains a duplicate This is done by checking that there are no matching Destination keys
type Stake ¶
Stake encapsulates a Stake transaction
func (*Stake) CalculateHash ¶
CalculateHash calculates the hash of this transaction
func (*Stake) Equals ¶
func (s *Stake) Equals(t Transaction) bool
Equals test the transactions equality
func (*Stake) StandardTx ¶
StandardTx returns the Standard transaction
type Standard ¶
type Standard struct {
//// Encoded fields
// TxType represents the transaction type
TxType TxType
// R is the transaction Public Key
R ristretto.Point
// Version is the transaction version. It does not use semver.
// A new transaction version denotes a modification of the previous structure
Version uint8 // 1 byte
// Inputs represent a list of inputs to the transaction.
Inputs
// Outputs represent a list of outputs to the transaction
Outputs
Fee ristretto.Scalar
// RangeProof is the bulletproof rangeproof that proves that the hidden amount
// is between 0 and 2^64
RangeProof rangeproof.Proof
// TxID is the hash of the transaction fields.
TxID []byte
TotalSent ristretto.Scalar
// contains filtered or unexported fields
}
Standard is a generic transaction. It can also be seen as a stealth transaction. It is used to make basic payments on the dusk network.
func NewStandard ¶
NewStandard creates a new Standard transaction
func (*Standard) AddDecoys ¶
func (s *Standard) AddDecoys(numMixins int, f FetchDecoys) error
AddDecoys to a standard transaction
func (*Standard) CalculateHash ¶
CalculateHash calculates the SHA3 hash of this Standard transaction
func (*Standard) Equals ¶
func (s *Standard) Equals(t Transaction) bool
Equals returns true if two standard tx's are the same
func (*Standard) LockTime ¶
LockTime returns 0 since Standard is not a time locked transaction. See Timelock
func (*Standard) Prove ¶
Prove creates the rangeproof for output values and creates the mlsag balance and ownership proof Prove assumes that all inputs, outputs and decoys have been added to the transaction
func (*Standard) ProveRangeProof ¶
ProveRangeProof proves that the transaction amount is positive
type Timelock ¶
Timelock represents a standard transaction that has an additional time restriction What does the time-lock represent? For a `Standard TimeLock`; that the TX can only become valid after the time stated. This is not the case for others, please check each transaction for the significance of the timelock
func NewTimelock ¶
NewTimelock creates a Timelock
func (*Timelock) CalculateHash ¶
CalculateHash calculate the SHA3 hash of the timelock
func (*Timelock) Equals ¶
func (tl *Timelock) Equals(t Transaction) bool
Equals checks the equality of the transaction
func (*Timelock) StandardTx ¶
StandardTx returns the standard transaction encapsulated within the TimeLock
type Transaction ¶
type Transaction interface {
TypeInfo
merkletree.Payload
Equals(Transaction) bool
StandardTx() *Standard
LockTime() uint64
}
Transaction represents all transaction structures All transactions will embed the standard transaction. Returning Standard() allows the caller to fetch the inputs/outputs/fees without type casting the Transaction interface to a specific type
type TxType ¶
type TxType uint8
TxType defines a transaction type identifier.
const ( // CoinbaseType is the identifier for a block coinbase CoinbaseType TxType = 0x00 // BidType is the identifier for a blind bid BidType TxType = 0x01 // StakeType is the identifier for a stake StakeType TxType = 0x02 // StandardType is the identifier for a standard transaction StandardType TxType = 0x03 // TimelockType is the identifier for a standard time-locked transaction TimelockType TxType = 0x04 // ContractType is the identifier for a smart contract transaction ContractType TxType = 0x05 )