Skip to content

Commit

Permalink
Feat/write point slice ptr (#585)
Browse files Browse the repository at this point in the history
Co-authored-by: Arya Tabaie <[email protected]>
  • Loading branch information
Tabaie and Tabaie authored Dec 21, 2024
1 parent 97d69dc commit f08f759
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 9 deletions.
10 changes: 9 additions & 1 deletion ecc/bls12-377/marshal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion ecc/bls12-381/marshal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion ecc/bls24-315/marshal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion ecc/bls24-317/marshal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion ecc/bn254/marshal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion ecc/bw6-633/marshal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion ecc/bw6-761/marshal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ecc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ func getVector(l *Lattice, a, b *big.Int) [2]big.Int {
return res
}

// NextPowerOfTwo returns the next power of 2 of n
// NextPowerOfTwo(n) = 2^⌈log₂(n)⌉
// or 2ᵏ where 2ᵏ⁻¹ < n ≤ 2ᵏ
func NextPowerOfTwo(n uint64) uint64 {
c := bits.OnesCount64(n)
if c == 0 {
Expand Down
6 changes: 5 additions & 1 deletion internal/generator/ecc/template/marshal.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func NewEncoder(w io.Writer, options ...func(*Encoder)) *Encoder {


// Encode writes the binary encoding of v to the stream
// type must be uint64, *fr.Element, *fp.Element, *G1Affine, *G2Affine, []G1Affine or []G2Affine
// type must be uint64, *fr.Element, *fp.Element, *G1Affine, *G2Affine, []G1Affine, []G2Affine, *[]G1Affine or *[]G2Affine
func (enc *Encoder) Encode(v interface{}) (err error) {
if enc.raw {
return enc.encodeRaw(v)
Expand Down Expand Up @@ -645,6 +645,8 @@ func (enc *Encoder) encode{{- $.Raw}}(v interface{}) (err error) {
}
}
return
case *[]G1Affine:
return enc.encode{{- $.Raw}}(*t)
case []G1Affine:
// write slice length
err = binary.Write(enc.w, binary.BigEndian, uint32(len(t)))
Expand All @@ -664,6 +666,8 @@ func (enc *Encoder) encode{{- $.Raw}}(v interface{}) (err error) {
}
}
return nil
case *[]G2Affine:
return enc.encode{{- $.Raw}}(*t)
case []G2Affine:
// write slice length
err = binary.Write(enc.w, binary.BigEndian, uint32(len(t)))
Expand Down

0 comments on commit f08f759

Please sign in to comment.