-
Notifications
You must be signed in to change notification settings - Fork 24
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
SignedSSVMessage #345
SignedSSVMessage #345
Conversation
@@ -15,11 +16,19 @@ type MsgValidatorFunc = func(ctx context.Context, p peer.ID, msg *pubsub.Message | |||
|
|||
func MsgValidation(runner ssv.Runner) MsgValidatorFunc { | |||
return func(ctx context.Context, p peer.ID, msg *pubsub.Message) pubsub.ValidationResult { | |||
ssvMsg, err := DecodePubsubMsg(msg) | |||
signedSSVMsg, err := DecodePubsubMsg(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this is a complaint to myself.. but we should have deleted MsgValidation since it is definitely not what the code does at the moment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let's remove it in another PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
types/generate.go
Outdated
@@ -7,7 +7,7 @@ package types | |||
//go:generate go run github.com/ferranbt/fastssz/sszgen --path share.go --include ./operator.go,./messages.go,./signer.go,./domain_type.go | |||
|
|||
//go:generate rm -f ./messages_encoding.go | |||
//go:generate go run github.com/ferranbt/fastssz/sszgen --path messages.go --exclude-objs ValidatorPK,MessageID,MsgType | |||
//go:generate go run github.com/ferranbt/fastssz/sszgen --path messages.go --include ./operator.go --exclude-objs ValidatorPK,MessageID,MsgType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why this changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of OperatorID
addition
types/messages.go
Outdated
// SSVMessage is the main message passed within the SSV network. It encapsulates the SSVMessage structure and a signature | ||
type SignedSSVMessage struct { | ||
OperatorID OperatorID | ||
Signature []byte `ssz-max:"512"` // Current signature max size allow keys up to 512*8 = 4096 bits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it is just nice to comment that this is created by the operator's private key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe we need to add at least one test where we validate a real signature
to show that use RSA with correct padding
@GalRogozinski |
The spec should achieve 2 objectives in my eyes:
Currently the spec doesn't exactly reach those objectives and in the spec rewrite I am hoping to change this. Imagine someone changes the RSA parameters (for better security) and then creates an incompatibility. |
@GalRogozinski |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if err == nil { | ||
var pk *rsa.PublicKey | ||
pk, err = types.PemToPublicKey(test.RSAPublicKey) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
|
||
messageHash := sha256.Sum256(msg.Data) | ||
err = rsa.VerifyPKCS1v15(pk, crypto.SHA256, messageHash[:], msg.Signature) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for a future PR, something we are working in ssv-node is encapsulating all operator pubkey/private key operation to make them less dependent on specific functions. so if for example we'll want to change our RSA implementation it will be easy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great. I will try to encapsulate it here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this is probably a fork. we are creating signed messages in the node a bit differently right now.
https://github.com/bloxapp/ssv/blob/main/network/commons/common.go#L43
it might be good idea to consider using the same approach in the node unless this fork has some significant advantages.
@y0sher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fork because the implementation puts signature first and the PR puts operator first, right?
If so we should change this to not be a fork because I don't think there is a real advantage here...
Its a fork because the implementation uses its own way of encoding the sig and operators. even if you create the struct in the PR in the same order it doesn't mean the final encoded data will be the same unless you enforce the struct to be encoded in the same way. |
There are 2 things we can do here:
The only reason I would use SSZ is just for the sake of consistency, since we use SSZ everywhere. Besides this I don't see an advantage. But this is good enough for me to opt for 2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we fork so changed order is fine
Overview
Introduce
SignedSSVMessage
, which encapsulatesSSVMessage
along with asignature
and a senderidentifier
fields.Changes
SignedSSVMesage
structure intypes
DecodePubsubMsg
now returns aSignedSSVMesage
MsgValidation
adapted to receive aSignedSSVMesage
instead of aSSVMessage
.Note: though
SSVMessage
is no longer the transmitted message in the network, theRunner
still processes the typeSSVMessage
in theProcessMessage
function.Tests