diff --git a/bindings/go/blst.go b/bindings/go/blst.go index b0713780..0ca9a337 100644 --- a/bindings/go/blst.go +++ b/bindings/go/blst.go @@ -165,8 +165,10 @@ const BLST_SCALAR_BYTES = 256 / 8 const BLST_FP_BYTES = 384 / 8 const BLST_P1_COMPRESS_BYTES = BLST_FP_BYTES const BLST_P1_SERIALIZE_BYTES = BLST_FP_BYTES * 2 +const BLST_P1_SERIALIZE_EIP2537_BYTES = 64 * 2 const BLST_P2_COMPRESS_BYTES = BLST_FP_BYTES * 2 const BLST_P2_SERIALIZE_BYTES = BLST_FP_BYTES * 4 +const BLST_P2_SERIALIZE_EIP2537_BYTES = 128 * 2 type Scalar = C.blst_scalar type Fp = C.blst_fp @@ -1705,11 +1707,22 @@ func (p1 *P1Affine) Serialize() []byte { return out[:] } +func (p1 *P1Affine) SerializeEip2537() []byte { + var out [BLST_P1_SERIALIZE_EIP2537_BYTES]byte + C.blst_p1_affine_serialize_eip2537((*C.byte)(&out[0]), p1) + return out[:] +} + func (p1 *P1Affine) Deserialize(in []byte) *P1Affine { - if len(in) != BLST_P1_SERIALIZE_BYTES { - return nil - } - if C.blst_p1_deserialize(p1, (*C.byte)(&in[0])) != C.BLST_SUCCESS { + if len(in) == BLST_P1_SERIALIZE_BYTES { + if C.blst_p1_deserialize(p1, (*C.byte)(&in[0])) != C.BLST_SUCCESS { + return nil + } + } else if len(in) == BLST_P1_SERIALIZE_EIP2537_BYTES { + if C.blst_p1_deserialize_eip2537(p1, (*C.byte)(&in[0])) != C.BLST_SUCCESS { + return nil + } + } else { return nil } return p1 @@ -1797,6 +1810,11 @@ func (p1 *P1) Serialize() []byte { C.blst_p1_serialize((*C.byte)(&out[0]), p1) return out[:] } +func (p1 *P1) SerializeEip2537() []byte { + var out [BLST_P1_SERIALIZE_EIP2537_BYTES]byte + C.blst_p1_serialize_eip2537((*C.byte)(&out[0]), p1) + return out[:] +} func (p1 *P1) Compress() []byte { var out [BLST_P1_COMPRESS_BYTES]byte C.blst_p1_compress((*C.byte)(&out[0]), p1) @@ -2367,11 +2385,22 @@ func (p2 *P2Affine) Serialize() []byte { return out[:] } +func (p2 *P2Affine) SerializeEip2537() []byte { + var out [BLST_P2_SERIALIZE_EIP2537_BYTES]byte + C.blst_p2_affine_serialize_eip2537((*C.byte)(&out[0]), p2) + return out[:] +} + func (p2 *P2Affine) Deserialize(in []byte) *P2Affine { - if len(in) != BLST_P2_SERIALIZE_BYTES { - return nil - } - if C.blst_p2_deserialize(p2, (*C.byte)(&in[0])) != C.BLST_SUCCESS { + if len(in) == BLST_P2_SERIALIZE_BYTES { + if C.blst_p2_deserialize(p2, (*C.byte)(&in[0])) != C.BLST_SUCCESS { + return nil + } + } else if len(in) == BLST_P2_SERIALIZE_EIP2537_BYTES { + if C.blst_p2_deserialize_eip2537(p2, (*C.byte)(&in[0])) != C.BLST_SUCCESS { + return nil + } + } else { return nil } return p2 @@ -2459,6 +2488,11 @@ func (p2 *P2) Serialize() []byte { C.blst_p2_serialize((*C.byte)(&out[0]), p2) return out[:] } +func (p2 *P2) SerializeEip2537() []byte { + var out [BLST_P2_SERIALIZE_EIP2537_BYTES]byte + C.blst_p2_serialize_eip2537((*C.byte)(&out[0]), p2) + return out[:] +} func (p2 *P2) Compress() []byte { var out [BLST_P2_COMPRESS_BYTES]byte C.blst_p2_compress((*C.byte)(&out[0]), p2) diff --git a/bindings/go/blst.tgo b/bindings/go/blst.tgo index 32887e06..a42592e7 100644 --- a/bindings/go/blst.tgo +++ b/bindings/go/blst.tgo @@ -155,8 +155,10 @@ const BLST_SCALAR_BYTES = 256 / 8 const BLST_FP_BYTES = 384 / 8 const BLST_P1_COMPRESS_BYTES = BLST_FP_BYTES const BLST_P1_SERIALIZE_BYTES = BLST_FP_BYTES * 2 +const BLST_P1_SERIALIZE_EIP2537_BYTES = 64 * 2 const BLST_P2_COMPRESS_BYTES = BLST_FP_BYTES * 2 const BLST_P2_SERIALIZE_BYTES = BLST_FP_BYTES * 4 +const BLST_P2_SERIALIZE_EIP2537_BYTES = 128 * 2 type Scalar = C.blst_scalar type Fp = C.blst_fp diff --git a/bindings/go/blst_px.tgo b/bindings/go/blst_px.tgo index 187d79d3..bb9d5d56 100644 --- a/bindings/go/blst_px.tgo +++ b/bindings/go/blst_px.tgo @@ -45,11 +45,22 @@ func (p1 *P1Affine) Serialize() []byte { return out[:] } +func (p1 *P1Affine) SerializeEip2537() []byte { + var out [BLST_P1_SERIALIZE_EIP2537_BYTES]byte + C.blst_p1_affine_serialize_eip2537((*C.byte)(&out[0]), p1) + return out[:] +} + func (p1 *P1Affine) Deserialize(in []byte) *P1Affine { - if len(in) != BLST_P1_SERIALIZE_BYTES { - return nil - } - if C.blst_p1_deserialize(p1, (*C.byte)(&in[0])) != C.BLST_SUCCESS { + if len(in) == BLST_P1_SERIALIZE_BYTES { + if C.blst_p1_deserialize(p1, (*C.byte)(&in[0])) != C.BLST_SUCCESS { + return nil + } + } else if len(in) == BLST_P1_SERIALIZE_EIP2537_BYTES { + if C.blst_p1_deserialize_eip2537(p1, (*C.byte)(&in[0])) != C.BLST_SUCCESS { + return nil + } + } else { return nil } return p1 @@ -137,6 +148,11 @@ func (p1 *P1) Serialize() []byte { C.blst_p1_serialize((*C.byte)(&out[0]), p1) return out[:] } +func (p1 *P1) SerializeEip2537() []byte { + var out [BLST_P1_SERIALIZE_EIP2537_BYTES]byte + C.blst_p1_serialize_eip2537((*C.byte)(&out[0]), p1) + return out[:] +} func (p1 *P1) Compress() []byte { var out [BLST_P1_COMPRESS_BYTES]byte C.blst_p1_compress((*C.byte)(&out[0]), p1) diff --git a/bindings/go/generate.py b/bindings/go/generate.py index d40fad21..57e43880 100755 --- a/bindings/go/generate.py +++ b/bindings/go/generate.py @@ -81,7 +81,7 @@ def remap(fout, fin, mapping, dont_touch, removeImports): # These are strings that overlap with the mapping names but we don't # actually want to change. The second value should be a unique string. -dont_touch = (('Fp12', 'foo1234'),) +dont_touch = (('Fp12', 'foo1234'), ('2537', 'bar1234')) # We're going to swap these names to get from min-pk to min-sig mapping = [('P1', 'P2'),