From d0f322364554048163b6bcaaf507171690fa241b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 23 Sep 2024 09:35:44 +0000 Subject: [PATCH] Replace embedded Groups with type assertions (#550) These were always nil and likely unintentional (I assume it started out as a way to mock unimplemented interface methods?). It doesn't matter much because these suites all implement `kyber.Group`, but any changes to `kyber.Group` would have added panicing methods to these suites without any type errors. Co-authored-by: AnomalRoil --- pairing/bls12381/circl/adapter.go | 3 ++- pairing/bls12381/kilic/adapter.go | 3 ++- pairing/bn254/adapter.go | 3 ++- pairing/bn256/adapter.go | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pairing/bls12381/circl/adapter.go b/pairing/bls12381/circl/adapter.go index 1e51aa2ad..bf0f576c7 100644 --- a/pairing/bls12381/circl/adapter.go +++ b/pairing/bls12381/circl/adapter.go @@ -13,9 +13,10 @@ import ( // used as a point from the group G1. type SuiteBLS12381 struct { Suite - kyber.Group } +var _ kyber.Group = (*SuiteBLS12381)(nil) + // NewSuiteBLS12381 makes a new BN256 suite func NewSuiteBLS12381() *SuiteBLS12381 { return &SuiteBLS12381{} diff --git a/pairing/bls12381/kilic/adapter.go b/pairing/bls12381/kilic/adapter.go index d7e0975d7..57414d0af 100644 --- a/pairing/bls12381/kilic/adapter.go +++ b/pairing/bls12381/kilic/adapter.go @@ -13,9 +13,10 @@ import ( // used as a point from the group G1. type SuiteBLS12381 struct { Suite - kyber.Group } +var _ kyber.Group = (*SuiteBLS12381)(nil) + // NewSuiteBLS12381 makes a new BN256 suite func NewSuiteBLS12381() *SuiteBLS12381 { return &SuiteBLS12381{} diff --git a/pairing/bn254/adapter.go b/pairing/bn254/adapter.go index e8116180a..77ae0cae5 100644 --- a/pairing/bn254/adapter.go +++ b/pairing/bn254/adapter.go @@ -13,9 +13,10 @@ import ( // used as a point from the group G1. type SuiteBn254 struct { *Suite - kyber.Group } +var _ kyber.Group = (*SuiteBn254)(nil) + // NewSuiteBn254 makes a new BN254 suite func NewSuiteBn254() *SuiteBn254 { return &SuiteBn254{ diff --git a/pairing/bn256/adapter.go b/pairing/bn256/adapter.go index 45ed25a80..62899bc0c 100644 --- a/pairing/bn256/adapter.go +++ b/pairing/bn256/adapter.go @@ -13,9 +13,10 @@ import ( // used as a point from the group G1. type SuiteBn256 struct { *Suite - kyber.Group } +var _ kyber.Group = (*SuiteBn256)(nil) + // NewSuiteBn256 makes a new BN256 suite func NewSuiteBn256() *SuiteBn256 { return &SuiteBn256{