Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

disable key inlining #40

Merged
merged 2 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ language: go
sudo: false

go:
- 1.9.x
- 1.11.x

install:
- make deps
Expand Down
15 changes: 1 addition & 14 deletions peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ import (
mh "github.com/multiformats/go-multihash"
)

// MaxInlineKeyLength is the maximum length a key can be for it to be inlined in
// the peer ID.
//
// * When `len(pubKey.Bytes()) <= MaxInlineKeyLength`, the peer ID is the
// identity multihash hash of the public key.
// * When `len(pubKey.Bytes()) > MaxInlineKeyLength`, the peer ID is the
// sha2-256 multihash of the public key.
const MaxInlineKeyLength = 42

var (
// ErrEmptyPeerID is an error for empty peer ID.
ErrEmptyPeerID = errors.New("empty peer ID")
Expand Down Expand Up @@ -150,11 +141,7 @@ func IDFromPublicKey(pk ic.PubKey) (ID, error) {
if err != nil {
return "", err
}
var alg uint64 = mh.SHA2_256
if len(b) <= MaxInlineKeyLength {
alg = mh.ID
}
hash, _ := mh.Sum(b, alg, -1)
hash, _ := mh.Sum(b, mh.SHA2_256, -1)
return ID(hash), nil
}

Expand Down
1 change: 1 addition & 0 deletions peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func TestIDMatchesPrivateKey(t *testing.T) {
}

func TestPublicKeyExtraction(t *testing.T) {
t.Skip("disabled until libp2p/go-libp2p-crypto#51 is fixed")
// Happy path
_, originalPub, err := ic.GenerateEd25519Key(rand.Reader)
if err != nil {
Expand Down