-
Notifications
You must be signed in to change notification settings - Fork 0
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
One curve to rule them all: Eliminate dependency to ethereum/go-ethereum #16
Conversation
We now use `btcsuite/btc/btcec` as a curve implementation in `ephemeral` and `frost` packages. This allows to eliminate the dependency to `ethereum/go-ethereum` altogether. The Marshal and Unmarshal code for points had to be copied from `ethereum/go-ethereum` to `bip340.go`. I found no code in `btcsuite/btc/btcec` doing what we need.
// byteLen := (BitCurve.BitSize + 7) >> 3 | ||
// ret := make([]byte, 1+2*byteLen) | ||
return 65 | ||
byteLen := (b.BitSize + 7) >> 3 |
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.
Non-blocking: I would take an opportunity an explain the bitwise magic for future-us. For example, here we divide by 8
but it took me a while to figure this out 😅 Same regarding other places in-scope of this PR.
// ret := make([]byte, 1+2*byteLen) | ||
return 65 | ||
byteLen := (b.BitSize + 7) >> 3 | ||
return 1 + 2*byteLen | ||
} | ||
|
||
// SerializePoint serializes the provided elliptic curve point to bytes. | ||
// The slice length is equal to SerializedPointLength(). | ||
func (b *Bip340Curve) SerializePoint(p *Point) []byte { |
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.
Probably not in-scope of this PR but we are not checking whether the given point is on the curve here. If this is ok, it's worth flagging this in the method's docstring. This may cause unexpected errors if we ever attempt to marshal a point whose coordinates use a different byte size than the BIP340 curve so, worth flagging.
@@ -113,6 +112,57 @@ func (b *Bip340Curve) DeserializePoint(bytes []byte) *Point { | |||
return point | |||
} | |||
|
|||
// Marshal and Unmarshal as well as readBits were copied from |
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.
Non-blocking: Worth covering Marshal
and Unmarshal
with some basic unit tests.
Depends on #15
We now use
btcsuite/btc/btcec
as a curve implementation inephemeral
andfrost
packages. This allows to eliminate the dependency toethereum/go-ethereum
altogether. The Marshal and Unmarshal code for points had to be copied fromethereum/go-ethereum
tobip340.go
. I found no code inbtcsuite/btc/btcec
doing what we need.