ecies / go Goto Github PK
View Code? Open in Web Editor NEWElliptic Curve Integrated Encryption Scheme for secp256k1 in Golang
Home Page: https://ecies.org/go
License: MIT License
Elliptic Curve Integrated Encryption Scheme for secp256k1 in Golang
Home Page: https://ecies.org/go
License: MIT License
I will fix it ASAP.
The package appears to have a bug where it will randomly produce a ciphertext it cannot decipher. This is easily reproducible with the following Go program, largely based on the example in the Readme:
package main
import (
"log"
ecies "github.com/ecies/go/v2"
)
func main() {
k, err := ecies.GenerateKey()
if err != nil {
panic(err)
}
log.Println("key pair has been generated")
for {
ciphertext, err := ecies.Encrypt(k.PublicKey, []byte("THIS IS THE TEST"))
if err != nil {
panic(err)
}
_, err = ecies.Decrypt(k, ciphertext)
if err != nil {
panic(err)
}
}
}
The expectation is that this program loops forever, however, what actually happens is that after a certain number of iterations (usually in the order of a few thousand), Decrypt
will fail with an error: "invalid public key". This is because the Encrypt function is rarely producing a ciphertext that does not appear to be valid.
go get github.com/ecies/go/v2
go: downloading github.com/ecies/go/v2 v2.0.3
go: github.com/ecies/go/[email protected]: verifying module: checksum mismatch
downloaded: h1:gosZ7+G8LFo0NHPGR7//Lcj7r5gzVRthWl/De3QVay8=
sum.golang.org: h1:rtz3x6uw+if+lt4a39JnCi7M/B35l1JShCXTOBe3LPw=
SECURITY ERROR
This download does NOT match the one reported by the checksum server.
The bits may have been replaced on the origin server, or an attacker may
have intercepted the download attempt.
For more information, see 'go help module-auth'.
@kigawas as far as I understand you are preparing this support for py/js/rs libraries. Currently Golang has new crypto/ecdh
standard library, but it lacks of rich configuration, I could only add some basic support for x25519 and xchacha20, otherwise I would need to fork stdlib, which will require more maintance.
Hello! Can you give a demo that loads keys from a file? Thank you very much!
Dependabot can't resolve your Go dependency files.
As a result, Dependabot couldn't update your dependencies.
The error Dependabot encountered was:
go: gopkg.in/[email protected]: invalid version: git fetch -f https://gopkg.in/check.v1 refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /opt/go/gopath/pkg/mod/cache/vcs/9241c28341fcedca6a799ab7a465dd6924dc5d94044cbfabb75778817250adfc: exit status 128:
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.
Hi,
How can I import ecies keys from existing ecdsa keys?
ecdsa: https://golang.org/pkg/crypto/ecdsa/
ecies: https://github.com/ecies/go
Thanks,
Everton
Hi guys,
Just sharing one thing you might enjoy, I hope. ๐
I am doing simplistic testing for ECIES encrypt/decrypt among some Go implementations.
So far, it seems each implementation only interoperates with itself. See below.
"ecies_go" is package github.com/ecies/go.
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 full test code here: https://github.com/udhos/ecies-go-test/blob/master/main_test.go
My cryptographic knowledge is close to zero, so please bear with me.
Are distinct ECIES implementations supposed to talk to each other?
What do you think?
Thanks,
Everton
Hello, I'm using github.com/ecies/go/v2 v2.0.7
, try to load a public key by openssl , and got the follow error:
panic: cannot parse public key
goroutine 1 [running]:
main.main()
the ecc public key is generate by the follow:
openssl version
OpenSSL 1.1.1n 15 Mar 2022
openssl ecparam -genkey -name secp256k1 -out ecc_private_key.pem
openssl ec -in ecc_private_key.pem -pubout -out ecc_public_key.pem
test go file:
package main
import (
"encoding/pem"
ecies "github.com/ecies/go/v2"
"log"
)
func main() {
pubStr := `
-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEvO6PRdLyD0EaRkFkfCeptcpey/P3ziHS
cbLbD96xg22JOvC3YYVtzyp4nVEyz+a07tonu3/pfEMstSiil1mEiw==
-----END PUBLIC KEY-----
`
block, _ := pem.Decode([]byte(pubStr))
pub, err := ecies.NewPublicKeyFromBytes(block.Bytes)
if err != nil {
panic(err)
}
log.Println(pub)
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.