MCPcopy Create free account
hub / github.com/ethstorage/es-node / decodeFieldElement

Function decodeFieldElement

cmd/es-utils/utils/optimism_blob_encoder.go:204–211  ·  view source on GitHub ↗

decodeFieldElement decodes the next input field element by writing its lower 31 bytes into its appropriate place in the output and checking the high order byte is valid. Returns an InvalidFieldElementError if a field element is seen with either of its two high order bits set.

(b []byte, opos, ipos int, output []byte)

Source from the content-addressed store, hash-verified

202// appropriate place in the output and checking the high order byte is valid. Returns an
203// InvalidFieldElementError if a field element is seen with either of its two high order bits set.
204func decodeFieldElement(b []byte, opos, ipos int, output []byte) (byte, int, int, error) {
205 // two highest order bits of the first byte of each field element should always be 0
206 if b[ipos]&0b1100_0000 != 0 {
207 return 0, 0, 0, fmt.Errorf("%w: field element: %d", ErrBlobInvalidFieldElement, ipos)
208 }
209 copy(output[opos:], b[ipos+1:ipos+32])
210 return b[ipos], opos + 32, ipos + 32, nil
211}
212
213// reassembleBytes takes the 4x6-bit chunks from encodedByte, reassembles them into 3 bytes of
214// output, and places them in their appropriate output positions.

Callers 1

ToDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected