@cryptotaxi247 / kubo / commits / fdb0046a1

Fix ipns validator key parsing

License: MIT Signed-off-by: Dirk McCormick <dirkmdev@gmail.com>

Dirk McCormick committed Jan 23, 2018 at 08:25 UTC fdb0046a1712e20ad107980b9667d65048b4660f
2 files changed +7 -6
namesys/ipns_validate_test.go
+6 -5
@@ -8,6 +8,7 @@ import (
8 path "github.com/ipfs/go-ipfs/path"
9 u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
10 proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
11 + peer "gx/ipfs/Qma7H6RW8wRrfZpNSXwxYGcd1E149s42FpWNpDNieSVrnU/go-libp2p-peer"
12 ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto"
13 record "gx/ipfs/QmbsY8Pr6s3uZsKg7rzBtGDKeCtdoAhNaMTCXBUbvb1eCV/go-libp2p-record"
14 )
@@ -45,7 +46,7 @@ func TestValidation(t *testing.T) {
46 t.Fatal(err)
47 }
48
48 - // Create IPNS record path with a different key
49 + // Create IPNS record path with a different private key
50 _, ipnsWrongAuthor := genKeys(t, r)
51 wrongAuthorRec, err := record.MakePutRecord(priv, ipnsWrongAuthor, val, true)
52 if err != nil {
@@ -118,14 +119,14 @@ func TestValidation(t *testing.T) {
119 }
120
121 func genKeys(t *testing.T, r io.Reader) (ci.PrivKey, string) {
121 - priv, pubk, err := ci.GenerateKeyPairWithReader(ci.RSA, 1024, r)
122 + priv, _, err := ci.GenerateKeyPairWithReader(ci.RSA, 1024, r)
123 if err != nil {
124 t.Fatal(err)
125 }
125 - pubkb, err := pubk.Bytes()
126 + id, err := peer.IDFromPrivateKey(priv)
127 if err != nil {
128 t.Fatal(err)
129 }
129 - p := "/ipns/" + u.Hash(pubkb).B58String()
130 - return priv, p
130 + _, ipnsKey := IpnsKeysForID(id)
131 + return priv, ipnsKey
132 }
namesys/publisher.go
+1 -1
@@ -318,7 +318,7 @@ func ValidateIpnsRecord(r *record.ValidationRecord) error {
318 // need to do that here
319
320 // Author in key must match author in record
321 - pid, err := peer.IDB58Decode(r.Key)
321 + pid, err := peer.IDFromString(r.Key)
322 if err != nil {
323 return ErrInvalidAuthor
324 }