MCPcopy Create free account
hub / github.com/XTLS/Go / SharedKey

Method SharedKey

key_schedule.go:167–178  ·  view source on GitHub ↗
(peerPublicKey []byte)

Source from the content-addressed store, hash-verified

165}
166
167func (p *nistParameters) SharedKey(peerPublicKey []byte) []byte {
168 curve, _ := curveForCurveID(p.curveID)
169 // Unmarshal also checks whether the given point is on the curve.
170 x, y := elliptic.Unmarshal(curve, peerPublicKey)
171 if x == nil {
172 return nil
173 }
174
175 xShared, _ := curve.ScalarMult(x, y, p.privateKey)
176 sharedKey := make([]byte, (curve.Params().BitSize+7)/8)
177 return xShared.FillBytes(sharedKey)
178}
179
180type x25519Parameters struct {
181 privateKey []byte

Callers

nothing calls this directly

Calls 1

curveForCurveIDFunction · 0.85

Tested by

no test coverage detected