-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
ellswift: introduce ElligatorSwift encoding and decoding funcs #2219
base: master
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 11147308122Details
💛 - Coveralls |
This is great! fwiw, I had great success using the csv files from the BIP324 directly for the tests and it gave me great test coverage too, see esp the big test running through all the "packet_encoding_test_vectors.csv" rows here |
cc: @ellemouton @ProofOfKeags for review |
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 to be a correct implementation of the BIP324 gear.
7227ec8
to
20aa98d
Compare
I don't have a strong opinion on whether we should add the csv files directly. In other parts of the codebase (i.e. other BIP test vectors), we just have the test vectors in the format that I have in this PR |
The BIP324 ElligatorSwift test vectors are also included.
cc @ellemouton for review comments on this pr. Thanks |
cc: @kcalvinalvin for review |
) | ||
|
||
func init() { | ||
c.SetByteSlice(cBytes[:]) |
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.
nit: instead of relying on the init function you should also be able to do this in the var section
_ = c.SetByteSlice(cBytes[:])
return nil, err | ||
} | ||
|
||
if initiating { |
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.
nit: I think would it make sense to only have the ellswiftOurs / ellswiftTheirs order toggle in the if to make clear that everything else stays the same?
Something like this:
var msg []byte
if initiating {
// Initiating, place our public key encoding first.
var msg []byte
msg = append(msg, ellswiftOurs[:]...)
msg = append(msg, ellswiftTheirs[:]...)
} else {
msg = append(msg, ellswiftTheirs[:]...)
msg = append(msg, ellswiftOurs[:]...)
}
msg = append(msg, ecdhPoint[:]...)
return chainhash.TaggedHash(ellswiftTag, msg), nil
The BIP324 ElligatorSwift test vectors are also included. They can be found here and here. This code could be more optimized, possibly by not using so many
new(FieldVal)
invocations among some other things.