(chunkSize uint64, bs []byte, encodeType uint64, encodeKey common.Hash)
| 301 | } |
| 302 | |
| 303 | func decodeChunk(chunkSize uint64, bs []byte, encodeType uint64, encodeKey common.Hash) []byte { |
| 304 | if len(bs) > int(chunkSize) { |
| 305 | panic("cannot decode chunk with size > CHUNK_SIZE") |
| 306 | } |
| 307 | if encodeType == ENCODE_KECCAK_256 { |
| 308 | output := make([]byte, len(bs)) |
| 309 | j := 0 |
| 310 | for i := 0; i < len(bs); i++ { |
| 311 | output[i] = bs[i] ^ encodeKey[j] |
| 312 | j = j + 1 |
| 313 | if j >= len(encodeKey) { |
| 314 | j = 0 |
| 315 | } |
| 316 | } |
| 317 | return output |
| 318 | } else if encodeType == NO_ENCODE { |
| 319 | output := make([]byte, len(bs)) |
| 320 | copy(output, bs) |
| 321 | return output |
| 322 | } else if encodeType == ENCODE_BLOB_POSEIDON { |
| 323 | mask, _ := encoder.Encode(encodeKey, int(chunkSize)) |
| 324 | return UnmaskDataInPlace(bs, mask) |
| 325 | } else if encodeType == ENCODE_ETHASH { |
| 326 | return UnmaskDataInPlace(bs, pora.GetMaskData(0, encodeKey, len(bs), nil)) |
| 327 | } else { |
| 328 | panic("unsupported encode type") |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | var EmptyBlobCommit = make([]byte, HashSizeInContract) |
| 333 |
no test coverage detected