     return lhs.value == rhs.value
 }
 
+
+/// Read and strip the unsigned variable int buffer size value from front of buffer
+///
+/// - Parameter buffer: The buffer prefixed with the size of the payload as an uvarint
+/// - Returns: the size as an int64 and the buffer with the uvarint indicating size removed.
+/// - Throws: <#throws value description#>
+func uVarInt(buffer: [UInt8]) throws -> (UInt64, [UInt8]) {
+    let (size, bytesRead) = VarInt.uVarInt(buffer)
+    if bytesRead == 0 { throw MultihashError.VarIntBufferTooShort }
+    if bytesRead < 0 { throw MultihashError.VarIntTooLarge }
+    
+    // Return the size as read from the uvarint and the buffer without the uvarint
+    return (size, Array(buffer[bytesRead..<buffer.count]))
+}
+
 public func fromHexString(_ theString: String) throws -> Multihash {
     
     let buf = try SwiftHex.decodeString(hexString: theString) 

//    print("The var int read is \(b0.0) and was \(b0.1) bytes")

    if dm.digest.count != dm.length {
        let b0 = Int(buf[0])
        print("SwiftMultihash decodeBuf error: buf[0] is \(b0), and code is \(String(describing: Codes[b0])) and buf[1] is \(buf[1])")
        throw MultihashError.inconsistentLength(dm.length)
    }


    case unknownCode
    case hashTooShort
    case hashTooLong
    case VarIntBufferTooShort
    case VarIntTooLarge
    case lengthNotSupported
    case hexConversionFail
    case inconsistentLength(Int)
