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

feat(adr-035): eots manager signing requests #184

Merged
merged 8 commits into from
Dec 4, 2024
Merged

Conversation

Lazar955
Copy link
Member

@Lazar955 Lazar955 commented Dec 3, 2024

extends eots manager to store signing requests

Addreses

@Lazar955 Lazar955 requested a review from gitferry December 3, 2024 15:19
@Lazar955
Copy link
Member Author

Lazar955 commented Dec 3, 2024

Now TestDoubleSigning fails with:

failed to sign EOTS: rpc error: code = Unknown desc = double sign

Which is expected. Should we now expose an UnsafeSignEOTS in which we would retain the old logic or mock EOTS for this e2e?

Copy link
Member

@gitferry gitferry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! A few comments:

@@ -29,6 +30,10 @@ const (
MnemonicEntropySize = 256
)

var (
ErrDoubleSign = errors.New("double sign")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move it to eotsmanager/types/errors.go?

})
}

func (s *EOTSStore) GetSignRecord(height uint64) (*proto.SigningRecord, bool, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (s *EOTSStore) GetSignRecord(height uint64) (*proto.SigningRecord, bool, error) {
func (s *EOTSStore) GetSignRecord(height uint64) (*proto.SigningRecord, error) {

is bool necessary? nil value of proto.SigningRecord already indicates existence

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal preference, otherwise we would have to check what type of error it is, I find this more readable

record, found, err := lm.es.GetSignRecord(height)
if err != nil {
return nil, fmt.Errorf("error getting sign record: %w", err)
} else if found && record != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems we don't need else if but use a different block

@@ -194,6 +199,20 @@ func (lm *LocalEOTSManager) CreateRandomnessPairList(fpPk []byte, chainID []byte
}

func (lm *LocalEOTSManager) SignEOTS(fpPk []byte, chainID []byte, msg []byte, height uint64, passphrase string) (*btcec.ModNScalar, error) {
record, found, err := lm.es.GetSignRecord(height)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not safe to use data directly from db. Better to have a counter part of the db type to have validated data

@gitferry
Copy link
Member

gitferry commented Dec 4, 2024

Which is expected. Should we now expose an UnsafeSignEOTS in which we would retain the old logic or mock EOTS for this e2e?

Good point. For this PR, we can add a case where the error is expected to make CI pass. A subsequent PR can implement UnsafeSignEOTS for old logic

@Lazar955 Lazar955 requested a review from gitferry December 4, 2024 10:00
Copy link
Member

@gitferry gitferry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@Lazar955 Lazar955 merged commit ee15a86 into main Dec 4, 2024
12 checks passed
@Lazar955 Lazar955 deleted the lazar/store-signature branch December 4, 2024 10:34
@Lazar955 Lazar955 linked an issue Dec 4, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add anti-slashing mechanism to EOTS manager
2 participants