Skip to content

Instantly share code, notes, and snippets.

@rtsisyk
Created October 12, 2018 11:52
Show Gist options
  • Save rtsisyk/26362b0512441e4779efb3387889b069 to your computer and use it in GitHub Desktop.
Save rtsisyk/26362b0512441e4779efb3387889b069 to your computer and use it in GitHub Desktop.
/// Transaction output.
/// (ID, P_{M, δ}, Bp, E_M(x, γ, δ))
#[derive(Debug)]
pub struct Output {
/// Unique identifier of the output.
/// Formed by hashing the rest of this structure.
/// H_r(P_{M, δ},B_p, E_M(x, γ, δ)).
id: Hash,
/// Clocked public key of recipient.
/// P_M + δG
recipient: PublicKey,
/// Bulletproof on range on amount x.
/// Contains Pedersen commitment.
// TODO: define data type
proof: BulletProof,
/// Encrypted payload.
///
/// E_M(x, γ, δ)
/// Represents an encrypted packet contain the information about x, γ, δ
/// that only receiver can red
// TODO: define data type
payload: Payload,
}
#[derive(Debug)]
pub struct Input {
/// Identifier of an unspent transaction output.
source_id: Hash,
}
/// Block Header.
#[derive(Debug)]
pub struct BlockHeader {
/// Version number.
pub version: u64,
/// A monotonically increasing value that represents the heights of the blockchain,
/// starting from genesis block (=0).
pub epoch: u64,
/// Hash of the block previous to this in the chain.
pub previous: Hash,
/// Leader public key
pub leader: PublicKey,
/// The sum of all gamma adjustments found in the block transactions (∑ γ_adj).
/// Includes the γ_adj from the leader's fee distribution transaction.
// TODO: which kind of data structure should be used for it?
pub adjustment: PublicKey,
/// Timestamp at which the block was built.
pub timestamp: DateTime<Utc>,
/// Merklish root of all range proofs for inputs.
pub inputs_range_hash: Hash,
/// Merklish root of all range proofs for output.
pub outputs_range_hash: Hash,
/// Hash of the current block (except Merkle trees):
/// H(BNO | HPREV | SGA | RH_TXINS | RH_TXOUT) (HCURR)
pub hash: Hash,
/// CoSi multisignature on HCURR
// TODO: which kind of data structure should be used for it?
/// Fee originally included in the transaction this proof is for.
pub fee: u64,
// TODO: what is about fee?
}
/// Block.
pub struct Block {
/// Block Header.
pub header: BlockHeader,
/// The list of transaction inputs.
pub inputs: Vec<Input>,
/// The list of transaction outputs.
pub outputs: Vec<Output>,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment