mirror of
https://github.com/luxfi/precompile.git
synced 2026-09-24 00:26:21 +00:00
Forty-five of the fifty-six suite modules keyed off <name>Config and eleven did not, in three other spellings: Verify, Threshold, Encapsulate. The LP-4200 unified PQCrypto block carried four of those conventions across its eight addresses — two KEMs named differently (mlkemConfig beside hqcEncapsulate) and two threshold schemes named differently (pulsarVerify beside coronaThreshold) — so the block that exists to be one thing did not read as one thing. The deviations also named an OPERATION where a precompile belongs. HQC decapsulates as well as encapsulates and the Verify precompiles do more than verify, so hqcEncapsulate was the name of one entry point standing in for the whole module. A config key selects a precompile; it is not a method selector. All fifty-six are <name>Config now. There is no compatibility shim: an upgrade.json naming an old key is naming something that does not exist, which luxd already refuses loudly, and every chain config in the estate moves with this. Co-authored-by: Hanzo Dev <[email protected]>
71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
// Copyright (C) 2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package cggmp21
|
|
|
|
import (
|
|
"github.com/luxfi/precompile/contract"
|
|
"github.com/luxfi/precompile/modules"
|
|
"github.com/luxfi/precompile/precompileconfig"
|
|
)
|
|
|
|
var _ contract.Configurator = &configurator{}
|
|
|
|
type configurator struct{}
|
|
|
|
func init() {
|
|
// Register CGGMP21 precompile module
|
|
if err := modules.RegisterModule(modules.Module{
|
|
ConfigKey: "cggmp21Config",
|
|
Address: ContractCGGMP21VerifyAddress,
|
|
Contract: CGGMP21VerifyPrecompile,
|
|
Configurator: &configurator{},
|
|
}); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (*configurator) MakeConfig() precompileconfig.Config {
|
|
return &Config{}
|
|
}
|
|
|
|
func (*configurator) Configure(
|
|
chainConfig precompileconfig.ChainConfig,
|
|
cfg precompileconfig.Config,
|
|
state contract.StateDB,
|
|
blockContext contract.ConfigurationBlockContext,
|
|
) error {
|
|
// No state initialization required for CGGMP21 verification
|
|
return nil
|
|
}
|
|
|
|
// Config implements the precompileconfig.Config interface for CGGMP21
|
|
type Config struct {
|
|
Upgrade precompileconfig.Upgrade `json:"upgrade"`
|
|
}
|
|
|
|
func (c *Config) Key() string {
|
|
return "cggmp21Config"
|
|
}
|
|
|
|
func (c *Config) Timestamp() *uint64 {
|
|
return c.Upgrade.Timestamp()
|
|
}
|
|
|
|
func (c *Config) IsDisabled() bool {
|
|
return c.Upgrade.Disable
|
|
}
|
|
|
|
func (c *Config) Equal(cfg precompileconfig.Config) bool {
|
|
other, ok := cfg.(*Config)
|
|
if !ok {
|
|
return false
|
|
}
|
|
return c.Upgrade.Equal(&other.Upgrade)
|
|
}
|
|
|
|
func (c *Config) Verify(chainConfig precompileconfig.ChainConfig) error {
|
|
// No additional verification required
|
|
return nil
|
|
}
|