diff --git a/src/hdnode.js b/src/hdnode.js
index <HASH>..<HASH> 100644
--- a/src/hdnode.js
+++ b/src/hdnode.js
@@ -31,6 +31,7 @@ function HDNode(K, chainCode, network) {
   network = network || networks.bitcoin
 
   assert(Buffer.isBuffer(chainCode), 'Expected Buffer, got ' + chainCode)
+  assert.equal(chainCode.length, 32, 'Expected chainCode length of 32, got ' + chainCode.length)
   assert(network.bip32, 'Unknown BIP32 constants for network')
 
   this.chainCode = chainCode
diff --git a/test/hdnode.js b/test/hdnode.js
index <HASH>..<HASH> 100644
--- a/test/hdnode.js
+++ b/test/hdnode.js
@@ -49,7 +49,13 @@ describe('HDNode', function() {
       assert.equal(hd.network, networks.testnet)
     })
 
-    it('throws an exception when an unknown network is given', function() {
+    it('throws when an invalid length chain code is given', function() {
+      assert.throws(function() {
+        new HDNode(d, chainCode.slice(0, 20), networks.testnet)
+      }, /Expected chainCode length of 32, got 20/)
+    })
+
+    it('throws when an unknown network is given', function() {
       assert.throws(function() {
         new HDNode(d, chainCode, {})
       }, /Unknown BIP32 constants for network/)
HDNode: assert chain code length