coinbase / kryptology

Apache License 2.0
847 stars 123 forks source link

Add PrependSign to BLS123-81 SigAug to enable signing with any pk prepended #48

Closed freddiecoleman closed 2 years ago

freddiecoleman commented 2 years ago

type=feature risk=low impact=sev2

Hi, I'm implementing the Signer interface for BLS123-81 in Rosetta SDK and require the ability to sign with a public key that is not derived from the secret key.

I felt it would be cleaner/safer to add this new exported function instead of introducing a breaking change to Sign which currently derives a public key from the passed in secret key.

mikelodder7 commented 2 years ago

Thanks for the PR. Couldn't you just prepend the public key as part of the message and call sign? That way you would have to have this function at all.

freddiecoleman commented 2 years ago

Thanks for the PR. Couldn't you just prepend the public key as part of the message and call sign? That way you would have to have this function at all.

Sign automatically prepends a PK derived from the passed in SK so it would end up with two public keys prepended.

https://github.com/coinbase/kryptology/blob/master/pkg/signatures/bls/bls_sig/usual_bls.go#L214

Also SigBasic can't be used to do this as that has a different domain seperation tag.

mikelodder7 commented 2 years ago

We have this method NewSigBasicWithDst which does allow you to set the DST

freddiecoleman commented 2 years ago

We have this method NewSigBasicWithDst which does allow you to set the DST

I hadn't noticed that and will give that a go. Thanks!