mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-27 13:48:49 +08:00
![dependabot[bot]](/assets/img/avatar_default.png)
Bumps [github.com/lestrrat-go/jwx/v2](https://github.com/lestrrat-go/jwx) from 2.0.8 to 2.0.11. - [Release notes](https://github.com/lestrrat-go/jwx/releases) - [Changelog](https://github.com/lestrrat-go/jwx/blob/develop/v2/Changes) - [Commits](https://github.com/lestrrat-go/jwx/compare/v2.0.8...v2.0.11) --- updated-dependencies: - dependency-name: github.com/lestrrat-go/jwx/v2 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
22 lines
758 B
Go
22 lines
758 B
Go
// Copyright (c) 2015 The btcsuite developers
|
|
// Copyright (c) 2015-2023 The Decred developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package secp256k1
|
|
|
|
// GenerateSharedSecret generates a shared secret based on a private key and a
|
|
// public key using Diffie-Hellman key exchange (ECDH) (RFC 5903).
|
|
// RFC5903 Section 9 states we should only return x.
|
|
//
|
|
// It is recommended to securely hash the result before using as a cryptographic
|
|
// key.
|
|
func GenerateSharedSecret(privkey *PrivateKey, pubkey *PublicKey) []byte {
|
|
var point, result JacobianPoint
|
|
pubkey.AsJacobian(&point)
|
|
ScalarMultNonConst(&privkey.Key, &point, &result)
|
|
result.ToAffine()
|
|
xBytes := result.X.Bytes()
|
|
return xBytes[:]
|
|
}
|