-
Notifications
You must be signed in to change notification settings - Fork 45
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: signer abstraction #395
base: dev
Are you sure you want to change the base?
feat: signer abstraction #395
Conversation
type Signer interface { | ||
SignMessage(ctx context.Context, message [32]byte) ([]byte, error) | ||
|
||
GetOperatorId() (string, error) |
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.
should there be context.Context
here? it's a pure operation - as in it doesn't depend on network in any case.
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.
Then no. Unless you think some implementation in the future might need to make this call over the network, for eg calling a contract?
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.
wait how does cerberus get operatorId? Doesn't it have to ask the remote signer over the network?
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.
operatorId is just extracted out of public key. so that call just not need to go over the network since public key is provided by the caller when initializing the client.
} | ||
|
||
func New(path, password string) (*Signer, error) { | ||
keyPair, err := bls.ReadPrivateKeyFromFile(path, password) |
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 will need to be updated to handle the new format from https://github.com/Layr-Labs/bn254-keystore-go - will add that.
@@ -0,0 +1,9 @@ | |||
package bn254 |
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.
why does this all live in bn254? shouldnt signer interface be independent of signing scheme?
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.
hmm you are right actually - although I just want the signer to be for BLS signer - the ethereum signer will have different interfaces. We can have this signer support bn254 or bls12381. would that be okay?
type Signer interface { | ||
SignMessage(ctx context.Context, message [32]byte) ([]byte, error) | ||
|
||
GetOperatorId() (string, error) |
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.
wait how does cerberus get operatorId? Doesn't it have to ask the remote signer over the network?
type Signer struct { | ||
} | ||
|
||
func New(signerUrl, pubKeyHex, password string) *Signer { |
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.
what is password for here?
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.
password to encrypt the keystore file stored in remote signer.
keyPair *bls.KeyPair | ||
} | ||
|
||
func New(path, password string) (*Signer, error) { |
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.
NewFromFile and NewFromHex?
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 always from File that's why keystore. maybe I can create another implementation for plaintext? but I don't want anyone to use plaintext 😅
signatureBytes := s.keyPair.SignMessage(message).Bytes() | ||
var signature []byte | ||
copy(signature[:], signatureBytes[:]) |
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.
why do you have to copy like this? signatureBytes is a fixed array [32]byte or something?
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.
signatureBytes is a fixed array [32]byte
Yep that's exactly why I need to copy.
Fixes # .
What Changed?
Reviewer Checklist