Documentation ¶
Index ¶
- Constants
- func AccountScript(expiry uint32, traderKey, auctioneerKey, batchKey *btcec.PublicKey, ...) ([]byte, error)
- func AccountWitnessScript(expiry uint32, traderKey, auctioneerKey, batchKey *btcec.PublicKey, ...) ([]byte, error)
- func AuctioneerKeyTweak(traderKey, auctioneerKey, batchKey *btcec.PublicKey, secret [32]byte) []byte
- func DecrementKey(key *btcec.PublicKey) *btcec.PublicKey
- func IncrementKey(key *btcec.PublicKey) *btcec.PublicKey
- func IsExpirySpend(witness wire.TxWitness) bool
- func IsMultiSigSpend(witness wire.TxWitness) bool
- func LocateOutputScript(tx *wire.MsgTx, script []byte) (uint32, bool)
- func SpendExpiry(witnessScript, traderSig []byte) wire.TxWitness
- func SpendMultiSig(witnessScript, traderSig, auctioneerSig []byte) wire.TxWitness
- func TraderKeyTweak(batchKey *btcec.PublicKey, secret [32]byte, traderKey *btcec.PublicKey) []byte
Constants ¶
const ( // AccountKeyFamily is the key family used to derive keys which will be // used in the 2 of 2 multi-sig construction of a CLM account. // // TODO(wilmer): decide on actual value. AccountKeyFamily keychain.KeyFamily = 220 // AccountWitnessScriptSize: 79 bytes // - OP_DATA: 1 byte (trader_key length) // - <trader_key>: 33 bytes // - OP_CHECKSIGVERIFY: 1 byte // - OP_DATA: 1 byte (auctioneer_key length) // - <auctioneer_key>: 33 bytes // - OP_CHECKSIG: 1 byte // - OP_IFDUP: 1 byte // - OP_NOTIF: 1 byte // - OP_DATA: 1 byte (account_expiry length) // - <account_expiry>: 4 bytes // - OP_CHECKLOCKTIMEVERIFY: 1 byte // - OP_ENDIF: 1 byte AccountWitnessScriptSize = 1 + 33 + 1 + 1 + 33 + 1 + 1 + 1 + 1 + 4 + 1 + 1 // MultiSigWitnessSize: 227 bytes // - num_witness_elements: 1 byte // - trader_sig_varint_len: 1 byte // - <trader_sig>: 73 bytes // - auctioneer_sig_varint_len: 1 byte // - <auctioneer_sig>: 73 bytes // - witness_script_varint_len: 1 byte // - <witness_script>: 79 bytes MultiSigWitnessSize = 1 + 1 + 73 + 1 + 73 + 1 + AccountWitnessScriptSize // ExpiryWitnessSize: 154 bytes // - num_witness_elements: 1 byte // - trader_sig_varint_len: 1 byte (trader_sig length) // - <trader_sig>: 73 bytes // - witness_script_varint_len: 1 byte (nil length) // - <witness_script>: 79 bytes ExpiryWitnessSize = 1 + 1 + 73 + 1 + AccountWitnessScriptSize )
Variables ¶
This section is empty.
Functions ¶
func AccountScript ¶
func AccountScript(expiry uint32, traderKey, auctioneerKey, batchKey *btcec.PublicKey, secret [32]byte) ([]byte, error)
AccountScript returns the output script of an account on-chain.
<trader_key> OP_CHECKSIGVERIFY <auctioneer_key> OP_CHECKSIG OP_IFDUP OP_NOTIF
<account_expiry> OP_CHECKLOCKTIMEVERIFY
OP_ENDIF
func AccountWitnessScript ¶
func AccountWitnessScript(expiry uint32, traderKey, auctioneerKey, batchKey *btcec.PublicKey, secret [32]byte) ([]byte, error)
AccountWitnessScript returns the witness script of an account.
func AuctioneerKeyTweak ¶
func AuctioneerKeyTweak(traderKey, auctioneerKey, batchKey *btcec.PublicKey, secret [32]byte) []byte
AuctioneerKeyTweak computes the tweak based on the tweaked trader's key that should be applied to an account's auctioneer base key. The tweak is computed as the following:
traderKeyTweak = sha256(batchKey || secret || traderKey) tweakedTraderKey = (traderKey + traderKeyTweak) * G auctioneerKeyTweak = sha256(tweakedTraderKey || auctioneerKey)
func DecrementKey ¶
DecrementKey is the opposite of IncrementKey, it "subtracts one" from the current key to arrive at the key used before the IncrementKey operation.
func IncrementKey ¶
IncrementKey increments the given key by the backing curve's base point.
func IsExpirySpend ¶
IsExpirySpend determines whether the provided witness corresponds to the expiration script path of an account.
func IsMultiSigSpend ¶
IsMultiSigSpend determines whether the provided witness corresponds to the multi-sig script path of an account.
func LocateOutputScript ¶
LocateOutputScript determines whether a transaction includes an output with a specific script. If it does, the output index is returned.
func SpendExpiry ¶
SpendExpiry returns the witness required to spend an account through the expiration script path.
func SpendMultiSig ¶
SpendMultiSig returns the witness required to spend an account through the multi-sig script path.
func TraderKeyTweak ¶
TraderKeyTweak computes the tweak based on the current per-batch key and shared secret that should be applied to an account's base trader key. The tweak is computed as the following:
tweak = sha256(batchKey || secret || traderKey)
Types ¶
This section is empty.