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
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"errors"
"fmt"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/signatures/common"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/signatures/common"
)
// BlindSignature is a BBS+ blind signature
+3 -3
View File
@@ -14,9 +14,9 @@ import (
"github.com/gtank/merlin"
"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/signatures/common"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/internal"
"github.com/sonr-io/crypto/signatures/common"
)
// BlindSignatureContext contains the data used for computing
@@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
func TestBlindSignatureContext(t *testing.T) {
+1 -1
View File
@@ -9,7 +9,7 @@ package bbs
import (
"errors"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
// MessageGenerators are used to sign a vector of commitments for
+2 -2
View File
@@ -12,8 +12,8 @@ import (
"github.com/gtank/merlin"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/signatures/common"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/signatures/common"
)
// PokSignature a.k.a. Proof of Knowledge of a Signature
+2 -2
View File
@@ -12,8 +12,8 @@ import (
"github.com/gtank/merlin"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/signatures/common"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/signatures/common"
)
// PokSignatureProof is the actual proof sent from a prover
+2 -2
View File
@@ -13,8 +13,8 @@ import (
"github.com/gtank/merlin"
"github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/signatures/common"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/signatures/common"
)
func TestPokSignatureProofSomeMessagesRevealed(t *testing.T) {
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"errors"
"fmt"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
// PublicKey is a BBS+ verification key
+1 -1
View File
@@ -16,7 +16,7 @@ import (
"golang.org/x/crypto/hkdf"
"golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
// SecretKey is a BBS+ signing key
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"errors"
"fmt"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
// Signature is a BBS+ signature
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
func TestSignatureWorks(t *testing.T) {
+5 -5
View File
@@ -15,11 +15,11 @@ import (
"golang.org/x/crypto/hkdf"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381"
"github.com/sonr-io/sonr/crypto/internal"
"github.com/sonr-io/sonr/crypto/sharing"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/crypto/core/curves/native/bls12381"
"github.com/sonr-io/crypto/internal"
"github.com/sonr-io/crypto/sharing"
)
// Secret key in Fr
+2 -2
View File
@@ -13,8 +13,8 @@ import (
"math/big"
"testing"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381"
"github.com/sonr-io/sonr/crypto/internal"
"github.com/sonr-io/crypto/core/curves/native/bls12381"
"github.com/sonr-io/crypto/internal"
)
func genSecretKey(t *testing.T) *SecretKey {
+3 -3
View File
@@ -9,9 +9,9 @@ package bls_sig
import (
"fmt"
"github.com/sonr-io/sonr/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381"
"github.com/sonr-io/sonr/crypto/internal"
"github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/crypto/core/curves/native/bls12381"
"github.com/sonr-io/crypto/internal"
)
// Implement BLS signatures on the BLS12-381 curve
@@ -9,7 +9,7 @@ package bls_sig
import (
"testing"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381"
"github.com/sonr-io/crypto/core/curves/native/bls12381"
)
func generateAugSignatureG1(sk *SecretKey, msg []byte, t *testing.T) *SignatureVt {
@@ -9,7 +9,7 @@ package bls_sig
import (
"testing"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381"
"github.com/sonr-io/crypto/core/curves/native/bls12381"
)
func generateBasicSignatureG1(sk *SecretKey, msg []byte, t *testing.T) *SignatureVt {
@@ -12,7 +12,7 @@ import (
"math/rand"
"testing"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381"
"github.com/sonr-io/crypto/core/curves/native/bls12381"
)
const numAggregateG1 = 10
+3 -3
View File
@@ -9,9 +9,9 @@ package bls_sig
import (
"fmt"
"github.com/sonr-io/sonr/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381"
"github.com/sonr-io/sonr/crypto/internal"
"github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/crypto/core/curves/native/bls12381"
"github.com/sonr-io/crypto/internal"
)
// Implement BLS signatures on the BLS12-381 curve
@@ -9,7 +9,7 @@ package bls_sig
import (
"testing"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381"
"github.com/sonr-io/crypto/core/curves/native/bls12381"
)
func generateAugSignatureG2(sk *SecretKey, msg []byte, t *testing.T) *Signature {
@@ -9,7 +9,7 @@ package bls_sig
import (
"testing"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381"
"github.com/sonr-io/crypto/core/curves/native/bls12381"
)
func generateBasicSignatureG2(sk *SecretKey, msg []byte, t *testing.T) *Signature {
@@ -12,7 +12,7 @@ import (
"math/rand"
"testing"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381"
"github.com/sonr-io/crypto/core/curves/native/bls12381"
)
const numAggregateG2 = 10
+1 -1
View File
@@ -14,7 +14,7 @@ import (
"fmt"
"os"
bls "github.com/sonr-io/sonr/crypto/signatures/bls/bls_sig"
bls "github.com/sonr-io/crypto/signatures/bls/bls_sig"
)
type signOp struct {
+1 -1
View File
@@ -7,7 +7,7 @@
package common
import (
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
// Challenge generated by fiat-shamir heuristic
+1 -1
View File
@@ -7,7 +7,7 @@
package common
import (
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
// Commitment represents a point Pedersen commitment of one or more
+1 -1
View File
@@ -7,7 +7,7 @@
package common
import (
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
// Nonce is used for zero-knowledge proofs to prevent replay attacks
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"fmt"
"io"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
const limit = 65535
+1 -1
View File
@@ -9,7 +9,7 @@ package common
import (
"io"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
// ProofMessage classifies how a message is presented in a proof
+1 -1
View File
@@ -7,7 +7,7 @@
package common
import (
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
// SignatureBlinding is a value used for computing blind signatures
+1 -1
View File
@@ -9,7 +9,7 @@ package mina
import (
"fmt"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
type MinaTSchnorrHandler struct{}
+3 -3
View File
@@ -17,9 +17,9 @@ import (
"github.com/mr-tron/base58"
"golang.org/x/crypto/blake2b"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fp"
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fq"
"github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves/native/pasta/fp"
"github.com/sonr-io/crypto/core/curves/native/pasta/fq"
)
const (
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fq"
"github.com/sonr-io/crypto/core/curves/native/pasta/fq"
)
func TestNewKeys(t *testing.T) {
+1 -1
View File
@@ -7,7 +7,7 @@
package mina
import (
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fp"
"github.com/sonr-io/crypto/core/curves/native/pasta/fp"
)
// SBox is the type of exponentiation to perform
+2 -2
View File
@@ -7,8 +7,8 @@
package mina
import (
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fp"
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fq"
"github.com/sonr-io/crypto/core/curves/native/pasta/fp"
"github.com/sonr-io/crypto/core/curves/native/pasta/fq"
)
type Context struct {
@@ -12,8 +12,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fp"
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fq"
"github.com/sonr-io/crypto/core/curves/native/pasta/fp"
"github.com/sonr-io/crypto/core/curves/native/pasta/fq"
)
func TestPoseidonHash(t *testing.T) {
+2 -2
View File
@@ -7,8 +7,8 @@
package mina
import (
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fp"
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fq"
"github.com/sonr-io/crypto/core/curves/native/pasta/fp"
"github.com/sonr-io/crypto/core/curves/native/pasta/fq"
)
// Handles the packing of bits and fields according to Mina spec
+2 -2
View File
@@ -9,8 +9,8 @@ package mina
import (
"fmt"
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fp"
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fq"
"github.com/sonr-io/crypto/core/curves/native/pasta/fp"
"github.com/sonr-io/crypto/core/curves/native/pasta/fq"
)
// Signature is a Mina compatible signature either for payment or delegation
+1 -1
View File
@@ -13,7 +13,7 @@ import (
"github.com/cosmos/btcutil/base58"
"github.com/sonr-io/sonr/crypto/core/curves"
"github.com/sonr-io/crypto/core/curves"
)
// Transaction is a Mina transaction for payments or delegations
+1 -1
View File
@@ -27,7 +27,7 @@ import (
"filippo.io/edwards25519"
"golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/internal"
"github.com/sonr-io/crypto/internal"
)
const (