Commit 2e8c13b1 authored by David Vorick's avatar David Vorick

change identifier strings, update documentation

parent c3a9d230
......@@ -182,12 +182,19 @@ Siacoin Inputs
--------------
Each input spends an output. The output being spent must already exist in the
state. An output has a value, and a spend hash (or address), which is the hash
of the 'spend conditions' object of the output. The spend conditions contain a
state. An output has a value, and a spend hash (or address), which relates to
the 'spend conditions' object of the output. The spend conditions contain a
timelock, a number of required signatures, and a set of public keys that can be
used during signing. The input is invalid if hash of the spend conditions do
not match the spend hash of the output being spent.
The spend hash is derived by getting the merkle root of a tree whose leaves are
the hashes of the timelock, the public keys (one leaf per key), and the number
of signatures. This ordering is chosen specifically because the timelock and
the number of signatures are low entropy. By using random data as the first and
last public key, you can make it safe to reveal any of the public keys without
revealing the low entropy items.
The timelock is a block height, and for the input to be valid, the current
height of the blockchain must be at least the height stated in the timelock.
......@@ -213,9 +220,10 @@ Outputs contain a value and a spend hash (also called a coin address). The
spend hash is a hash of the spend conditions that must be met to spend the
output.
The id of a contract is determined by marshalling all of the transaction fields
except for the signatures and then appending the byte array "scoinout" and the
index of the output within the transaction, and then taking the hash.
The id of a contract is determined by marhsalling an identifier with the string
"siacoin output" and appending that to the marshalling of the transaction
(excluding the signatures). This is easiest understood by looking at the
function 'OutputID' in consensus/types.go
File Contracts
--------------
......@@ -238,9 +246,10 @@ All contracts must have a non-zero payout, 'Start' must be before 'End', and
'Start' must be greater than the current height of the state. A storage proof
is acceptible if it is submitted in the block of height 'End'.
The id of a contract is determined by marshalling all of the transaction fields
except for the signatures and then appending the byte array "filecout" and the
index of the contract within the transaction, and then taking the hash.
The id of a contract is determined by marhsalling an identifier with the string
"file contract" and appending that to the marshalling of the transaction
(excluding the signatures). This is easiest understood by looking at the
function 'FileContractID' in consensus/types.go
Storage Proofs
--------------
......@@ -317,9 +326,10 @@ Sia outputs contain:
the moment the siafund output got created. This is used when the output is
spent to determine how many siacoins go to the new output.
The siafund output id is determied by mashalling all of the transaction fields
except for the signatures and then appending the byte array "sfundout" and the
index of the output within the transaction.
The id of a contract is determined by marhsalling an identifier with the string
"siafund output" and appending that to the marshalling of the transaction
(excluding the signatures). This is easiest understood by looking at the
function 'SiafundOutputID' in consensus/types.go
The id of the siacoin output that gets created when the siafund output is spent
(the claim id) is derived by hashing the id of the siafund output.
......
......@@ -8,7 +8,7 @@ package consensus
// TODO: Enforce siafund rules in consensus.
// TODO: Switch signature library to libsecpk2561
// TODO: Switch to typed public keys, with typed verification.
// TODO: Complete non-adversarial test coverage, partial adversarial test
// coverage.
......@@ -25,6 +25,7 @@ type (
Currency uint64
Siafund uint64
Identifier [16]byte
BlockID hash.Hash
OutputID hash.Hash
ContractID hash.Hash
......@@ -210,6 +211,7 @@ func (b Block) MinerPayoutID(i int) OutputID {
// contract" and the index of the contract.
func (t Transaction) FileContractID(i int) ContractID {
return ContractID(hash.HashBytes(encoding.MarshalAll(
Identifier{'f', 'i', 'l', 'e', ' ', 'c', 'o', 'n', 't', 'r', 'a', 'c', 't'},
t.Inputs,
t.MinerFees,
t.Outputs,
......@@ -218,7 +220,6 @@ func (t Transaction) FileContractID(i int) ContractID {
t.SiafundInputs,
t.SiafundOutputs,
t.ArbitraryData,
[8]byte{'f', 'i', 'l', 'e', 'c', 'o', 'u', 't'},
i,
)))
}
......@@ -228,6 +229,7 @@ func (t Transaction) FileContractID(i int) ContractID {
// and then appending the string "siacoin output" and the index of the output.
func (t Transaction) OutputID(i int) OutputID {
return OutputID(hash.HashBytes(encoding.MarshalAll(
Identifier{'s', 'i', 'a', 'c', 'o', 'i', 'n', ' ', 'o', 'u', 't', 'p', 'u', 't'},
t.Inputs,
t.MinerFees,
t.Outputs,
......@@ -236,7 +238,6 @@ func (t Transaction) OutputID(i int) OutputID {
t.SiafundInputs,
t.SiafundOutputs,
t.ArbitraryData,
[8]byte{'s', 'c', 'o', 'i', 'n', 'o', 'u', 't'},
i,
)))
}
......@@ -255,6 +256,7 @@ func (fcID ContractID) StorageProofOutputID(proofValid bool) (outputID OutputID)
// index `i` in the transaction.
func (t Transaction) SiafundOutputID(i int) OutputID {
return OutputID(hash.HashBytes(encoding.MarshalAll(
Identifier{'s', 'i', 'a', 'f', 'u', 'n', 'd', ' ', 'o', 'u', 't', 'p', 'u', 't'},
t.Inputs,
t.MinerFees,
t.Outputs,
......@@ -263,7 +265,6 @@ func (t Transaction) SiafundOutputID(i int) OutputID {
t.SiafundInputs,
t.SiafundOutputs,
t.ArbitraryData,
[8]byte{'s', 'f', 'u', 'n', 'd', 'o', 'u', 't'},
i,
)))
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment