Skip to content

Commit

Permalink
Introduce HeartbeatProof
Browse files Browse the repository at this point in the history
The HeartbeatProof type just makes the Heartbeat transactions a
little cleaner - they lack the legacy field that OneTimeSignature
can't remove.
  • Loading branch information
jannotti committed Nov 21, 2024
1 parent 75f9afb commit 674915e
Show file tree
Hide file tree
Showing 8 changed files with 342 additions and 7 deletions.
236 changes: 236 additions & 0 deletions crypto/msgp_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions crypto/msgp_gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions crypto/onetimesig.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,45 @@ type OneTimeSignature struct {
PK2Sig ed25519Signature `codec:"p2s"`
}

// A HeartbeatProof is functionally equivalent to a OneTimeSignature, but it has
// been cleaned up for use as a transaction field in heartbeat transactions.
type HeartbeatProof struct {
_struct struct{} `codec:",omitempty,omitemptyarray"`

// Sig is a signature of msg under the key PK.
Sig ed25519Signature `codec:"s"`
PK ed25519PublicKey `codec:"p"`

// PK2 is used to verify a two-level ephemeral signature.
PK2 ed25519PublicKey `codec:"p2"`
// PK1Sig is a signature of OneTimeSignatureSubkeyOffsetID(PK, Batch, Offset) under the key PK2.
PK1Sig ed25519Signature `codec:"p1s"`
// PK2Sig is a signature of OneTimeSignatureSubkeyBatchID(PK2, Batch) under the master key (OneTimeSignatureVerifier).
PK2Sig ed25519Signature `codec:"p2s"`
}

// ToOneTimeSignature converts a HeartbeatProof to a OneTimeSignature.
func (hbp HeartbeatProof) ToOneTimeSignature() OneTimeSignature {
return OneTimeSignature{
Sig: hbp.Sig,
PK: hbp.PK,
PK2: hbp.PK2,
PK1Sig: hbp.PK1Sig,
PK2Sig: hbp.PK2Sig,
}
}

// ToHeartbeatProof converts a OneTimeSignature to a HeartbeatProof.
func (ots OneTimeSignature) ToHeartbeatProof() HeartbeatProof {
return HeartbeatProof{
Sig: ots.Sig,
PK: ots.PK,
PK2: ots.PK2,
PK1Sig: ots.PK1Sig,
PK2Sig: ots.PK2Sig,
}
}

// A OneTimeSignatureSubkeyBatchID identifies an ephemeralSubkey of a batch
// for the purposes of signing it with the top-level master key.
type OneTimeSignatureSubkeyBatchID struct {
Expand Down
2 changes: 1 addition & 1 deletion data/transactions/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type HeartbeatTxnFields struct {
HbAddress basics.Address `codec:"hbad"`

// HbProof is a signature using HeartbeatAddress's partkey, thereby showing it is online.
HbProof crypto.OneTimeSignature `codec:"hbprf"`
HbProof crypto.HeartbeatProof `codec:"hbprf"`

// HbSeed must be the block seed for the block before this transaction's
// firstValid. It is supplied in the transaction so that Proof can be
Expand Down
4 changes: 2 additions & 2 deletions data/transactions/msgp_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion data/txntest/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type Txn struct {
StateProofMsg stateproofmsg.Message

HbAddress basics.Address
HbProof crypto.OneTimeSignature
HbProof crypto.HeartbeatProof
HbSeed committee.Seed
}

Expand Down
Loading

0 comments on commit 674915e

Please sign in to comment.