mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
add json decoding for kzg types
This commit is contained in:
parent
e5d5e09faa
commit
d299d770b0
1 changed files with 24 additions and 0 deletions
|
|
@ -20,21 +20,45 @@ package kzg4844
|
|||
import (
|
||||
"embed"
|
||||
"errors"
|
||||
"reflect"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
)
|
||||
|
||||
//go:embed trusted_setup.json
|
||||
var content embed.FS
|
||||
|
||||
var (
|
||||
blobT = reflect.TypeOf(Blob{})
|
||||
commitmentT = reflect.TypeOf(Commitment{})
|
||||
proofT = reflect.TypeOf(Proof{})
|
||||
)
|
||||
|
||||
// Blob represents a 4844 data blob.
|
||||
type Blob [131072]byte
|
||||
|
||||
// UnmarshalJSON parses a blob in hex syntax.
|
||||
func (b *Blob) UnmarshalJSON(input []byte) error {
|
||||
return hexutil.UnmarshalFixedJSON(blobT, input, b[:])
|
||||
}
|
||||
|
||||
// Commitment is a serialized commitment to a polynomial.
|
||||
type Commitment [48]byte
|
||||
|
||||
// UnmarshalJSON parses a commitment in hex syntax.
|
||||
func (c *Commitment) UnmarshalJSON(input []byte) error {
|
||||
return hexutil.UnmarshalFixedJSON(commitmentT, input, c[:])
|
||||
}
|
||||
|
||||
// Proof is a serialized commitment to the quotient polynomial.
|
||||
type Proof [48]byte
|
||||
|
||||
// UnmarshalJSON parses a proof in hex syntax.
|
||||
func (p *Proof) UnmarshalJSON(input []byte) error {
|
||||
return hexutil.UnmarshalFixedJSON(proofT, input, p[:])
|
||||
}
|
||||
|
||||
// Point is a BLS field element.
|
||||
type Point [32]byte
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue