gauntface / web-push-go

Apache License 2.0
99 stars 14 forks source link

nil pointer de-reference exception in computing sharedSecret #7

Closed ishail closed 8 years ago

ishail commented 8 years ago

I'm getting this exception while trying to send push notification. Complete traceback log is following:

**panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x0 pc=0x5364d1]

goroutine 1 [running]: panic(0x72cda0, 0xc82000a140) /usr/lib/go-1.6/src/runtime/panic.go:464 +0x3e6 math/big.(_Int).Cmp(0x0, 0xc8200c6b60, 0x1) /usr/lib/go-1.6/src/math/big/int.go:314 +0x21 crypto/elliptic.maybeReduceModP(0x0, 0xc8200683c0) /usr/lib/go-1.6/src/crypto/elliptic/p256_amd64.go:202 +0x37 crypto/elliptic.p256Curve.ScalarMult(0xc8200124c0, 0x0, 0x0, 0xc8200c6f40, 0x20, 0x20, 0x0, 0x0) /usr/lib/go-1.6/src/crypto/elliptic/p256amd64.go:245 +0xf3 github.com/googlechrome/push-encryption-go/webpush.sharedSecret(0x7f7dc6100600, 0xc8200124c0, 0xc820068180, 0x58, 0x60, 0xc8200c6f40, 0x20, 0x20, 0x0, 0x0, ...) /home/shail/Documents/pushchamp/controller/src/github.com/googlechrome/push-encryption-go/webpush/encrypt.go:301 +0xb0 github.com/googlechrome/push-encryption-go/webpush.Encrypt(0xc820049f08, 0x79df60, 0xe, 0xc82006b450, 0x0, 0x0) /home/shail/Documents/pushchamp/controller/src/github.com/googlechrome/push-encryption-go/webpush/encrypt.go:172 +0x48b github.com/googlechrome/push-encryption-go/webpush.NewPushRequest(0xc820049f08, 0x79df60, 0xe, 0x834160, 0xc0, 0x18, 0x0, 0x0) /home/shail/Documents/pushchamp/controller/src/github.com/googlechrome/push-encryption-go/webpush/push.go:58 +0x312 github.com/googlechrome/push-encryption-go/webpush.Send(0x94f540, 0xc820049f08, 0x79df60, 0xe, 0x834160, 0xc0, 0x0, 0x0, 0x0) /home/shail/Documents/pushchamp/controller/src/github.com/googlechrome/push-encryption-go/webpush/push.go:82 +0x7a main.main() /home/shail/Desktop/junk/enc.go:11 +0x140 exit status 2*

As much I found out, it is caused by 'publicX' is not present on given curve. Can you guys suggest a solution or I'm doing something wrong here?