-
Notifications
You must be signed in to change notification settings - Fork 104
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
Darc ECDSA #2484
base: darc_identity_test
Are you sure you want to change the base?
Darc ECDSA #2484
Conversation
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.
Thanks for this PR. I think the most difficult bit is the naming :) You called it ECDSA
, but I think it would be more appropriate to call it something like MPCECDSA
, or TSMECDSA
or such.
@@ -964,6 +973,10 @@ func (id Identity) GetPublicBytes() []byte { | |||
return buf | |||
case 4: | |||
return id.EvmContract.Address[:] | |||
case 5: | |||
buf := elliptic.Marshal(id.ECDSA.PublicKey.Curve, id.ECDSA.PublicKey.X, id.ECDSA.PublicKey.Y) | |||
//TODO: add error check 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.
What kind of error check can you do here? The GetPublicBytes
doesn't return an error, so all you could do is panic
.
darc/darc.go
Outdated
} | ||
} | ||
|
||
//TODO make calls to tsm available |
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.
Please resolve all TODOs.
From what I understand, the Verify
method will not call to the TSM, no?
//necessary function, needs to be refactored only supports elliptic.P256 curve | ||
//needs to be tested Unmarshal might not work |
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.
//necessary function, needs to be refactored only supports elliptic.P256 curve | |
//needs to be tested Unmarshal might not work | |
// Tries to convert a string into a sec256k1 point. | |
// TODO: needs to be tested Unmarshal might not work |
darc/darc.go
Outdated
@@ -790,6 +793,8 @@ func (s Signer) Identity() Identity { | |||
return NewIdentityProxy(s.Proxy) | |||
case 4: | |||
return NewIdentityEvmContract(s.EvmContract) | |||
case 5: | |||
return NewIdentityECDSA(s.ECDSA.PublicKey) |
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.
Here and everywhere else: we should call the ECDSA
identity MPCECDSA
to indicate we're doing something special..
id := make([]byte, hex.DecodedLen(len(in))) | ||
_, err := hex.Decode(id, []byte(in)) |
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.
id := make([]byte, hex.DecodedLen(len(in))) | |
_, err := hex.Decode(id, []byte(in)) | |
buf, err := hex.DecodeString(in) | |
if err != nil { | |
return xerrors.Errorf("couldn't parse hex-string: %v", err) | |
} |
if err != nil { | ||
return Identity{}, err | ||
} |
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.
if err != nil { | |
return Identity{}, err | |
} |
Treat the error as close as possible to the source. Else it is very confusing.
darc/darc.go
Outdated
@@ -1447,6 +1500,22 @@ func (kcs SignerX509EC) Sign(msg []byte) ([]byte, error) { | |||
return nil, errors.New("not yet implemented") | |||
} | |||
|
|||
// new signer creates a signer only with a public key used to verify signatures |
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.
// new signer creates a signer only with a public key used to verify signatures | |
// NewSignerECDSA only takes a public key as the MPC is needed to sign data. |
darc/darc.go
Outdated
}} | ||
} | ||
|
||
//TODO |
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.
One way to implement sign would be to give the necessary configuration when calling NewSignerECDSA
, and then having Sign
call the MPC backend. But that would introduce a dependency on the MPC code that we probably don't want to have in here.
//TODO | |
// Sign cannot be implemented, as only the MPC can sign a message. |
darc/darc_test.go
Outdated
msg := []byte(`Hello World`) | ||
|
||
//Signature from code example go-tsm-sdk corresponding to ecdsa public key example | ||
signed, _ := hex.DecodeString("304402204f0b20a44efacec7b0514683233a79552026fe80e468078f6fed6cfe3f3e8a0402201eb12db7f6fe0828cafe8b0a032a37ff377b342799cfe77cfbac40c8ec1fa9e8") |
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.
signed, _ := hex.DecodeString("304402204f0b20a44efacec7b0514683233a79552026fe80e468078f6fed6cfe3f3e8a0402201eb12db7f6fe0828cafe8b0a032a37ff377b342799cfe77cfbac40c8ec1fa9e8") | |
signed, err := hex.DecodeString("304402204f0b20a44efacec7b0514683233a79552026fe80e468078f6fed6cfe3f3e8a0402201eb12db7f6fe0828cafe8b0a032a37ff377b342799cfe77cfbac40c8ec1fa9e8") | |
require.NoError(t, err) |
ALWAYS do error checking! You will save yourself a lot of pain!
var x, _ = new(big.Int).SetString("25613385885653880697990944418179706546134037329992108968315147853972798913688", 10) | ||
var y, _ = new(big.Int).SetString("74946767262888349555270609195205284686604880870734462312238891495596941025713", 10) |
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.
Error checking needed.
You can also use the |
SonarCloud Quality Gate failed. 0 Bugs No Coverage information |
SonarCloud Quality Gate failed. 0 Bugs No Coverage information |
What this PR does
See commit message
This PR
🙅 Friendly checklist:
xerrors.Errorf
and the%v
verb.