mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 06:12:55 +00:00
0babdad17b
* chore: upgrade go-waku to v0.5 * chore: add println and logs to check what's being stored in the enr, and preemptively delete the multiaddr field (#3219) * feat: add wakuv2 test (#3218)
28 lines
654 B
Go
28 lines
654 B
Go
package config
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"io"
|
|
|
|
"golang.org/x/crypto/hkdf"
|
|
|
|
"github.com/libp2p/go-libp2p/core/crypto"
|
|
|
|
"github.com/quic-go/quic-go"
|
|
)
|
|
|
|
const statelessResetKeyInfo = "libp2p quic stateless reset key"
|
|
|
|
func PrivKeyToStatelessResetKey(key crypto.PrivKey) (quic.StatelessResetKey, error) {
|
|
var statelessResetKey quic.StatelessResetKey
|
|
keyBytes, err := key.Raw()
|
|
if err != nil {
|
|
return statelessResetKey, err
|
|
}
|
|
keyReader := hkdf.New(sha256.New, keyBytes, nil, []byte(statelessResetKeyInfo))
|
|
if _, err := io.ReadFull(keyReader, statelessResetKey[:]); err != nil {
|
|
return statelessResetKey, err
|
|
}
|
|
return statelessResetKey, nil
|
|
}
|