1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-29 17:36:38 +08:00

Fix ipns validator key parsing

License: MIT
Signed-off-by: Dirk McCormick <dirkmdev@gmail.com>
This commit is contained in:
Dirk McCormick
2018-01-23 08:25:40 -05:00
committed by Steven Allen
parent f6d507b203
commit fdb0046a17
2 changed files with 7 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import (
path "github.com/ipfs/go-ipfs/path"
u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
peer "gx/ipfs/Qma7H6RW8wRrfZpNSXwxYGcd1E149s42FpWNpDNieSVrnU/go-libp2p-peer"
ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto"
record "gx/ipfs/QmbsY8Pr6s3uZsKg7rzBtGDKeCtdoAhNaMTCXBUbvb1eCV/go-libp2p-record"
)
@ -45,7 +46,7 @@ func TestValidation(t *testing.T) {
t.Fatal(err)
}
// Create IPNS record path with a different key
// Create IPNS record path with a different private key
_, ipnsWrongAuthor := genKeys(t, r)
wrongAuthorRec, err := record.MakePutRecord(priv, ipnsWrongAuthor, val, true)
if err != nil {
@ -118,14 +119,14 @@ func TestValidation(t *testing.T) {
}
func genKeys(t *testing.T, r io.Reader) (ci.PrivKey, string) {
priv, pubk, err := ci.GenerateKeyPairWithReader(ci.RSA, 1024, r)
priv, _, err := ci.GenerateKeyPairWithReader(ci.RSA, 1024, r)
if err != nil {
t.Fatal(err)
}
pubkb, err := pubk.Bytes()
id, err := peer.IDFromPrivateKey(priv)
if err != nil {
t.Fatal(err)
}
p := "/ipns/" + u.Hash(pubkb).B58String()
return priv, p
_, ipnsKey := IpnsKeysForID(id)
return priv, ipnsKey
}

View File

@ -318,7 +318,7 @@ func ValidateIpnsRecord(r *record.ValidationRecord) error {
// need to do that here
// Author in key must match author in record
pid, err := peer.IDB58Decode(r.Key)
pid, err := peer.IDFromString(r.Key)
if err != nil {
return ErrInvalidAuthor
}