Make all kzg interface functions methods on the KzgSettings struct
In the public interface, the Blob argument is just a byte slice
Make Blob a private type which contains a byte slice. The Blob constructor does the length check and returns an error if it doesn't equal self.bytes_per_blob()
Have internal functions which accept a length validatedBlob call the underlying FFI functions.
Some advantages to this approach:
No generics
Blob being just a byte slice in the public interface means that users of the library can store the Blobs in whatever container they want and don't have to do conversions before passing it to the library
All kzg functions being methods on KzgSettings is advantageous because we do the blob length validations w.r.t a given trusted setup
A Blob passed to the internal functions would be valid w.r.t the passed KzgSettings so there's less scope of shooting ourselves in the foot for any future changes.
Curious to see what you guys think @Rjected @asn-d6 @jtraglia
cc @realbigsean
This is a version of what Sean described in https://github.com/ethereum/c-kzg-4844/pull/363#issuecomment-1749509149
The changes are the following:
KzgSettings
structBlob
argument is just a byte sliceBlob
a private type which contains a byte slice. TheBlob
constructor does the length check and returns an error if it doesn't equalself.bytes_per_blob()
Blob
call the underlying FFI functions.Some advantages to this approach:
Blob
being just a byte slice in the public interface means that users of the library can store the Blobs in whatever container they want and don't have to do conversions before passing it to the libraryKzgSettings
is advantageous because we do the blob length validations w.r.t a given trusted setupBlob
passed to the internal functions would be valid w.r.t the passedKzgSettings
so there's less scope of shooting ourselves in the foot for any future changes.Curious to see what you guys think @Rjected @asn-d6 @jtraglia cc @realbigsean