diff --git a/contrib/backends/srndv2/src/srnd/daemon.go b/contrib/backends/srndv2/src/srnd/daemon.go index 3fe2ebd..27b5466 100644 --- a/contrib/backends/srndv2/src/srnd/daemon.go +++ b/contrib/backends/srndv2/src/srnd/daemon.go @@ -165,7 +165,7 @@ func (self *NNTPDaemon) WrapSign(nntp NNTPMessage) { if seed == nil { log.Println("invalid secretkey will not sign") } else { - pk, sec := seedToKeyPair(seed) + pk, sec := naclSeedToKeyPair(seed) sig := msgidFrontendSign(sec, nntp.MessageID()) nntp.Headers().Add("X-Frontend-Signature", sig) nntp.Headers().Add("X-Frontend-Pubkey", hexify(pk)) diff --git a/contrib/backends/srndv2/src/srnd/frontend_http.go b/contrib/backends/srndv2/src/srnd/frontend_http.go index 5587b97..e5d4958 100644 --- a/contrib/backends/srndv2/src/srnd/frontend_http.go +++ b/contrib/backends/srndv2/src/srnd/frontend_http.go @@ -921,7 +921,7 @@ func (self *httpFrontend) handle_postRequest(pr *postRequest, b bannedFunc, e er // pack it before sending so that the article is well formed // sign if needed if len(tripcode_privkey) == 32 { - pk, _ := seedToKeyPair(tripcode_privkey) + pk, _ := naclSeedToKeyPair(tripcode_privkey) nntp.headers.Set("X-PubKey-Ed25519", hexify(pk)) nntp.Pack() err = self.daemon.store.RegisterPost(nntp) diff --git a/contrib/backends/srndv2/src/srnd/message.go b/contrib/backends/srndv2/src/srnd/message.go index f98388a..778d23d 100644 --- a/contrib/backends/srndv2/src/srnd/message.go +++ b/contrib/backends/srndv2/src/srnd/message.go @@ -180,7 +180,7 @@ func signArticle(nntp NNTPMessage, seed []byte) (signed *nntpArticle, err error) mw.Write([]byte{10}) if err == nil { // build keypair - pk, sk := seedToKeyPair(seed) + pk, sk := naclSeedToKeyPair(seed) // sign it nigguh digest := sha.Sum(nil) sig := cryptoSignFucky(digest, sk) @@ -188,8 +188,8 @@ func signArticle(nntp NNTPMessage, seed []byte) (signed *nntpArticle, err error) // log.Printf("signed %s pubkey=%s sig=%s hash=%s", nntp.MessageID(), pk, sig, hexify(digest)) signed.headers.Set("X-Signature-Ed25519-SHA512", sig) signed.headers.Set("X-PubKey-Ed25519", hexify(pk[:])) - sig = cryptoSignProper(blake.Sum(nil), sk) - signed.headers.Set("X-Signature-Ed25519-BLAKE2B", sig) + //sig = cryptoSignProper(blake.Sum(nil), sk) + //signed.headers.Set("X-Signature-Ed25519-BLAKE2B", sig) } return } diff --git a/contrib/backends/srndv2/src/srnd/mod_http.go b/contrib/backends/srndv2/src/srnd/mod_http.go index 3f675dd..14f73e9 100644 --- a/contrib/backends/srndv2/src/srnd/mod_http.go +++ b/contrib/backends/srndv2/src/srnd/mod_http.go @@ -415,7 +415,7 @@ func (self httpModUI) CheckPubkey(pubkey, scope string) (bool, error) { func (self httpModUI) CheckKey(privkey, scope string) (bool, error) { privkey_bytes, err := hex.DecodeString(privkey) if err == nil { - pk, _ := seedToKeyPair(privkey_bytes) + pk, _ := naclSeedToKeyPair(privkey_bytes) pubkey := hex.EncodeToString(pk) return self.CheckPubkey(pubkey, scope) } diff --git a/contrib/backends/srndv2/src/srnd/nacl_crypto.go b/contrib/backends/srndv2/src/srnd/nacl_crypto.go index 96462e4..bf66796 100644 --- a/contrib/backends/srndv2/src/srnd/nacl_crypto.go +++ b/contrib/backends/srndv2/src/srnd/nacl_crypto.go @@ -21,7 +21,7 @@ func naclCryptoSignDetached(hash, sk []byte) []byte { return nacl.CryptoSignDetached(hash, sk) } -func seedToKeyPair(seed []byte) (pk, sk []byte) { +func naclSeedToKeyPair(seed []byte) (pk, sk []byte) { kp := nacl.LoadSignKey(seed) defer kp.Free() pk, sk = kp.Public(), kp.Secret() diff --git a/contrib/backends/srndv2/src/srnd/util.go b/contrib/backends/srndv2/src/srnd/util.go index 4b85190..0a105c9 100644 --- a/contrib/backends/srndv2/src/srnd/util.go +++ b/contrib/backends/srndv2/src/srnd/util.go @@ -298,7 +298,7 @@ func ValidNewsgroup(newsgroup string) bool { func genKeypair() (pk, sk []byte) { sk = randbytes(32) - pk, _ = seedToKeyPair(sk) + pk, _ = naclSeedToKeyPair(sk) return } @@ -395,7 +395,7 @@ func hexify(data []byte) string { // extract pubkey from secret key // return as hex func getSignPubkey(sk []byte) string { - pk, _ := seedToKeyPair(sk) + pk, _ := naclSeedToKeyPair(sk) return hexify(pk) } @@ -411,31 +411,9 @@ func cryptoSignFucky(h, sk []byte) string { return hexify(sig) } -/* -// convert seed to secret key -func seedToKeyPair(seed []byte) (pub ed25519.PublicKey, full ed25519.PrivateKey) { - pub = make(ed25519.PublicKey, ed25519.PublicKeySize) - full = make(ed25519.PrivateKey, ed25519.PrivateKeySize) - h := sha512.Sum512(seed) - seed = h[:] - seed[0] &= 248 - seed[31] &= 127 - seed[31] |= 64 - var in [32]byte - var out [32]byte - copy(in[:], seed[0:32]) - naclScalarBaseMult(&out, &in) - copy(pub[:], out[:]) - copy(full[0:32], in[:]) - copy(full[32:64], pub[:]) - log.Println("pk=", hexify(pub[:])) - return -} -*/ - func cryptoSignProper(h, sk []byte) string { - // convert key - _, key := seedToKeyPair(sk) + key := make(ed25519.PrivateKey, ed25519.PrivateKeySize) + copy(key, sk) // sign sig := ed25519.Sign(key, h) if sig == nil {