Skip to content

Main content

Encoding: Protocol Buffers Wire Key Scalar Fields Tool

Pack one Protocol Buffers field number and legal wire type into an unsigned32 key, excluding compiler-reserved field19000..19999; no message encoding.

Loading tool…

Description

Return wireKey = fieldNumber*8+wireType.

Protocol Buffer integer fields separate a numeric key, signed-value mapping and byte representation. Varint groups carry seven payload bits plus continuation, while ZigZag and sign-extended integer types represent negative values differently.

Return wireKey = fieldNumber*8+wireType.

When to use this tool

Use Encoding: Protocol Buffers Wire Key Scalar Fields when inspecting one supplied protobuf integer or key-encoding component.

How to use the tool and how it works

  1. Enter fieldNumber, wireType. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read result. Expand result to inspect the returned fields.

Require whole fieldNumber in [1,536870911] excluding 19000-19999 and whole wireType in [0,5]. Return wireKey = fieldNumber*8+wireType.1

Protobuf separates keys, varints, fixed-width payloads and signed mappings. A local field transformation does not encode a complete message.2

Input fieldMeaning and unitsAccepted input
fieldNumberField NumberRequired. Safe integer.
wireTypeWhole wire type 0-5; legacy group codes are accepted.Required. Safe integer.
Output fieldInterpretationReturned shape
resultObject containing the named calculated members below.Required. Object.
result.wireKeyWire KeyCalculated result member: number.
json
{
  "input": {
    "fieldNumber": 2,
    "wireType": 2
  },
  "output": {
    "result": {
      "wireKey": 18
    }
  }
}

Limitations and assumptions

  • The output is a numeric protobuf key before varint encoding. Legacy group wire types 3 and 4 are accepted; message schemas, field semantics and payload compatibility are not checked.
  • Outputs are nested inside result. Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Use a conforming complete serializer and message schema for full wire encoding, payload validation and interoperability.

References

  1. Calculation and input contract: encode/protobuf-wire-key-scalar-fields — tool.io

  2. Protocol Buffers wire encoding — Protocol Buffers

Similar or alternative tools