@@ -28,7 +28,6 @@ import (
2828 "time"
2929
3030 lru "github.com/hashicorp/golang-lru"
31- "golang.org/x/crypto/sha3"
3231
3332 "github.com/CortexFoundation/CortexTheseus/accounts"
3433 "github.com/CortexFoundation/CortexTheseus/common"
@@ -38,6 +37,7 @@ import (
3837 "github.com/CortexFoundation/CortexTheseus/core/state"
3938 "github.com/CortexFoundation/CortexTheseus/core/types"
4039 "github.com/CortexFoundation/CortexTheseus/crypto"
40+ "github.com/CortexFoundation/CortexTheseus/crypto/keccak"
4141 "github.com/CortexFoundation/CortexTheseus/ctxcdb"
4242 "github.com/CortexFoundation/CortexTheseus/log"
4343 "github.com/CortexFoundation/CortexTheseus/params"
@@ -155,7 +155,7 @@ type SignerFn func(signer accounts.Account, mimeType string, message []byte) ([]
155155// Note, the method requires the extra data to be at least 65 bytes, otherwise it
156156// panics. This is done to avoid accidentally using both forms (signature present
157157// or not), which could be abused to produce different hashes for the same header.
158- func SealHash (header * types.Header ) (hash common.Hash ) {
158+ /* func SealHash(header *types.Header) (hash common.Hash) {
159159 hasher := sha3.NewLegacyKeccak256()
160160
161161 rlp.Encode(hasher, []any{
@@ -178,7 +178,7 @@ func SealHash(header *types.Header) (hash common.Hash) {
178178 //hasher.Sum(hash[:0])
179179 hasher.(crypto.KeccakState).Read(hash[:])
180180 return hash
181- }
181+ }*/
182182
183183// ecrecover extracts the Cortex account address from a signed header.
184184func ecrecover (header * types.Header , sigcache * lru.ARCCache ) (common.Address , error ) {
@@ -730,6 +730,21 @@ func calcDifficulty(snap *Snapshot, signer common.Address) *big.Int {
730730 return new (big.Int ).Set (diffNoTurn )
731731}
732732
733+ // SealHash returns the hash of a block prior to it being sealed.
734+ func SealHash (header * types.Header ) (hash common.Hash ) {
735+ hasher := keccak .NewLegacyKeccak256 ()
736+ encodeSigHeader (hasher , header )
737+ hasher .(crypto.KeccakState ).Read (hash [:])
738+ return hash
739+ }
740+
741+ // CliqueRLP returns the rlp bytes which needs to be signed for the proof-of-authority
742+ // sealing. The RLP to sign consists of the entire header apart from the 65 byte signature
743+ // contained at the end of the extra data.
744+ //
745+ // Note, the method requires the extra data to be at least 65 bytes, otherwise it
746+ // panics. This is done to avoid accidentally using both forms (signature present
747+ // or not), which could be abused to produce different hashes for the same header.
733748func CliqueRLP (header * types.Header ) []byte {
734749 b := new (bytes.Buffer )
735750 encodeSigHeader (b , header )
0 commit comments