diff --git a/batchverifier.go b/batchverifier.go index 661e382898..d265e6e4f4 100644 --- a/batchverifier.go +++ b/batchverifier.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/batchverifier_test.go b/batchverifier_test.go index 3922105aa5..6f3c5954fc 100644 --- a/batchverifier_test.go +++ b/batchverifier_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/crypto_test.go b/crypto_test.go index ee3a23d58f..82273c6fbe 100644 --- a/crypto_test.go +++ b/crypto_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/cryptoerror.go b/cryptoerror.go index b635f1ea88..6d1b468c5e 100644 --- a/cryptoerror.go +++ b/cryptoerror.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/curve25519.go b/curve25519.go index 0961ed6263..9a7e92ad2a 100644 --- a/curve25519.go +++ b/curve25519.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/curve25519_test.go b/curve25519_test.go index fac0bd6ab9..9bbbb11158 100644 --- a/curve25519_test.go +++ b/curve25519_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/digest.go b/digest.go index 967fa68abf..3e20fb236a 100644 --- a/digest.go +++ b/digest.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/encoding_test.go b/encoding_test.go index 0093b6c587..e400a19f7a 100644 --- a/encoding_test.go +++ b/encoding_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/falconWrapper.go b/falconWrapper.go index 4930210425..63158fcc85 100644 --- a/falconWrapper.go +++ b/falconWrapper.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/falconWrapper_test.go b/falconWrapper_test.go index cb251c7d89..4d8720e9f9 100644 --- a/falconWrapper_test.go +++ b/falconWrapper_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/hashes.go b/hashes.go index 3e232ed27d..b4392300bf 100644 --- a/hashes.go +++ b/hashes.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/hashes_test.go b/hashes_test.go index 2988f9ca1e..8999834423 100644 --- a/hashes_test.go +++ b/hashes_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/memcpy_chk_windows.c b/memcpy_chk_windows.c index 3cff6c7da2..c48d685f0d 100644 --- a/memcpy_chk_windows.c +++ b/memcpy_chk_windows.c @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklearray/array.go b/merklearray/array.go index 2e1eccb398..cfab888cde 100644 --- a/merklearray/array.go +++ b/merklearray/array.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklearray/layer.go b/merklearray/layer.go index bed28ccf51..728653ff7e 100644 --- a/merklearray/layer.go +++ b/merklearray/layer.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklearray/merkle.go b/merklearray/merkle.go index e540586b53..f77b6dcf7b 100644 --- a/merklearray/merkle.go +++ b/merklearray/merkle.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify @@ -21,10 +21,10 @@ import ( "errors" "fmt" "hash" + "slices" "sort" "github.com/algorand/go-algorand/crypto" - "golang.org/x/exp/slices" ) const ( diff --git a/merklearray/merkle_test.go b/merklearray/merkle_test.go index f62d6c282c..4c15f74df6 100644 --- a/merklearray/merkle_test.go +++ b/merklearray/merkle_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklearray/partial.go b/merklearray/partial.go index baebf4538d..e16dc7f12c 100644 --- a/merklearray/partial.go +++ b/merklearray/partial.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklearray/proof.go b/merklearray/proof.go index 8caa057bd3..bd88562d51 100644 --- a/merklearray/proof.go +++ b/merklearray/proof.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklearray/proof_test.go b/merklearray/proof_test.go index 7ef7ae044b..dd93d1a8f4 100644 --- a/merklearray/proof_test.go +++ b/merklearray/proof_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklearray/vectorCommitmentArray.go b/merklearray/vectorCommitmentArray.go index 6745aca603..82bdc8c67e 100644 --- a/merklearray/vectorCommitmentArray.go +++ b/merklearray/vectorCommitmentArray.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklearray/vectorCommitmentArray_test.go b/merklearray/vectorCommitmentArray_test.go index 24b1d32e9d..136609df78 100644 --- a/merklearray/vectorCommitmentArray_test.go +++ b/merklearray/vectorCommitmentArray_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklearray/worker.go b/merklearray/worker.go index 2c33440679..9d5179cbef 100644 --- a/merklearray/worker.go +++ b/merklearray/worker.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklesignature/committablePublicKeys.go b/merklesignature/committablePublicKeys.go index a636b3f02a..8cd8857057 100644 --- a/merklesignature/committablePublicKeys.go +++ b/merklesignature/committablePublicKeys.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklesignature/committablePublicKeys_test.go b/merklesignature/committablePublicKeys_test.go index 68463bf8e6..979528f236 100644 --- a/merklesignature/committablePublicKeys_test.go +++ b/merklesignature/committablePublicKeys_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklesignature/const.go b/merklesignature/const.go index 40817d4215..a7e529771f 100644 --- a/merklesignature/const.go +++ b/merklesignature/const.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklesignature/kats_test.go b/merklesignature/kats_test.go index 64b3e8c539..53aff9c2f0 100644 --- a/merklesignature/kats_test.go +++ b/merklesignature/kats_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklesignature/keysBuilder.go b/merklesignature/keysBuilder.go index 68ee76ae30..aaf8ce8a47 100644 --- a/merklesignature/keysBuilder.go +++ b/merklesignature/keysBuilder.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklesignature/keysBuilder_test.go b/merklesignature/keysBuilder_test.go index 01dd082fd4..c54c230bd9 100644 --- a/merklesignature/keysBuilder_test.go +++ b/merklesignature/keysBuilder_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklesignature/merkleSignatureScheme.go b/merklesignature/merkleSignatureScheme.go index 61724af4ec..a17a59c84b 100644 --- a/merklesignature/merkleSignatureScheme.go +++ b/merklesignature/merkleSignatureScheme.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklesignature/merkleSignatureScheme_test.go b/merklesignature/merkleSignatureScheme_test.go index 5abd9b77cb..9670e90ba1 100644 --- a/merklesignature/merkleSignatureScheme_test.go +++ b/merklesignature/merkleSignatureScheme_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklesignature/persistentMerkleSignatureScheme.go b/merklesignature/persistentMerkleSignatureScheme.go index 66f1dd055b..e3cd8c4b9d 100644 --- a/merklesignature/persistentMerkleSignatureScheme.go +++ b/merklesignature/persistentMerkleSignatureScheme.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklesignature/persistentMerkleSignatureScheme_test.go b/merklesignature/persistentMerkleSignatureScheme_test.go index adc22833f1..95179f3f04 100644 --- a/merklesignature/persistentMerkleSignatureScheme_test.go +++ b/merklesignature/persistentMerkleSignatureScheme_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklesignature/posdivs.go b/merklesignature/posdivs.go index 09b798c780..b1d8374b10 100644 --- a/merklesignature/posdivs.go +++ b/merklesignature/posdivs.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merklesignature/posdivs_test.go b/merklesignature/posdivs_test.go index 68f4b77aba..cb3fd5275a 100644 --- a/merklesignature/posdivs_test.go +++ b/merklesignature/posdivs_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merkletrie/bitset.go b/merkletrie/bitset.go index f764137a9a..7862576b78 100644 --- a/merkletrie/bitset.go +++ b/merkletrie/bitset.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merkletrie/bitset_test.go b/merkletrie/bitset_test.go index 315b27c952..2bf3bc392a 100644 --- a/merkletrie/bitset_test.go +++ b/merkletrie/bitset_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merkletrie/cache.go b/merkletrie/cache.go index d4d60b2c39..3f8a8d861d 100644 --- a/merkletrie/cache.go +++ b/merkletrie/cache.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify @@ -21,9 +21,8 @@ import ( "encoding/binary" "errors" "fmt" - - "golang.org/x/exp/maps" - "golang.org/x/exp/slices" + "maps" + "slices" ) // storedNodeIdentifier is the "equivalent" of a node-ptr, but oriented around persisting the @@ -448,8 +447,7 @@ func (mtc *merkleTrieCache) reallocatePendingPages(stats *CommitStats) (pagesToC } // create a sorted list of created pages - sortedCreatedPages := maps.Keys(createdPages) - slices.Sort(sortedCreatedPages) + sortedCreatedPages := slices.Sorted(maps.Keys(createdPages)) mtc.reallocatedPages = make(map[uint64]map[storedNodeIdentifier]*node) diff --git a/merkletrie/cache_test.go b/merkletrie/cache_test.go index ac08ea442f..9ff3649efb 100644 --- a/merkletrie/cache_test.go +++ b/merkletrie/cache_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merkletrie/committer.go b/merkletrie/committer.go index 66dd2c65c8..eb935a901e 100644 --- a/merkletrie/committer.go +++ b/merkletrie/committer.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ package merkletrie -import "golang.org/x/exp/slices" +import "slices" // Committer is the interface supporting serializing tries into persistent storage. type Committer interface { diff --git a/merkletrie/committer_test.go b/merkletrie/committer_test.go index 3dc6c39d2a..004c0b60f7 100644 --- a/merkletrie/committer_test.go +++ b/merkletrie/committer_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify @@ -18,10 +18,10 @@ package merkletrie import ( "encoding/binary" + "slices" "testing" "github.com/stretchr/testify/require" - "golang.org/x/exp/slices" "github.com/algorand/go-algorand/crypto" "github.com/algorand/go-algorand/test/partitiontest" diff --git a/merkletrie/node.go b/merkletrie/node.go index f63d2b12ab..c7b616d6e6 100644 --- a/merkletrie/node.go +++ b/merkletrie/node.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify @@ -19,11 +19,11 @@ package merkletrie import ( "bytes" "encoding/binary" + "slices" "sort" "unsafe" "github.com/algorand/go-algorand/crypto" - "golang.org/x/exp/slices" ) type childEntry struct { diff --git a/merkletrie/node_test.go b/merkletrie/node_test.go index c9fc2e46f4..1ffa67bb8b 100644 --- a/merkletrie/node_test.go +++ b/merkletrie/node_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merkletrie/trie.go b/merkletrie/trie.go index 6bb2a51851..4686647e75 100644 --- a/merkletrie/trie.go +++ b/merkletrie/trie.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/merkletrie/trie_test.go b/merkletrie/trie_test.go index 7b15d5534e..96eae19f66 100644 --- a/merkletrie/trie_test.go +++ b/merkletrie/trie_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/msgp_gen.go b/msgp_gen.go index ab5bdceb88..fc279029a0 100644 --- a/msgp_gen.go +++ b/msgp_gen.go @@ -111,6 +111,16 @@ import ( // |-----> MsgIsZero // |-----> HashTypeMaxSize() // +// HeartbeatProof +// |-----> (*) MarshalMsg +// |-----> (*) CanMarshalMsg +// |-----> (*) UnmarshalMsg +// |-----> (*) UnmarshalMsgWithState +// |-----> (*) CanUnmarshalMsg +// |-----> (*) Msgsize +// |-----> (*) MsgIsZero +// |-----> HeartbeatProofMaxSize() +// // MasterDerivationKey // |-----> (*) MarshalMsg // |-----> (*) CanMarshalMsg @@ -1169,6 +1179,232 @@ func HashTypeMaxSize() (s int) { return } +// MarshalMsg implements msgp.Marshaler +func (z *HeartbeatProof) MarshalMsg(b []byte) (o []byte) { + o = msgp.Require(b, z.Msgsize()) + // omitempty: check for empty values + zb0006Len := uint32(5) + var zb0006Mask uint8 /* 6 bits */ + if (*z).PK == (ed25519PublicKey{}) { + zb0006Len-- + zb0006Mask |= 0x2 + } + if (*z).PK1Sig == (ed25519Signature{}) { + zb0006Len-- + zb0006Mask |= 0x4 + } + if (*z).PK2 == (ed25519PublicKey{}) { + zb0006Len-- + zb0006Mask |= 0x8 + } + if (*z).PK2Sig == (ed25519Signature{}) { + zb0006Len-- + zb0006Mask |= 0x10 + } + if (*z).Sig == (ed25519Signature{}) { + zb0006Len-- + zb0006Mask |= 0x20 + } + // variable map header, size zb0006Len + o = append(o, 0x80|uint8(zb0006Len)) + if zb0006Len != 0 { + if (zb0006Mask & 0x2) == 0 { // if not empty + // string "p" + o = append(o, 0xa1, 0x70) + o = msgp.AppendBytes(o, ((*z).PK)[:]) + } + if (zb0006Mask & 0x4) == 0 { // if not empty + // string "p1s" + o = append(o, 0xa3, 0x70, 0x31, 0x73) + o = msgp.AppendBytes(o, ((*z).PK1Sig)[:]) + } + if (zb0006Mask & 0x8) == 0 { // if not empty + // string "p2" + o = append(o, 0xa2, 0x70, 0x32) + o = msgp.AppendBytes(o, ((*z).PK2)[:]) + } + if (zb0006Mask & 0x10) == 0 { // if not empty + // string "p2s" + o = append(o, 0xa3, 0x70, 0x32, 0x73) + o = msgp.AppendBytes(o, ((*z).PK2Sig)[:]) + } + if (zb0006Mask & 0x20) == 0 { // if not empty + // string "s" + o = append(o, 0xa1, 0x73) + o = msgp.AppendBytes(o, ((*z).Sig)[:]) + } + } + return +} + +func (_ *HeartbeatProof) CanMarshalMsg(z interface{}) bool { + _, ok := (z).(*HeartbeatProof) + return ok +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *HeartbeatProof) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error) { + if st.AllowableDepth == 0 { + err = msgp.ErrMaxDepthExceeded{} + return + } + st.AllowableDepth-- + var field []byte + _ = field + var zb0006 int + var zb0007 bool + zb0006, zb0007, bts, err = msgp.ReadMapHeaderBytes(bts) + if _, ok := err.(msgp.TypeError); ok { + zb0006, zb0007, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0006 > 0 { + zb0006-- + bts, err = msgp.ReadExactBytes(bts, ((*z).Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "Sig") + return + } + } + if zb0006 > 0 { + zb0006-- + bts, err = msgp.ReadExactBytes(bts, ((*z).PK)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PK") + return + } + } + if zb0006 > 0 { + zb0006-- + bts, err = msgp.ReadExactBytes(bts, ((*z).PK2)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PK2") + return + } + } + if zb0006 > 0 { + zb0006-- + bts, err = msgp.ReadExactBytes(bts, ((*z).PK1Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PK1Sig") + return + } + } + if zb0006 > 0 { + zb0006-- + bts, err = msgp.ReadExactBytes(bts, ((*z).PK2Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "struct-from-array", "PK2Sig") + return + } + } + if zb0006 > 0 { + err = msgp.ErrTooManyArrayFields(zb0006) + if err != nil { + err = msgp.WrapError(err, "struct-from-array") + return + } + } + } else { + if err != nil { + err = msgp.WrapError(err) + return + } + if zb0007 { + (*z) = HeartbeatProof{} + } + for zb0006 > 0 { + zb0006-- + field, bts, err = msgp.ReadMapKeyZC(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + switch string(field) { + case "s": + bts, err = msgp.ReadExactBytes(bts, ((*z).Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "Sig") + return + } + case "p": + bts, err = msgp.ReadExactBytes(bts, ((*z).PK)[:]) + if err != nil { + err = msgp.WrapError(err, "PK") + return + } + case "p2": + bts, err = msgp.ReadExactBytes(bts, ((*z).PK2)[:]) + if err != nil { + err = msgp.WrapError(err, "PK2") + return + } + case "p1s": + bts, err = msgp.ReadExactBytes(bts, ((*z).PK1Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "PK1Sig") + return + } + case "p2s": + bts, err = msgp.ReadExactBytes(bts, ((*z).PK2Sig)[:]) + if err != nil { + err = msgp.WrapError(err, "PK2Sig") + return + } + default: + err = msgp.ErrNoField(string(field)) + if err != nil { + err = msgp.WrapError(err) + return + } + } + } + } + o = bts + return +} + +func (z *HeartbeatProof) UnmarshalMsg(bts []byte) (o []byte, err error) { + return z.UnmarshalMsgWithState(bts, msgp.DefaultUnmarshalState) +} +func (_ *HeartbeatProof) CanUnmarshalMsg(z interface{}) bool { + _, ok := (z).(*HeartbeatProof) + return ok +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z *HeartbeatProof) Msgsize() (s int) { + s = 1 + 2 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + 2 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 3 + msgp.ArrayHeaderSize + (32 * (msgp.ByteSize)) + 4 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + 4 + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize)) + return +} + +// MsgIsZero returns whether this is a zero value +func (z *HeartbeatProof) MsgIsZero() bool { + return ((*z).Sig == (ed25519Signature{})) && ((*z).PK == (ed25519PublicKey{})) && ((*z).PK2 == (ed25519PublicKey{})) && ((*z).PK1Sig == (ed25519Signature{})) && ((*z).PK2Sig == (ed25519Signature{})) +} + +// MaxSize returns a maximum valid message size for this message type +func HeartbeatProofMaxSize() (s int) { + s = 1 + 2 + // Calculating size of array: z.Sig + s += msgp.ArrayHeaderSize + ((64) * (msgp.ByteSize)) + s += 2 + // Calculating size of array: z.PK + s += msgp.ArrayHeaderSize + ((32) * (msgp.ByteSize)) + s += 3 + // Calculating size of array: z.PK2 + s += msgp.ArrayHeaderSize + ((32) * (msgp.ByteSize)) + s += 4 + // Calculating size of array: z.PK1Sig + s += msgp.ArrayHeaderSize + ((64) * (msgp.ByteSize)) + s += 4 + // Calculating size of array: z.PK2Sig + s += msgp.ArrayHeaderSize + ((64) * (msgp.ByteSize)) + return +} + // MarshalMsg implements msgp.Marshaler func (z *MasterDerivationKey) MarshalMsg(b []byte) (o []byte) { o = msgp.Require(b, z.Msgsize()) diff --git a/msgp_gen_test.go b/msgp_gen_test.go index b3fb95150b..0105a58f1d 100644 --- a/msgp_gen_test.go +++ b/msgp_gen_test.go @@ -434,6 +434,66 @@ func BenchmarkUnmarshalHashFactory(b *testing.B) { } } +func TestMarshalUnmarshalHeartbeatProof(t *testing.T) { + partitiontest.PartitionTest(t) + v := HeartbeatProof{} + bts := v.MarshalMsg(nil) + left, err := v.UnmarshalMsg(bts) + if err != nil { + t.Fatal(err) + } + if len(left) > 0 { + t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) + } + + left, err = msgp.Skip(bts) + if err != nil { + t.Fatal(err) + } + if len(left) > 0 { + t.Errorf("%d bytes left over after Skip(): %q", len(left), left) + } +} + +func TestRandomizedEncodingHeartbeatProof(t *testing.T) { + protocol.RunEncodingTest(t, &HeartbeatProof{}) +} + +func BenchmarkMarshalMsgHeartbeatProof(b *testing.B) { + v := HeartbeatProof{} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + v.MarshalMsg(nil) + } +} + +func BenchmarkAppendMsgHeartbeatProof(b *testing.B) { + v := HeartbeatProof{} + bts := make([]byte, 0, v.Msgsize()) + bts = v.MarshalMsg(bts[0:0]) + b.SetBytes(int64(len(bts))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + bts = v.MarshalMsg(bts[0:0]) + } +} + +func BenchmarkUnmarshalHeartbeatProof(b *testing.B) { + v := HeartbeatProof{} + bts := v.MarshalMsg(nil) + b.ReportAllocs() + b.SetBytes(int64(len(bts))) + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, err := v.UnmarshalMsg(bts) + if err != nil { + b.Fatal(err) + } + } +} + func TestMarshalUnmarshalMasterDerivationKey(t *testing.T) { partitiontest.PartitionTest(t) v := MasterDerivationKey{} diff --git a/multisig.go b/multisig.go index f17833f1a0..f696b1d361 100644 --- a/multisig.go +++ b/multisig.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/multisig_test.go b/multisig_test.go index 614889c5a7..11e1dd791c 100644 --- a/multisig_test.go +++ b/multisig_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/onetimesig.go b/onetimesig.go index d05ccaa961..11930d633e 100644 --- a/onetimesig.go +++ b/onetimesig.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify @@ -57,6 +57,56 @@ 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, + } +} + +// BatchPrep enqueues the necessary checks into the batch. The caller must call +// batchVerifier.verify() to verify it. +func (hbp HeartbeatProof) BatchPrep(voteID OneTimeSignatureVerifier, id OneTimeSignatureIdentifier, msg Hashable, batchVerifier BatchVerifier) { + offsetID := OneTimeSignatureSubkeyOffsetID{SubKeyPK: hbp.PK, Batch: id.Batch, Offset: id.Offset} + batchID := OneTimeSignatureSubkeyBatchID{SubKeyPK: hbp.PK2, Batch: id.Batch} + batchVerifier.EnqueueSignature(PublicKey(voteID), batchID, Signature(hbp.PK2Sig)) + batchVerifier.EnqueueSignature(PublicKey(batchID.SubKeyPK), offsetID, Signature(hbp.PK1Sig)) + batchVerifier.EnqueueSignature(PublicKey(offsetID.SubKeyPK), msg, Signature(hbp.Sig)) + +} + // A OneTimeSignatureSubkeyBatchID identifies an ephemeralSubkey of a batch // for the purposes of signing it with the top-level master key. type OneTimeSignatureSubkeyBatchID struct { diff --git a/onetimesig_test.go b/onetimesig_test.go index ca7b641ead..d9eec123d3 100644 --- a/onetimesig_test.go +++ b/onetimesig_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/passphrase/errors.go b/passphrase/errors.go index 84918ce395..00d2d948fb 100644 --- a/passphrase/errors.go +++ b/passphrase/errors.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/passphrase/passphrase.go b/passphrase/passphrase.go index 6c1364229b..3bcee21107 100644 --- a/passphrase/passphrase.go +++ b/passphrase/passphrase.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/passphrase/passphrase_test.go b/passphrase/passphrase_test.go index 8824116505..66a9ae51fd 100644 --- a/passphrase/passphrase_test.go +++ b/passphrase/passphrase_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/passphrase/wordlist.go b/passphrase/wordlist.go index d2b786f411..66ebac5111 100644 --- a/passphrase/wordlist.go +++ b/passphrase/wordlist.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/rand.go b/rand.go index e74b62f9dc..7d9e391072 100644 --- a/rand.go +++ b/rand.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/rand_test.go b/rand_test.go index 49d431c8ee..b2e768b067 100644 --- a/rand_test.go +++ b/rand_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/stateproof/coinGenerator.go b/stateproof/coinGenerator.go index eb256336dc..a8a7199ad1 100644 --- a/stateproof/coinGenerator.go +++ b/stateproof/coinGenerator.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/stateproof/coinGenerator_test.go b/stateproof/coinGenerator_test.go index cf4b326eae..38df47c179 100644 --- a/stateproof/coinGenerator_test.go +++ b/stateproof/coinGenerator_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/stateproof/committableSignatureSlot.go b/stateproof/committableSignatureSlot.go index c53df6960d..07a1d9885e 100644 --- a/stateproof/committableSignatureSlot.go +++ b/stateproof/committableSignatureSlot.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/stateproof/committableSignatureSlot_test.go b/stateproof/committableSignatureSlot_test.go index 5723df5aab..93a890d427 100644 --- a/stateproof/committableSignatureSlot_test.go +++ b/stateproof/committableSignatureSlot_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/stateproof/const.go b/stateproof/const.go index 35c6134e98..3580aaba6b 100644 --- a/stateproof/const.go +++ b/stateproof/const.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/stateproof/prover.go b/stateproof/prover.go index 45d9e27aa2..f7c6e69282 100644 --- a/stateproof/prover.go +++ b/stateproof/prover.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/stateproof/prover_test.go b/stateproof/prover_test.go index 42a0daa5ed..d804e9cf0c 100644 --- a/stateproof/prover_test.go +++ b/stateproof/prover_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/stateproof/structs.go b/stateproof/structs.go index f82edbd6c0..ecb8782da8 100644 --- a/stateproof/structs.go +++ b/stateproof/structs.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/stateproof/verifier.go b/stateproof/verifier.go index 0f36f95a50..1afbf0ab45 100644 --- a/stateproof/verifier.go +++ b/stateproof/verifier.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/stateproof/verifier_test.go b/stateproof/verifier_test.go index 352a53202a..5d26d642f3 100644 --- a/stateproof/verifier_test.go +++ b/stateproof/verifier_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/stateproof/weights.go b/stateproof/weights.go index 874222f493..95e72d627e 100644 --- a/stateproof/weights.go +++ b/stateproof/weights.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/stateproof/weights_test.go b/stateproof/weights_test.go index 718382563d..19a93f3622 100644 --- a/stateproof/weights_test.go +++ b/stateproof/weights_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/statetrie/nibbles/nibbles.go b/statetrie/nibbles/nibbles.go index d2f95678fd..ade9117674 100644 --- a/statetrie/nibbles/nibbles.go +++ b/statetrie/nibbles/nibbles.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/statetrie/nibbles/nibbles_test.go b/statetrie/nibbles/nibbles_test.go index 7b355c0386..0e81bef5e9 100644 --- a/statetrie/nibbles/nibbles_test.go +++ b/statetrie/nibbles/nibbles_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/util.go b/util.go index 8d167dfc8b..aa957a408b 100644 --- a/util.go +++ b/util.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/util_test.go b/util_test.go index 01941511b3..9c19053cec 100644 --- a/util_test.go +++ b/util_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/vrf.go b/vrf.go index 0002a7b2f7..b78580671f 100644 --- a/vrf.go +++ b/vrf.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify diff --git a/vrf_test.go b/vrf_test.go index 7acc791732..55f781b98c 100644 --- a/vrf_test.go +++ b/vrf_test.go @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Algorand, Inc. +// Copyright (C) 2019-2025 Algorand, Inc. // This file is part of go-algorand // // go-algorand is free software: you can redistribute it and/or modify