MCPcopy Create free account
hub / github.com/0xsequence/czip / EncodeWordBytes32

Method EncodeWordBytes32

compressor/encode.go:239–255  ·  view source on GitHub ↗

Encodes a 32 word, without any optimizations

(word []byte)

Source from the content-addressed store, hash-verified

237
238// Encodes a 32 word, without any optimizations
239func (buf *Buffer) EncodeWordBytes32(word []byte) ([]byte, EncodeType, error) {
240 if len(word) > 32 {
241 return nil, Stateless, fmt.Errorf("word exceeds 32 bytes")
242 }
243
244 if len(word) == 0 {
245 return nil, Stateless, fmt.Errorf("word is empty")
246 }
247
248 if !buf.Allows(FLAG_READ_WORD_1) {
249 return nil, Stateless, fmt.Errorf("bytes32 encoding is not allowed")
250 }
251
252 encodedWord := []byte{byte(FLAG_READ_WORD_1 + uint(len(word)) - 1)}
253 encodedWord = append(encodedWord, word...)
254 return encodedWord, Stateless, nil
255}
256
257func (buf *Buffer) EncodeWordBytes32Inv(word []byte) ([]byte, EncodeType, error) {
258 if len(word) > 32 {

Callers 1

EncodeWordOptimizedMethod · 0.95

Calls 1

AllowsMethod · 0.95

Tested by

no test coverage detected