Skip to content

Commit

Permalink
add metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
dssei committed Nov 27, 2024
1 parent 3d91e3d commit a7814b1
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 16 deletions.
10 changes: 10 additions & 0 deletions x/confidentialtransfers/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package keeper

import (
"fmt"
"github.com/armon/go-metrics"
"time"

paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"

Expand Down Expand Up @@ -68,6 +70,10 @@ func NewKeeper(
}

func (k BaseKeeper) GetAccount(ctx sdk.Context, address string, denom string) (types.Account, bool) {
defer metrics.MeasureSince(
[]string{"ct", "get", "account", "milliseconds"},
time.Now().UTC(),

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
)
addr, err := sdk.AccAddressFromBech32(address)
if err != nil {
return types.Account{}, false
Expand Down Expand Up @@ -108,6 +114,10 @@ func (k BaseKeeper) getCtAccount(ctx sdk.Context, address sdk.AccAddress, denom
}

func (k BaseKeeper) SetAccount(ctx sdk.Context, address string, denom string, account types.Account) error {
defer metrics.MeasureSince(
[]string{"ct", "set", "account", "milliseconds"},
time.Now().UTC(),

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
)
addr, err := sdk.AccAddressFromBech32(address)
if err != nil {
return err
Expand Down
81 changes: 71 additions & 10 deletions x/confidentialtransfers/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package keeper
import (
"bytes"
"context"
"github.com/armon/go-metrics"
"math"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -99,6 +101,10 @@ func (m msgServer) InitializeAccount(goCtx context.Context, req *types.MsgInitia
}

func (m msgServer) Deposit(goCtx context.Context, req *types.MsgDeposit) (*types.MsgDepositResponse, error) {
defer metrics.MeasureSince(
[]string{"ct", "deposit", "milliseconds"},
time.Now().UTC(),

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
)
ctx := sdk.UnwrapSDKContext(goCtx)

// Validate request
Expand Down Expand Up @@ -146,7 +152,13 @@ func (m msgServer) Deposit(goCtx context.Context, req *types.MsgDeposit) (*types

// Compute the new balances
teg := elgamal.NewTwistedElgamal()

addScalarStart := time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
newPendingBalanceLo, err := teg.AddScalar(account.PendingBalanceLo, uint64(bottom16))
metrics.MeasureSince(
[]string{"ct", "add", "scalar", "milliseconds"},
addScalarStart,
)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "error adding pending balance lo")
}
Expand Down Expand Up @@ -181,6 +193,10 @@ func (m msgServer) Deposit(goCtx context.Context, req *types.MsgDeposit) (*types
}

func (m msgServer) Withdraw(goCtx context.Context, req *types.MsgWithdraw) (*types.MsgWithdrawResponse, error) {
defer metrics.MeasureSince(
[]string{"ct", "withdraw", "milliseconds"},
time.Now().UTC(),

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
)
ctx := sdk.UnwrapSDKContext(goCtx)

// Get the requested address.
Expand All @@ -201,25 +217,40 @@ func (m msgServer) Withdraw(goCtx context.Context, req *types.MsgWithdraw) (*typ
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid msg")
}

rangeProofStart := time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
// Verify that the account has sufficient funds (Remaining balance after making the transfer is greater than or equal to zero.)
// This range proof verification is performed on the RemainingBalanceCommitment sent by the user.
// An additional check is required to ensure that this matches the remaining balance calculated by the server.
verified, _ := zkproofs.VerifyRangeProof(instruction.Proofs.RemainingBalanceRangeProof, instruction.RemainingBalanceCommitment, 64)
metrics.MeasureSince(
[]string{"ct", "verify", "range", "proof", "milliseconds"},
rangeProofStart,
)
if !verified {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "range proof verification failed")
}

// Verify that the remaining balance sent by the user matches the remaining balance calculated by the server.
teg := elgamal.NewTwistedElgamal()
subScalarStart := time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
remainingBalanceCalculated, err := teg.SubScalar(account.AvailableBalance, instruction.Amount)
metrics.MeasureSince(
[]string{"ct", "subtract", "scalar", "milliseconds"},
subScalarStart,
)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "error subtracting amount")
}

verifyCipherTextStart := time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
verified = zkproofs.VerifyCiphertextCommitmentEquality(
instruction.Proofs.RemainingBalanceEqualityProof,
&account.PublicKey, remainingBalanceCalculated,
&instruction.RemainingBalanceCommitment.C)
metrics.MeasureSince(
[]string{"ct", "verify", "ciphertext", "commitment", "equality", "milliseconds"},
verifyCipherTextStart,
)
if !verified {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "ciphertext commitment equality verification failed")
}
Expand Down Expand Up @@ -255,6 +286,10 @@ func (m msgServer) Withdraw(goCtx context.Context, req *types.MsgWithdraw) (*typ
}

func (m msgServer) ApplyPendingBalance(goCtx context.Context, req *types.MsgApplyPendingBalance) (*types.MsgApplyPendingBalanceResponse, error) {
defer metrics.MeasureSince(
[]string{"ct", "apply", "pending", "balance", "milliseconds"},
time.Now().UTC(),

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
)
ctx := sdk.UnwrapSDKContext(goCtx)

// Check if the account exists
Expand Down Expand Up @@ -282,12 +317,22 @@ func (m msgServer) ApplyPendingBalance(goCtx context.Context, req *types.MsgAppl

// Calculate updated balances
teg := elgamal.NewTwistedElgamal()
startAddWithLoHi := time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
newAvailableBalance, err := teg.AddWithLoHi(account.AvailableBalance, account.PendingBalanceLo, account.PendingBalanceHi)
metrics.MeasureSince(
[]string{"ct", "add", "with", "lo", "hi", "milliseconds"},
startAddWithLoHi,
)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "error summing balances")
}

startSubCiphertext := time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
zeroCiphertextLo, err := elgamal.SubtractCiphertext(account.PendingBalanceLo, account.PendingBalanceLo)
metrics.MeasureSince(
[]string{"ct", "subtract", "ciphertext", "milliseconds"},
startSubCiphertext,
)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "error zeroing pending balance lo")
}
Expand Down Expand Up @@ -372,6 +417,10 @@ func (m msgServer) CloseAccount(goCtx context.Context, req *types.MsgCloseAccoun
}

func (m msgServer) Transfer(goCtx context.Context, req *types.MsgTransfer) (*types.MsgTransferResponse, error) {
defer metrics.MeasureSince(
[]string{"ct", "transfer", "milliseconds"},
time.Now().UTC(),

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
)
ctx := sdk.UnwrapSDKContext(goCtx)

instruction, err := req.FromProto()
Expand Down Expand Up @@ -401,13 +450,18 @@ func (m msgServer) Transfer(goCtx context.Context, req *types.MsgTransfer) (*typ

// Calculate senders new available balance.
teg := elgamal.NewTwistedElgamal()
startSubWithLoHi := time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
newSenderBalanceCiphertext, err := teg.SubWithLoHi(senderAccount.AvailableBalance, instruction.SenderTransferAmountLo, instruction.SenderTransferAmountHi)
metrics.MeasureSince(
[]string{"ct", "subtract", "with", "lo", "hi", "milliseconds"},
startSubWithLoHi)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "error subtracting sender transfer amount")
}

// Validate proofs
err = types.VerifyTransferProofs(instruction, &senderAccount.PublicKey, &recipientAccount.PublicKey, newSenderBalanceCiphertext)

if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
}
Expand All @@ -433,12 +487,19 @@ func (m msgServer) Transfer(goCtx context.Context, req *types.MsgTransfer) (*typ
}

// Calculate and Update the account states.
startAddCipherText := time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
recipientPendingBalanceLo, err := elgamal.AddCiphertext(recipientAccount.PendingBalanceLo, instruction.RecipientTransferAmountLo)
metrics.MeasureSince(
[]string{"ct", "add", "ciphertext", "PendingBalanceLo", "milliseconds"},
startAddCipherText)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "error adding recipient transfer amount lo")
}

startAddCipherText = time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
recipientPendingBalanceHi, err := elgamal.AddCiphertext(recipientAccount.PendingBalanceHi, instruction.RecipientTransferAmountHi)
metrics.MeasureSince(
[]string{"ct", "add", "ciphertext", "PendingBalanceHi", "milliseconds"},
startAddCipherText)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "error adding recipient transfer amount hi")
}
Expand All @@ -451,15 +512,15 @@ func (m msgServer) Transfer(goCtx context.Context, req *types.MsgTransfer) (*typ
senderAccount.AvailableBalance = newSenderBalanceCiphertext

// Save the account states
//err = m.Keeper.SetAccount(ctx, req.FromAddress, req.Denom, senderAccount)
//if err != nil {
// return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "error setting sender account")
//}
//
//err = m.Keeper.SetAccount(ctx, req.ToAddress, req.Denom, recipientAccount)
//if err != nil {
// return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "error setting recipient account")
//}
err = m.Keeper.SetAccount(ctx, req.FromAddress, req.Denom, senderAccount)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "error setting sender account")
}

err = m.Keeper.SetAccount(ctx, req.ToAddress, req.Denom, recipientAccount)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "error setting recipient account")
}

// Emit any required events
ctx.EventManager().EmitEvents(sdk.Events{
Expand Down
5 changes: 5 additions & 0 deletions x/confidentialtransfers/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package types

import (
"crypto/ecdsa"
"github.com/armon/go-metrics"

Check failure on line 5 in x/confidentialtransfers/types/msgs.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed (goimports)
"time"

"github.com/coinbase/kryptology/pkg/core/curves"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -92,6 +94,9 @@ func (m *MsgTransfer) GetSigners() []sdk.AccAddress {
}

func (m *MsgTransfer) FromProto() (*Transfer, error) {
defer metrics.MeasureSince(
[]string{"ct", "msg", "transfer", "from", "proto", "milliseconds"},
time.Now().UTC())

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
err := m.ValidateBasic()
if err != nil {
return nil, err
Expand Down
50 changes: 45 additions & 5 deletions x/confidentialtransfers/types/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package types
import (
"crypto/ecdsa"
"errors"
"github.com/armon/go-metrics"

Check failure on line 6 in x/confidentialtransfers/types/transfer.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed (goimports)
"math/big"
"strconv"
"time"

"github.com/coinbase/kryptology/pkg/core/curves"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -275,35 +277,58 @@ func createTransferPartyParams(

// Verifies the proofs sent in the transfer request. This does not verify proofs for auditors.
func VerifyTransferProofs(params *Transfer, senderPubkey *curves.Point, recipientPubkey *curves.Point, newBalanceCiphertext *elgamal.Ciphertext) error {
defer metrics.MeasureSince(
[]string{"ct", "verify", "transfer", "proofs", "milliseconds"},
time.Now().UTC())

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

Check warning on line 282 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L280-L282

Added lines #L280 - L282 were not covered by tests
// Verify the validity proofs that the ciphertexts sent are valid (encrypted with the correct pubkey).
startVerifyCiphertextValidity := time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

Check warning on line 284 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L284

Added line #L284 was not covered by tests
ok := zkproofs.VerifyCiphertextValidity(params.Proofs.RemainingBalanceCommitmentValidityProof, *senderPubkey, params.RemainingBalanceCommitment)
metrics.MeasureSince(
[]string{"ct", "verify", "ciphertext", "validity", "RemainingBalanceCommitmentValidityProof", "milliseconds"},
startVerifyCiphertextValidity)

Check warning on line 288 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L286-L288

Added lines #L286 - L288 were not covered by tests
if !ok {
return errors.New("failed to verify remaining balance commitment")
}

startVerifyCiphertextValidity = time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

Check warning on line 292 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L292

Added line #L292 was not covered by tests
ok = zkproofs.VerifyCiphertextValidity(params.Proofs.SenderTransferAmountLoValidityProof, *senderPubkey, params.SenderTransferAmountLo)
metrics.MeasureSince(
[]string{"ct", "verify", "ciphertext", "validity", "SenderTransferAmountLoValidityProof", "milliseconds"},
startVerifyCiphertextValidity)

Check warning on line 296 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L294-L296

Added lines #L294 - L296 were not covered by tests
if !ok {
return errors.New("failed to verify sender transfer amount lo")
}

startVerifyCiphertextValidity = time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

Check warning on line 300 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L300

Added line #L300 was not covered by tests
ok = zkproofs.VerifyCiphertextValidity(params.Proofs.SenderTransferAmountHiValidityProof, *senderPubkey, params.SenderTransferAmountHi)
metrics.MeasureSince(
[]string{"ct", "verify", "ciphertext", "validity", "SenderTransferAmountHiValidityProof", "milliseconds"},
startVerifyCiphertextValidity)

Check warning on line 304 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L302-L304

Added lines #L302 - L304 were not covered by tests
if !ok {
return errors.New("failed to verify sender transfer amount hi")
}

startVerifyCiphertextValidity = time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

Check warning on line 308 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L308

Added line #L308 was not covered by tests
ok = zkproofs.VerifyCiphertextValidity(params.Proofs.RecipientTransferAmountLoValidityProof, *recipientPubkey, params.RecipientTransferAmountLo)
metrics.MeasureSince(
[]string{"ct", "verify", "ciphertext", "validity", "RecipientTransferAmountLoValidityProof", "milliseconds"},
startVerifyCiphertextValidity)

Check warning on line 312 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L310-L312

Added lines #L310 - L312 were not covered by tests
if !ok {
return errors.New("failed to verify recipient transfer amount lo")
}

startVerifyCiphertextValidity = time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

Check warning on line 316 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L316

Added line #L316 was not covered by tests
ok = zkproofs.VerifyCiphertextValidity(params.Proofs.RecipientTransferAmountHiValidityProof, *recipientPubkey, params.RecipientTransferAmountHi)
if !ok {
return errors.New("failed to verify recipient transfer amount hi")
}
metrics.MeasureSince(
[]string{"ct", "verify", "ciphertext", "validity", "RecipientTransferAmountHiValidityProof", "milliseconds"},
startVerifyCiphertextValidity)

Check warning on line 323 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L321-L323

Added lines #L321 - L323 were not covered by tests

// Verify that the account's remaining balance is greater than zero after this transfer.
// This validates the RemainingBalanceCommitment sent by the user, so an additional check is needed to make sure this matches what is calculated by the server.
startRangeProof := time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

Check warning on line 327 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L327

Added line #L327 was not covered by tests
ok, err := zkproofs.VerifyRangeProof(params.Proofs.RemainingBalanceRangeProof, params.RemainingBalanceCommitment, 64)
metrics.MeasureSince(
[]string{"ct", "verify", "range", "proof", "RemainingBalanceRangeProof", "milliseconds"},
startRangeProof)

Check warning on line 331 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L329-L331

Added lines #L329 - L331 were not covered by tests
if err != nil {
return err
}
Expand All @@ -312,18 +337,30 @@ func VerifyTransferProofs(params *Transfer, senderPubkey *curves.Point, recipien
}

// As part of the range proof above, we verify that the RemainingBalanceCommitment sent by the user is equal to the remaining balance calculated by the server.
startVVerifyCiphertextCommitmentEquality := time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

Check warning on line 340 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L340

Added line #L340 was not covered by tests
ok = zkproofs.VerifyCiphertextCommitmentEquality(params.Proofs.RemainingBalanceEqualityProof, senderPubkey, newBalanceCiphertext, &params.RemainingBalanceCommitment.C)
metrics.MeasureSince(
[]string{"ct", "verify", "ciphertext", "commitment", "RemainingBalanceEqualityProof", "milliseconds"},
startVVerifyCiphertextCommitmentEquality)

Check warning on line 344 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L342-L344

Added lines #L342 - L344 were not covered by tests
if !ok {
return errors.New("ciphertext commitment equality verification failed")
}

// Lastly verify that the transferAmount ciphertexts encode the same value
startVVerifyCiphertextCommitmentEquality = time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

Check warning on line 350 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L350

Added line #L350 was not covered by tests
ok = zkproofs.VerifyCiphertextCiphertextEquality(params.Proofs.TransferAmountLoEqualityProof, senderPubkey, recipientPubkey, params.SenderTransferAmountLo, params.RecipientTransferAmountLo)
metrics.MeasureSince(
[]string{"ct", "verify", "ciphertext", "commitment", "TransferAmountLoEqualityProof", "milliseconds"},
startVVerifyCiphertextCommitmentEquality)

Check warning on line 354 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L352-L354

Added lines #L352 - L354 were not covered by tests
if !ok {
return errors.New("ciphertext ciphertext equality verification on transfer amount lo failed")
}

startVVerifyCiphertextCommitmentEquality = time.Now().UTC()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

Check warning on line 359 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L359

Added line #L359 was not covered by tests
ok = zkproofs.VerifyCiphertextCiphertextEquality(params.Proofs.TransferAmountHiEqualityProof, senderPubkey, recipientPubkey, params.SenderTransferAmountHi, params.RecipientTransferAmountHi)
metrics.MeasureSince(
[]string{"ct", "verify", "ciphertext", "commitment", "TransferAmountHiEqualityProof", "milliseconds"},
startVVerifyCiphertextCommitmentEquality)

Check warning on line 363 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L361-L363

Added lines #L361 - L363 were not covered by tests
if !ok {
return errors.New("ciphertext ciphertext equality verification on transfer amount hi failed")
}
Expand All @@ -338,10 +375,13 @@ func VerifyAuditorProof(
auditorParams *TransferAuditor,
senderPubkey *curves.Point,
auditorPubkey *curves.Point) error {
defer metrics.MeasureSince(
[]string{"ct", "verify", "auditor", "proofs", "milliseconds"},
time.Now().UTC())

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

Check warning on line 380 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L378-L380

Added lines #L378 - L380 were not covered by tests
// Verify that the transfer amounts are valid (encrypted with the correct pubkey).
ok := zkproofs.VerifyCiphertextValidity(auditorParams.TransferAmountLoValidityProof, *auditorPubkey, auditorParams.EncryptedTransferAmountLo)
if !ok {
return errors.New("failed to verify auditor transfer amoun lo")
return errors.New("failed to verify auditor transfer amount lo")

Check warning on line 384 in x/confidentialtransfers/types/transfer.go

View check run for this annotation

Codecov / codecov/patch

x/confidentialtransfers/types/transfer.go#L384

Added line #L384 was not covered by tests
}

ok = zkproofs.VerifyCiphertextValidity(auditorParams.TransferAmountHiValidityProof, *auditorPubkey, auditorParams.EncryptedTransferAmountHi)
Expand Down
Loading

0 comments on commit a7814b1

Please sign in to comment.