Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nit: fix log message #62

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions chainio/avsregistry/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ func (r *AvsRegistryChainReader) GetOperatorsStakeInQuorumsOfOperatorAtBlock(
operatorId,
blockNumber)
if err != nil {
r.logger.Error("Failed to get operators state", "err", err, "fn", "AvsRegistryChainReader.GetOperatorsStakeInQuorumsOfOperatorAtBlock")
r.logger.Error(
"Failed to get operators state",
"err",
err,
"fn",
"AvsRegistryChainReader.GetOperatorsStakeInQuorumsOfOperatorAtBlock",
)
return nil, nil, err
}

Expand Down Expand Up @@ -133,7 +139,11 @@ func (r *AvsRegistryChainReader) GetOperatorStakeInQuorumsOfOperatorAtCurrentBlo
}
quorumStakes := make(map[types.QuorumNum]types.StakeAmount)
for _, quorum := range quorums {
stake, err := r.avsRegistryContractsClient.GetCurrentOperatorStakeForQuorum(&bind.CallOpts{}, operatorId, quorum)
stake, err := r.avsRegistryContractsClient.GetCurrentOperatorStakeForQuorum(
&bind.CallOpts{},
operatorId,
quorum,
)
if err != nil {
r.logger.Error("Failed to get operator stake", "err", err)
return nil, err
Expand Down
6 changes: 5 additions & 1 deletion chainio/elcontracts/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ func (w *ELChainWriter) RegisterBLSPublicKey(
if err != nil {
return nil, err
}
signedMsgHash := blsKeyPair.MakePubkeyRegistrationData(gethcommon.HexToAddress(operator.Address), w.elContractsClient.GetBLSPublicKeyCompendiumContractAddress(), chainID)
signedMsgHash := blsKeyPair.MakePubkeyRegistrationData(
gethcommon.HexToAddress(operator.Address),
w.elContractsClient.GetBLSPublicKeyCompendiumContractAddress(),
chainID,
)
signedMsgHashBN254 := blspubkeycompendium.BN254G1Point(utils.ConvertToBN254G1Point(signedMsgHash))
G1pubkeyBN254 := blspubkeycompendium.BN254G1Point(utils.ConvertToBN254G1Point(blsKeyPair.GetPubKeyG1()))
G2pubkeyBN254 := blspubkeycompendium.BN254G2Point(utils.ConvertToBN254G2Point(blsKeyPair.GetPubKeyG2()))
Expand Down
10 changes: 8 additions & 2 deletions crypto/bls/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ func (k *KeyPair) GetPubKeyG1() *G1Point {
// public key, and prevents the operator
// from attacking the signature protocol by registering a public key that is derived from other public keys.
// (e.g., see https://medium.com/@coolcottontail/rogue-key-attack-in-bls-signature-and-harmony-security-eac1ea2370ee)
func (k *KeyPair) MakePubkeyRegistrationData(operatorAddress common.Address, blsPubkeyCompendiumAddress common.Address, chainId *big.Int) *G1Point {
return &G1Point{bn254utils.MakePubkeyRegistrationData(k.PrivKey, operatorAddress, blsPubkeyCompendiumAddress, chainId)}
func (k *KeyPair) MakePubkeyRegistrationData(
operatorAddress common.Address,
blsPubkeyCompendiumAddress common.Address,
chainId *big.Int,
) *G1Point {
return &G1Point{
bn254utils.MakePubkeyRegistrationData(k.PrivKey, operatorAddress, blsPubkeyCompendiumAddress, chainId),
}
}
7 changes: 6 additions & 1 deletion crypto/bn254/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ func DeserializeG2(b []byte) *bn254.G2Affine {
return p
}

func MakePubkeyRegistrationData(privKey *fr.Element, operatorAddress common.Address, blsPubkeyCompendiumAddress common.Address, chainId *big.Int) *bn254.G1Affine {
func MakePubkeyRegistrationData(
privKey *fr.Element,
operatorAddress common.Address,
blsPubkeyCompendiumAddress common.Address,
chainId *big.Int,
) *bn254.G1Affine {
toHash := make([]byte, 0)
toHash = append(toHash, operatorAddress.Bytes()...)
// we also sign on the bls pubkey compendium contract's address, to prevent replay attacks
Expand Down
2 changes: 1 addition & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func ReadFile(path string) ([]byte, error) {

func ReadYamlConfig(path string, o interface{}) error {
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
log.Fatal("Path", path, "does not exist")
log.Fatal("Path ", path, " does not exist")
}
b, err := ReadFile(path)
if err != nil {
Expand Down
Loading