Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional data encode/decode methods #1667

Closed
Tracked by #10316
magik6k opened this issue Feb 28, 2023 · 5 comments
Closed
Tracked by #10316

Additional data encode/decode methods #1667

magik6k opened this issue Feb 28, 2023 · 5 comments

Comments

@magik6k
Copy link

magik6k commented Feb 28, 2023

Currently methods for encoding/decoding data to/from sectors are quite limited.

  • Unseal/UnsealRange allow reading unsealed data from sealed sectors, but require TreeR generation, which is slow and expensive, and cannot be stored
    • Even if there was a way to generate TreeR/SectorKey (Method to generate sector key #1666), there is no method to decode data from the sealed sector.
    • If that method exists ideally it would look like UnsealRange, taking sealed/key streams, which would allow unsealing services to generate sector key before fetching data from SPs, and decode (parts of) data with the key in a streaming fashion after getting the key.
  • Snapdeals encode/decode methods could also use streaming support.
@magik6k
Copy link
Author

magik6k commented Feb 28, 2023

This is needed to enable filecoin-project/lotus#10316

@cryptonemo
Copy link
Collaborator

Noting this is for normal sectors, not snapdeals

@DrPeterVanNostrand
Copy link
Contributor

ELI5: Lotus wants an API for encoding/decoding of "normal" (i.e. non CC) sectors.

  • Accept a range of unsealed data and encoding key and return sealed data.
  • Accept a range of sealed data and encoding key and return unsealed data.
  • Lotus would like proofs API to accept file descriptors (e.g. to [un]sealed data and sealing keys).

@magik6k
Copy link
Author

magik6k commented Apr 3, 2023

Apparently this is quite easy to do in Go, approximate code that may work:

import (
	"github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
)

func encode(keyBytes []byte, valueBytes []byte) fr.Element {
	// Convert bytes to field elements
	key := new(fr.Element).SetBytes(keyBytes[:])
	value := new(fr.Element).SetBytes(valueBytes[:])

	// Add the field elements
	key.Add(key, value)

	return *key
}

We should probably test that + a snapdeals variant before adding rust-side APIs which may turn out to be redundant

@vmx
Copy link
Contributor

vmx commented May 26, 2023

SnapDeals decode is merged and available through the FFI via filecoin-project/filecoin-ffi#402. Normal replica encode/decode will be implemented directly in Go.

@vmx vmx closed this as completed May 26, 2023
@rjan90 rjan90 moved this from 👀 In Review to ✅ Done in Lotus-Miner-V2 Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

4 participants