Skip to content

Commit

Permalink
fix log message (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur authored Oct 25, 2023
1 parent 71ec295 commit 23a0dfd
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
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

0 comments on commit 23a0dfd

Please sign in to comment.