Skip to content

Commit

Permalink
wire-mix: rename methods, use uint32 for expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Dec 4, 2023
1 parent ee9528e commit 2860b9b
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 69 deletions.
14 changes: 7 additions & 7 deletions wire/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ func TestMessage(t *testing.T) {
{msgCFTypes, msgCFTypes, pver, MainNet, 26},
{msgGetInitState, msgGetInitState, pver, MainNet, 25},
{msgInitState, msgInitState, pver, MainNet, 28},
{msgMixPR, msgMixPR, pver, MainNet, 169},
{msgMixKE, msgMixKE, pver, MainNet, 1449},
{msgMixCT, msgMixCT, pver, MainNet, 166},
{msgMixSR, msgMixSR, pver, MainNet, 169},
{msgMixDC, msgMixDC, pver, MainNet, 189},
{msgMixCM, msgMixCM, pver, MainNet, 181},
{msgMixRS, msgMixRS, pver, MainNet, 213},
{msgMixPR, msgMixPR, pver, MainNet, 165},
{msgMixKE, msgMixKE, pver, MainNet, 1445},
{msgMixCT, msgMixCT, pver, MainNet, 162},
{msgMixSR, msgMixSR, pver, MainNet, 165},
{msgMixDC, msgMixDC, pver, MainNet, 185},
{msgMixCM, msgMixCM, pver, MainNet, 177},
{msgMixRS, msgMixRS, pver, MainNet, 209},
}

t.Logf("Running %d tests", len(tests))
Expand Down
16 changes: 8 additions & 8 deletions wire/msgmixciphertexts.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type MsgMixCiphertexts struct {
Signature [64]byte
Identity [33]byte
SessionID [32]byte
Expiry int64
Expiry uint32
Run uint32
Ciphertexts [][1047]byte
SeenKeyExchanges []chainhash.Hash
Expand Down Expand Up @@ -190,21 +190,21 @@ func (msg *MsgMixCiphertexts) Command() string {
// MaxPayloadLength returns the maximum length the payload can be for the
// receiver. This is part of the Message interface implementation.
func (msg *MsgMixCiphertexts) MaxPayloadLength(pver uint32) uint32 {
return 552592
return 552588
}

// GetIdentity returns the message sender's public key identity.
func (msg *MsgMixCiphertexts) GetIdentity() []byte {
// Pub returns the message sender's public key identity.
func (msg *MsgMixCiphertexts) Pub() []byte {
return msg.Identity[:]
}

// GetSignature returns the message signature.
func (msg *MsgMixCiphertexts) GetSignature() []byte {
// Sig returns the message signature.
func (msg *MsgMixCiphertexts) Sig() []byte {
return msg.Signature[:]
}

// Expires returns the block height at which the message expires.
func (msg *MsgMixCiphertexts) Expires() int64 {
func (msg *MsgMixCiphertexts) Expires() uint32 {
return msg.Expiry
}

Expand All @@ -226,7 +226,7 @@ func (msg *MsgMixCiphertexts) GetRun() uint32 {
// NewMsgMixCiphertexts returns a new mixcphrtxt message that conforms to the
// Message interface using the passed parameters and defaults for the
// remaining fields.
func NewMsgMixCiphertexts(identity [33]byte, sid [32]byte, expires int64, run uint32,
func NewMsgMixCiphertexts(identity [33]byte, sid [32]byte, expires uint32, run uint32,
ciphertexts [][1047]byte, seenKeyExchanges []chainhash.Hash) *MsgMixCiphertexts {

return &MsgMixCiphertexts{
Expand Down
2 changes: 1 addition & 1 deletion wire/msgmixciphertexts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestMixCTWire(t *testing.T) {
var sid [32]byte
copy(sid[:], repeat(0x82, 32))

const expiry = int64(0x0383838383838383)
const expiry = uint32(0x83838383)
const run = uint32(0x84848484)

cts := make([][1047]byte, 4)
Expand Down
16 changes: 8 additions & 8 deletions wire/msgmixconfirm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type MsgMixConfirm struct {
Signature [64]byte
Identity [33]byte
SessionID [32]byte
Expiry int64
Expiry uint32
Run uint32
Mix MsgTx
SeenDCNets []chainhash.Hash
Expand Down Expand Up @@ -183,21 +183,21 @@ func (msg *MsgMixConfirm) Command() string {
// MaxPayloadLength returns the maximum length the payload can be for the
// receiver. This is part of the Message interface implementation.
func (msg *MsgMixConfirm) MaxPayloadLength(pver uint32) uint32 {
return 16543 + MaxBlockPayloadV3
return 16539 + MaxBlockPayloadV3
}

// GetIdentity returns the message sender's public key identity.
func (msg *MsgMixConfirm) GetIdentity() []byte {
// Pub returns the message sender's public key identity.
func (msg *MsgMixConfirm) Pub() []byte {
return msg.Identity[:]
}

// GetSignature returns the message signature.
func (msg *MsgMixConfirm) GetSignature() []byte {
// Sig returns the message signature.
func (msg *MsgMixConfirm) Sig() []byte {
return msg.Signature[:]
}

// Expires returns the block height at which the message expires.
func (msg *MsgMixConfirm) Expires() int64 {
func (msg *MsgMixConfirm) Expires() uint32 {
return msg.Expiry
}

Expand All @@ -219,7 +219,7 @@ func (msg *MsgMixConfirm) GetRun() uint32 {
// NewMsgMixConfirm returns a new mixconfirm message that conforms to the
// Message interface using the passed parameters and defaults for the
// remaining fields.
func NewMsgMixConfirm(identity [33]byte, sid [32]byte, expiry int64, run uint32,
func NewMsgMixConfirm(identity [33]byte, sid [32]byte, expiry uint32, run uint32,
mix *MsgTx, seenDCNets []chainhash.Hash) *MsgMixConfirm {

if mix == nil {
Expand Down
2 changes: 1 addition & 1 deletion wire/msgmixconfirm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestMixCMWire(t *testing.T) {
var sid [32]byte
copy(sid[:], repeat(0x82, 32))

const expiry = int64(0x0383838383838383)
const expiry = uint32(0x83838383)
const run = uint32(0x84848484)

mix := NewMsgTx()
Expand Down
16 changes: 8 additions & 8 deletions wire/msgmixdcnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type MsgMixDCNet struct {
Signature [64]byte
Identity [33]byte
SessionID [32]byte
Expiry int64
Expiry uint32
Run uint32
DCNet []MixVect
SeenSlotReserves []chainhash.Hash
Expand Down Expand Up @@ -257,21 +257,21 @@ func (msg *MsgMixDCNet) Command() string {
// MaxPayloadLength returns the maximum length the payload can be for the
// receiver. This is part of the Message interface implementation.
func (msg *MsgMixDCNet) MaxPayloadLength(pver uint32) uint32 {
return 16800915
return 16800911
}

// GetIdentity returns the message sender's public key identity.
func (msg *MsgMixDCNet) GetIdentity() []byte {
// Pub returns the message sender's public key identity.
func (msg *MsgMixDCNet) Pub() []byte {
return msg.Identity[:]
}

// GetSignature returns the message signature.
func (msg *MsgMixDCNet) GetSignature() []byte {
// Sig returns the message signature.
func (msg *MsgMixDCNet) Sig() []byte {
return msg.Signature[:]
}

// Expires returns the block height at which the message expires.
func (msg *MsgMixDCNet) Expires() int64 {
func (msg *MsgMixDCNet) Expires() uint32 {
return msg.Expiry
}

Expand All @@ -293,7 +293,7 @@ func (msg *MsgMixDCNet) GetRun() uint32 {
// NewMsgMixDCNet returns a new mixdcnet message that conforms to the Message
// interface using the passed parameters and defaults for the remaining
// fields.
func NewMsgMixDCNet(identity [33]byte, sid [32]byte, expiry int64, run uint32,
func NewMsgMixDCNet(identity [33]byte, sid [32]byte, expiry uint32, run uint32,
dcnet []MixVect, seenSlotReserves []chainhash.Hash) *MsgMixDCNet {

return &MsgMixDCNet{
Expand Down
2 changes: 1 addition & 1 deletion wire/msgmixdcnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestMixDCWire(t *testing.T) {
var sid [32]byte
copy(sid[:], repeat(0x82, 32))

const expiry = int64(0x0383838383838383)
const expiry = uint32(0x83838383)
const run = uint32(0x84848484)

mcount := 4
Expand Down
16 changes: 8 additions & 8 deletions wire/msgmixkeyexchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type MsgMixKeyExchange struct {
Signature [64]byte
Identity [33]byte
SessionID [32]byte
Expiry int64
Expiry uint32
Run uint32
ECDH [33]byte // Secp256k1 public key
PQPK [1218]byte // Sntrup4591761 public key
Expand Down Expand Up @@ -180,21 +180,21 @@ func (msg *MsgMixKeyExchange) Command() string {
// MaxPayloadLength returns the maximum length the payload can be for the
// receiver. This is part of the Message interface implementation.
func (msg *MsgMixKeyExchange) MaxPayloadLength(pver uint32) uint32 {
return 17811
return 17807
}

// GetIdentity returns the message sender's public key identity.
func (msg *MsgMixKeyExchange) GetIdentity() []byte {
// Pub returns the message sender's public key identity.
func (msg *MsgMixKeyExchange) Pub() []byte {
return msg.Identity[:]
}

// GetSignature returns the message signature.
func (msg *MsgMixKeyExchange) GetSignature() []byte {
// Sig returns the message signature.
func (msg *MsgMixKeyExchange) Sig() []byte {
return msg.Signature[:]
}

// Expires returns the block height at which the message expires.
func (msg *MsgMixKeyExchange) Expires() int64 {
func (msg *MsgMixKeyExchange) Expires() uint32 {
return msg.Expiry
}

Expand All @@ -216,7 +216,7 @@ func (msg *MsgMixKeyExchange) GetRun() uint32 {
// NewMsgMixKeyExchange returns a new mixkeyxchg message that conforms to the
// Message interface using the passed parameters and defaults for the
// remaining fields.
func NewMsgMixKeyExchange(identity [33]byte, sid [32]byte, expires int64, run uint32,
func NewMsgMixKeyExchange(identity [33]byte, sid [32]byte, expires uint32, run uint32,
ecdh [33]byte, pqpk [1218]byte, commitment [32]byte, seenPRs []chainhash.Hash) *MsgMixKeyExchange {

return &MsgMixKeyExchange{
Expand Down
2 changes: 1 addition & 1 deletion wire/msgmixkeyexchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestMixKEWire(t *testing.T) {
var sid [32]byte
copy(sid[:], repeat(0x82, 32))

const expiry = int64(0x0383838383838383)
const expiry = uint32(0x83838383)
const run = uint32(0x84848484)

var ecdh [33]byte
Expand Down
14 changes: 7 additions & 7 deletions wire/msgmixpairreq.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type MixPairReqUTXO struct {
type MsgMixPairReq struct {
Signature [64]byte
Identity [33]byte
Expiry int64
Expiry uint32
MixAmount int64
ScriptClass string
TxVersion uint16
Expand Down Expand Up @@ -353,18 +353,18 @@ func (msg *MsgMixPairReq) MaxPayloadLength(pver uint32) uint32 {
return MaxBlockPayload
}

// GetIdentity returns the message sender's public key identity.
func (msg *MsgMixPairReq) GetIdentity() []byte {
// Pub returns the message sender's public key identity.
func (msg *MsgMixPairReq) Pub() []byte {
return msg.Identity[:]
}

// GetSignature returns the message signature.
func (msg *MsgMixPairReq) GetSignature() []byte {
// Sig returns the message signature.
func (msg *MsgMixPairReq) Sig() []byte {
return msg.Signature[:]
}

// Expires returns the block height at which the message expires.
func (msg *MsgMixPairReq) Expires() int64 {
func (msg *MsgMixPairReq) Expires() uint32 {
return msg.Expiry
}

Expand All @@ -386,7 +386,7 @@ func (msg *MsgMixPairReq) GetRun() uint32 {
// NewMsgMixPairReq returns a new mixpairreq message that conforms to the
// Message interface using the passed parameters and defaults for the
// remaining fields.
func NewMsgMixPairReq(identity [33]byte, expiry int64, mixAmount int64,
func NewMsgMixPairReq(identity [33]byte, expiry uint32, mixAmount int64,
scriptClass string, txVersion uint16, lockTime, messageCount uint32,
inputValue int64, utxos []MixPairReqUTXO, change *TxOut) (*MsgMixPairReq, error) {

Expand Down
2 changes: 1 addition & 1 deletion wire/msgmixpairreq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestMixPairReqWire(t *testing.T) {
var id [33]byte
copy(id[:], repeat(0x81, 33))

const expiry = int64(0x0282828282828282)
const expiry = uint32(0x82828282)
const mixAmount = int64(0x0383838383838383)
const sc = "P2PKH-secp256k1-v0"
const txVersion = uint16(0x8484)
Expand Down
16 changes: 8 additions & 8 deletions wire/msgmixsecrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type MsgMixSecrets struct {
Signature [64]byte
Identity [33]byte
SessionID [32]byte
Expiry int64
Expiry uint32
Run uint32
Seed [32]byte
SlotReserveMsgs [][]byte
Expand Down Expand Up @@ -193,21 +193,21 @@ func (msg *MsgMixSecrets) Command() string {
// MaxPayloadLength returns the maximum length the payload can be for the
// receiver. This is part of the Message interface implementation.
func (msg *MsgMixSecrets) MaxPayloadLength(pver uint32) uint32 {
return 67773
return 67769
}

// GetIdentity returns the message sender's public key identity.
func (msg *MsgMixSecrets) GetIdentity() []byte {
// Pub returns the message sender's public key identity.
func (msg *MsgMixSecrets) Pub() []byte {
return msg.Identity[:]
}

// GetSignature returns the message signature.
func (msg *MsgMixSecrets) GetSignature() []byte {
// Sig returns the message signature.
func (msg *MsgMixSecrets) Sig() []byte {
return msg.Signature[:]
}

// Expires returns the block height at which the message expires.
func (msg *MsgMixSecrets) Expires() int64 {
func (msg *MsgMixSecrets) Expires() uint32 {
return msg.Expiry
}

Expand All @@ -233,7 +233,7 @@ func (msg *MsgMixSecrets) GetRun() uint32 {
// NewMsgMixSecrets returns a new mixsecrets message that conforms to the
// Message interface using the passed parameters and defaults for the
// remaining fields.
func NewMsgMixSecrets(identity [33]byte, sid [32]byte, expiry int64, run uint32,
func NewMsgMixSecrets(identity [33]byte, sid [32]byte, expiry uint32, run uint32,
seed [32]byte, slotReserveMsgs [][]byte, dcNetMsgs [][]byte) *MsgMixSecrets {

return &MsgMixSecrets{
Expand Down
2 changes: 1 addition & 1 deletion wire/msgmixsecrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestMixRSWire(t *testing.T) {
var sid [32]byte
copy(sid[:], repeat(0x82, 32))

const expiry = int64(0x0383838383838383)
const expiry = uint32(0x83838383)
const run = uint32(0x84848484)

var seed [32]byte
Expand Down
16 changes: 8 additions & 8 deletions wire/msgmixslotreserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type MsgMixSlotReserve struct {
Signature [64]byte
Identity [33]byte
SessionID [32]byte
Expiry int64
Expiry uint32
Run uint32
DCMix [][][]byte // mcount-by-peers matrix of field numbers
SeenCiphertexts []chainhash.Hash
Expand Down Expand Up @@ -269,21 +269,21 @@ func (msg *MsgMixSlotReserve) Command() string {
// MaxPayloadLength returns the maximum length the payload can be for the
// receiver. This is part of the Message interface implementation.
func (msg *MsgMixSlotReserve) MaxPayloadLength(pver uint32) uint32 {
return 17318038
return 17318034
}

// GetIdentity returns the message sender's public key identity.
func (msg *MsgMixSlotReserve) GetIdentity() []byte {
// Pub returns the message sender's public key identity.
func (msg *MsgMixSlotReserve) Pub() []byte {
return msg.Identity[:]
}

// GetSignature returns the message signature.
func (msg *MsgMixSlotReserve) GetSignature() []byte {
// Sig returns the message signature.
func (msg *MsgMixSlotReserve) Sig() []byte {
return msg.Signature[:]
}

// Expires returns the block height at which the message expires.
func (msg *MsgMixSlotReserve) Expires() int64 {
func (msg *MsgMixSlotReserve) Expires() uint32 {
return msg.Expiry
}

Expand All @@ -305,7 +305,7 @@ func (msg *MsgMixSlotReserve) GetRun() uint32 {
// NewMsgMixSlotReserve returns a new mixslotres message that conforms to the
// Message interface using the passed parameters and defaults for the
// remaining fields.
func NewMsgMixSlotReserve(identity [33]byte, sid [32]byte, expires int64, run uint32,
func NewMsgMixSlotReserve(identity [33]byte, sid [32]byte, expires uint32, run uint32,
dcmix [][][]byte, seenCTs []chainhash.Hash) *MsgMixSlotReserve {

return &MsgMixSlotReserve{
Expand Down
Loading

0 comments on commit 2860b9b

Please sign in to comment.