danielhavir / go-ecies

Golang implementation of the ECIES encryption scheme using AES, Poly1305 and P-256/P-521 elliptic curves
5 stars 4 forks source link

Testing ECIES interoperability #4

Open udhos opened 4 years ago

udhos commented 4 years ago

Hi Daniel!

One thing you might enjoy to know, I hope. :smile: I am testing ECIES encrypt/decrypt among some Go implementations. So far, it seems each implementation only interoperates with itself. See below. "havir" is your go-ecies.

go test | grep good
    main_test.go:96: key=key1(secp256r1) text=text1 src= ethereum dst= ethereum good
    main_test.go:96: key=key1(secp256r1) text=text1 src= ethereum dst= obscuren good
    main_test.go:96: key=key1(secp256r1) text=text1 src=    havir dst=    havir good
    main_test.go:96: key=key1(secp256r1) text=text1 src= obscuren dst= ethereum good
    main_test.go:96: key=key1(secp256r1) text=text1 src= obscuren dst= obscuren good
    main_test.go:96: key=key2(secp256k1) text=text1 src=  bitcoin dst=  bitcoin good
    main_test.go:96: key=key2(secp256k1) text=text1 src=sghcrypto dst=sghcrypto good
    main_test.go:96: key=key2(secp256k1) text=text1 src= ecies_go dst= ecies_go good
    main_test.go:96: key=key2(secp256k1) text=text1 src=    btcec dst=    btcec good

If you want, you can find the full test code here: https://github.com/udhos/ecies-go-test/blob/master/main_test.go

Is it expected that distinct ECIES implementations should not talk to each other?

What do you think?

Thanks, Everton

joonas-fi commented 4 years ago

It really goes to show that the ECIES spec is miserable because it doesn't give us test vectors to validate our implementations against. I would've liked to use Ethereum's ECIES implementation in my project, but the code had too many suspicious elements (contradicting code, hard-to-read code, works for P256 but crashes for P384 even though the code should support it) I could not use or modify it because I can't trust it without testing it against test vectors.