Encodes a 32 word, without any optimizations
(word []byte)
| 237 | |
| 238 | // Encodes a 32 word, without any optimizations |
| 239 | func (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 | |
| 257 | func (buf *Buffer) EncodeWordBytes32Inv(word []byte) ([]byte, EncodeType, error) { |
| 258 | if len(word) > 32 { |
no test coverage detected