Projects STRLCPY dnstt Commits 0269f6f5
🤬
  • ■ ■ ■ ■ ■
    go.mod
    skipped 5 lines
    6 6   github.com/flynn/noise v1.0.0
    7 7   github.com/xtaci/kcp-go/v5 v5.6.1
    8 8   github.com/xtaci/smux v1.5.15
     9 + golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
    9 10  )
    10 11   
  • ■ ■ ■ ■ ■ ■
    noise/noise.go
    skipped 16 lines
    17 17   "strings"
    18 18   
    19 19   "github.com/flynn/noise"
     20 + "golang.org/x/crypto/curve25519"
    20 21  )
    21 22   
    22 23  // The length of public and private keys as returned by GenerateKeypair.
    skipped 208 lines
    231 232   
    232 233  // PubkeyFromPrivkey returns the public key that corresponds to privkey.
    233 234  func PubkeyFromPrivkey(privkey []byte) []byte {
    234  - pair, err := noise.DH25519.GenerateKeypair(bytes.NewReader(privkey))
     235 + pubkey, err := curve25519.X25519(privkey, curve25519.Basepoint)
    235 236   if err != nil {
    236 237   panic(err)
    237 238   }
    238  - if !bytes.Equal(pair.Private, privkey) {
    239  - panic("privkey was not as expected")
    240  - }
    241  - return pair.Public
     239 + return pubkey
    242 240  }
    243 241   
    244 242  // ReadKey reads a hex-encoded key from r. r must consist of a single line, with
    skipped 44 lines
Please wait...
Page is in error, reload to recover