refactor(crypto): simplify elliptic curve implementation

This commit is contained in:
Prad Nukala
2025-10-09 15:11:59 -04:00
parent a934caa7d3
commit 7d339ae522
205 changed files with 380 additions and 380 deletions
+5 -5
View File
@@ -5,11 +5,11 @@ import (
"github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/core/protocol"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/refresh"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/sign"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/core/protocol"
"github.com/sonr-io/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/crypto/tecdsa/dklsv1/refresh"
"github.com/sonr-io/crypto/tecdsa/dklsv1/sign"
)
// AliceDkg DKLS DKG implementation that satisfies the protocol iterator interface.
+4 -4
View File
@@ -15,10 +15,10 @@ import (
"github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/ot/base/simplest"
"github.com/sonr-io/sonr/crypto/ot/extension/kos"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/ot/base/simplest"
"github.com/sonr-io/crypto/ot/extension/kos"
"github.com/sonr-io/crypto/tecdsa/dklsv1/dkg"
)
// GenerateAndDeal produces private key material for alice and bob which they can later use in signing.
+3 -3
View File
@@ -6,9 +6,9 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/dealer"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/sign"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/tecdsa/dklsv1/dealer"
"github.com/sonr-io/crypto/tecdsa/dklsv1/sign"
)
func Test_DealerCanGenerateKeysThatSign(t *testing.T) {
+4 -4
View File
@@ -15,10 +15,10 @@ import (
"github.com/gtank/merlin"
"github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/ot/base/simplest"
"github.com/sonr-io/sonr/crypto/ot/extension/kos"
"github.com/sonr-io/sonr/crypto/zkp/schnorr"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/ot/base/simplest"
"github.com/sonr-io/crypto/ot/extension/kos"
"github.com/sonr-io/crypto/zkp/schnorr"
)
// AliceOutput is the result of running DKG for Alice. It contains both the public and secret values that are needed
+2 -2
View File
@@ -12,8 +12,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/ot/extension/kos"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/ot/extension/kos"
)
func TestDkg(t *testing.T) {
+5 -5
View File
@@ -6,11 +6,11 @@ import (
"github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/core/protocol"
"github.com/sonr-io/sonr/crypto/ot/base/simplest"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/sonr/crypto/zkp/schnorr"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/core/protocol"
"github.com/sonr-io/crypto/ot/base/simplest"
"github.com/sonr-io/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/crypto/zkp/schnorr"
)
const payloadKey = "direct"
+1 -1
View File
@@ -3,7 +3,7 @@
package dklsv1
import (
"github.com/sonr-io/sonr/crypto/core/protocol"
"github.com/sonr-io/crypto/core/protocol"
)
// Basic protocol interface implementation that calls the next step func in a pre-defined list
+4 -4
View File
@@ -13,10 +13,10 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/core/protocol"
"github.com/sonr-io/sonr/crypto/ot/extension/kos"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/core/protocol"
"github.com/sonr-io/crypto/ot/extension/kos"
"github.com/sonr-io/crypto/tecdsa/dklsv1/dkg"
)
// For DKG bob starts first. For refresh and sign, Alice starts first.
+5 -5
View File
@@ -19,11 +19,11 @@ import (
"github.com/gtank/merlin"
"github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/ot/base/simplest"
"github.com/sonr-io/sonr/crypto/ot/extension/kos"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/sonr/crypto/zkp/schnorr"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/ot/base/simplest"
"github.com/sonr-io/crypto/ot/extension/kos"
"github.com/sonr-io/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/crypto/zkp/schnorr"
)
// Alice struct encoding Alice's state during one execution of the overall signing algorithm.
+5 -5
View File
@@ -13,11 +13,11 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/ot/extension/kos"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/refresh"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/sign"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/ot/extension/kos"
"github.com/sonr-io/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/crypto/tecdsa/dklsv1/refresh"
"github.com/sonr-io/crypto/tecdsa/dklsv1/sign"
)
func performDKG(t *testing.T, curve *curves.Curve) (*dkg.Alice, *dkg.Bob) {
+5 -5
View File
@@ -6,11 +6,11 @@ import (
"github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/core/protocol"
"github.com/sonr-io/sonr/crypto/ot/base/simplest"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/refresh"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/core/protocol"
"github.com/sonr-io/crypto/ot/base/simplest"
"github.com/sonr-io/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/crypto/tecdsa/dklsv1/refresh"
)
func newRefreshProtocolMessage(payload []byte, round string, version uint) *protocol.Message {
+4 -4
View File
@@ -16,10 +16,10 @@ import (
"github.com/pkg/errors"
"golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/internal"
"github.com/sonr-io/sonr/crypto/ot/base/simplest"
"github.com/sonr-io/sonr/crypto/ot/extension/kos"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/internal"
"github.com/sonr-io/crypto/ot/base/simplest"
"github.com/sonr-io/crypto/ot/extension/kos"
)
// This implements the Multiplication protocol of DKLs, protocol 5. https://eprint.iacr.org/2018/499.pdf
+4 -4
View File
@@ -12,10 +12,10 @@ import (
"github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/ot/base/simplest"
"github.com/sonr-io/sonr/crypto/ot/extension/kos"
"github.com/sonr-io/sonr/crypto/ot/ottest"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/ot/base/simplest"
"github.com/sonr-io/crypto/ot/extension/kos"
"github.com/sonr-io/crypto/ot/ottest"
)
func TestMultiply(t *testing.T) {
+5 -5
View File
@@ -20,11 +20,11 @@ import (
"github.com/pkg/errors"
"golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/ot/base/simplest"
"github.com/sonr-io/sonr/crypto/ot/extension/kos"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/sonr/crypto/zkp/schnorr"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/ot/base/simplest"
"github.com/sonr-io/crypto/ot/extension/kos"
"github.com/sonr-io/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/crypto/zkp/schnorr"
)
const multiplicationCount = 2
+5 -5
View File
@@ -13,11 +13,11 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/ot/base/simplest"
"github.com/sonr-io/sonr/crypto/ot/extension/kos"
"github.com/sonr-io/sonr/crypto/ot/ottest"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/dkg"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/ot/base/simplest"
"github.com/sonr-io/crypto/ot/extension/kos"
"github.com/sonr-io/crypto/ot/ottest"
"github.com/sonr-io/crypto/tecdsa/dklsv1/dkg"
)
func TestSign(t *testing.T) {
+3 -3
View File
@@ -6,9 +6,9 @@ import (
"github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/core/protocol"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/sign"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/core/protocol"
"github.com/sonr-io/crypto/tecdsa/dklsv1/sign"
)
func newSignProtocolMessage(payload []byte, round string, version uint) *protocol.Message {