mirror of
https://github.com/sonr-io/crypto.git
synced 2026-08-02 15:31:38 +00:00
refactor(crypto): simplify elliptic curve implementation
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user