refactor(crypto): simplify elliptic curve implementation

This commit is contained in:
2025-10-09 15:11:59 -04:00
parent a934caa7d3
commit 7d339ae522
205 changed files with 380 additions and 380 deletions

View File

@@ -16,7 +16,7 @@ import (
"git.sr.ht/~sircmpwn/go-bare" "git.sr.ht/~sircmpwn/go-bare"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
type structMarshal struct { type structMarshal struct {

View File

@@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func TestNewAccumulator100(t *testing.T) { func TestNewAccumulator100(t *testing.T) {

View File

@@ -12,7 +12,7 @@ import (
"git.sr.ht/~sircmpwn/go-bare" "git.sr.ht/~sircmpwn/go-bare"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
// SecretKey is the secret alpha only held by the accumulator manager. // SecretKey is the secret alpha only held by the accumulator manager.

View File

@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func TestSecretKeyMarshal(t *testing.T) { func TestSecretKeyMarshal(t *testing.T) {

View File

@@ -10,7 +10,7 @@ import (
"fmt" "fmt"
"math" "math"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
// dad constructs two polynomials - dA(x) and dD(x) // dad constructs two polynomials - dA(x) and dD(x)

View File

@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func TestEvaluatePolyG1(t *testing.T) { func TestEvaluatePolyG1(t *testing.T) {

View File

@@ -14,7 +14,7 @@ import (
"git.sr.ht/~sircmpwn/go-bare" "git.sr.ht/~sircmpwn/go-bare"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
type proofParamsMarshal struct { type proofParamsMarshal struct {

View File

@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func TestProofParamsMarshal(t *testing.T) { func TestProofParamsMarshal(t *testing.T) {

View File

@@ -12,7 +12,7 @@ import (
"git.sr.ht/~sircmpwn/go-bare" "git.sr.ht/~sircmpwn/go-bare"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
// MembershipWitness contains the witness c and the value y respect to the accumulator state. // MembershipWitness contains the witness c and the value y respect to the accumulator state.

View File

@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func Test_Membership_Witness_New(t *testing.T) { func Test_Membership_Witness_New(t *testing.T) {

View File

@@ -10,7 +10,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
// generators contains a list of points to be used as generators for bulletproofs. // generators contains a list of points to be used as generators for bulletproofs.

View File

@@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func TestGeneratorsHappyPath(t *testing.T) { func TestGeneratorsHappyPath(t *testing.T) {

View File

@@ -9,7 +9,7 @@ package bulletproof
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
// innerProduct takes two lists of scalars (a, b) and performs the dot product returning a single scalar. // innerProduct takes two lists of scalars (a, b) and performs the dot product returning a single scalar.

View File

@@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func TestInnerProductHappyPath(t *testing.T) { func TestInnerProductHappyPath(t *testing.T) {

View File

@@ -11,7 +11,7 @@ import (
"github.com/gtank/merlin" "github.com/gtank/merlin"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
// InnerProductProver is the struct used to create InnerProductProofs // InnerProductProver is the struct used to create InnerProductProofs

View File

@@ -7,7 +7,7 @@ import (
"github.com/gtank/merlin" "github.com/gtank/merlin"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func TestIPPHappyPath(t *testing.T) { func TestIPPHappyPath(t *testing.T) {

View File

@@ -4,7 +4,7 @@ import (
"github.com/gtank/merlin" "github.com/gtank/merlin"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
// InnerProductVerifier is the struct used to verify inner product proofs // InnerProductVerifier is the struct used to verify inner product proofs

View File

@@ -7,7 +7,7 @@ import (
"github.com/gtank/merlin" "github.com/gtank/merlin"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func TestIPPVerifyHappyPath(t *testing.T) { func TestIPPVerifyHappyPath(t *testing.T) {

View File

@@ -6,7 +6,7 @@ import (
"github.com/gtank/merlin" "github.com/gtank/merlin"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
// BatchProve proves that a list of scalars v are in the range n. // BatchProve proves that a list of scalars v are in the range n.

View File

@@ -7,7 +7,7 @@ import (
"github.com/gtank/merlin" "github.com/gtank/merlin"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func TestRangeBatchProverHappyPath(t *testing.T) { func TestRangeBatchProverHappyPath(t *testing.T) {

View File

@@ -4,7 +4,7 @@ import (
"github.com/gtank/merlin" "github.com/gtank/merlin"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
// VerifyBatched verifies a given batched range proof. // VerifyBatched verifies a given batched range proof.

View File

@@ -7,7 +7,7 @@ import (
"github.com/gtank/merlin" "github.com/gtank/merlin"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func TestRangeBatchVerifyHappyPath(t *testing.T) { func TestRangeBatchVerifyHappyPath(t *testing.T) {

View File

@@ -14,7 +14,7 @@ import (
"github.com/gtank/merlin" "github.com/gtank/merlin"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
// RangeProver is the struct used to create RangeProofs // RangeProver is the struct used to create RangeProofs

View File

@@ -7,7 +7,7 @@ import (
"github.com/gtank/merlin" "github.com/gtank/merlin"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func TestRangeProverHappyPath(t *testing.T) { func TestRangeProverHappyPath(t *testing.T) {

View File

@@ -4,7 +4,7 @@ import (
"github.com/gtank/merlin" "github.com/gtank/merlin"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
// RangeVerifier is the struct used to verify RangeProofs // RangeVerifier is the struct used to verify RangeProofs

View File

@@ -7,7 +7,7 @@ import (
"github.com/gtank/merlin" "github.com/gtank/merlin"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
func TestRangeVerifyHappyPath(t *testing.T) { func TestRangeVerifyHappyPath(t *testing.T) {

View File

@@ -19,7 +19,7 @@ import (
bls12377 "github.com/consensys/gnark-crypto/ecc/bls12-377" bls12377 "github.com/consensys/gnark-crypto/ecc/bls12-377"
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/core" "github.com/sonr-io/crypto/core"
) )
// See 'r' = https://eprint.iacr.org/2018/962.pdf Figure 16 // See 'r' = https://eprint.iacr.org/2018/962.pdf Figure 16

View File

@@ -13,9 +13,9 @@ import (
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381" "github.com/sonr-io/crypto/core/curves/native/bls12381"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
var bls12381modulus = bhex( var bls12381modulus = bhex(

View File

@@ -16,7 +16,7 @@ import (
"math/big" "math/big"
"sync" "sync"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381" "github.com/sonr-io/crypto/core/curves/native/bls12381"
) )
var ( var (

View File

@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core" "github.com/sonr-io/crypto/core"
) )
// TestAdditionalCurveSupport tests the new curve support in hash.go // TestAdditionalCurveSupport tests the new curve support in hash.go

View File

@@ -12,10 +12,10 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/sonr-io/sonr/crypto/core" "github.com/sonr-io/crypto/core"
"github.com/dustinxie/ecc" "github.com/dustinxie/ecc"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
var curveNameToID = map[string]byte{ var curveNameToID = map[string]byte{

View File

@@ -15,8 +15,8 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core" "github.com/sonr-io/crypto/core"
tt "github.com/sonr-io/sonr/crypto/internal" tt "github.com/sonr-io/crypto/internal"
) )
func TestIsIdentity(t *testing.T) { func TestIsIdentity(t *testing.T) {

View File

@@ -18,9 +18,9 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/bwesterb/go-ristretto" "github.com/bwesterb/go-ristretto"
"github.com/sonr-io/sonr/crypto/core" "github.com/sonr-io/crypto/core"
"github.com/sonr-io/sonr/crypto/core/curves/native/bls12381" "github.com/sonr-io/crypto/core/curves/native/bls12381"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
type EcScalar interface { type EcScalar interface {

View File

@@ -19,7 +19,7 @@ import (
"github.com/bwesterb/go-ristretto" "github.com/bwesterb/go-ristretto"
ed "github.com/bwesterb/go-ristretto/edwards25519" ed "github.com/bwesterb/go-ristretto/edwards25519"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
type ScalarEd25519 struct { type ScalarEd25519 struct {

View File

@@ -15,7 +15,7 @@ import (
ed "filippo.io/edwards25519" ed "filippo.io/edwards25519"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
func TestScalarEd25519Random(t *testing.T) { func TestScalarEd25519Random(t *testing.T) {

View File

@@ -9,8 +9,8 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
mod "github.com/sonr-io/sonr/crypto/core" mod "github.com/sonr-io/crypto/core"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
func BenchmarkK256(b *testing.B) { func BenchmarkK256(b *testing.B) {

View File

@@ -15,11 +15,11 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
secp256k1 "github.com/sonr-io/sonr/crypto/core/curves/native/k256" secp256k1 "github.com/sonr-io/crypto/core/curves/native/k256"
"github.com/sonr-io/sonr/crypto/core/curves/native/k256/fp" "github.com/sonr-io/crypto/core/curves/native/k256/fp"
"github.com/sonr-io/sonr/crypto/core/curves/native/k256/fq" "github.com/sonr-io/crypto/core/curves/native/k256/fq"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
var ( var (

View File

@@ -3,7 +3,7 @@ package bls12381
import ( import (
"math/bits" "math/bits"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
) )
var fqModulusBytes = [native.FieldBytes]byte{ var fqModulusBytes = [native.FieldBytes]byte{

View File

@@ -6,8 +6,8 @@ import (
"io" "io"
"math/big" "math/big"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
// fp field element mod p // fp field element mod p

View File

@@ -14,7 +14,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
func TestFpSetOne(t *testing.T) { func TestFpSetOne(t *testing.T) {

View File

@@ -5,7 +5,7 @@ import (
"math/big" "math/big"
"sync" "sync"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
) )
type Fq [native.FieldLimbs]uint64 type Fq [native.FieldLimbs]uint64

View File

@@ -14,8 +14,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
func TestFqSetOne(t *testing.T) { func TestFqSetOne(t *testing.T) {

View File

@@ -7,8 +7,8 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
var ( var (

View File

@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
) )
func TestG1IsOnCurve(t *testing.T) { func TestG1IsOnCurve(t *testing.T) {

View File

@@ -7,8 +7,8 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
var ( var (

View File

@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
) )
func TestG2IsOnCurve(t *testing.T) { func TestG2IsOnCurve(t *testing.T) {

View File

@@ -3,8 +3,8 @@ package bls12381
import ( import (
"io" "io"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
// GtFieldBytes is the number of bytes needed to represent this field // GtFieldBytes is the number of bytes needed to represent this field

View File

@@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
) )
func TestSinglePairing(t *testing.T) { func TestSinglePairing(t *testing.T) {

View File

@@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
// FieldLimbs is the number of limbs needed to represent this field // FieldLimbs is the number of limbs needed to represent this field

View File

@@ -10,7 +10,7 @@ import (
"math/big" "math/big"
"sync" "sync"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
) )
var ( var (

View File

@@ -14,8 +14,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
func TestFpSetOne(t *testing.T) { func TestFpSetOne(t *testing.T) {

View File

@@ -10,7 +10,7 @@ import (
"math/big" "math/big"
"sync" "sync"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
) )
var ( var (

View File

@@ -14,8 +14,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
func TestFqSetOne(t *testing.T) { func TestFqSetOne(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package k256
import ( import (
"sync" "sync"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/core/curves/native/k256/fp" "github.com/sonr-io/crypto/core/curves/native/k256/fp"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
var ( var (

View File

@@ -5,8 +5,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/core/curves/native/k256" "github.com/sonr-io/crypto/core/curves/native/k256"
) )
func TestK256PointArithmetic_Hash(t *testing.T) { func TestK256PointArithmetic_Hash(t *testing.T) {

View File

@@ -10,7 +10,7 @@ import (
"math/big" "math/big"
"sync" "sync"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
) )
var ( var (

View File

@@ -14,8 +14,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
func TestFpSetOne(t *testing.T) { func TestFpSetOne(t *testing.T) {

View File

@@ -10,7 +10,7 @@ import (
"math/big" "math/big"
"sync" "sync"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
) )
var ( var (

View File

@@ -14,8 +14,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
func TestFqSetOne(t *testing.T) { func TestFqSetOne(t *testing.T) {

View File

@@ -3,9 +3,9 @@ package p256
import ( import (
"sync" "sync"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/core/curves/native/p256/fp" "github.com/sonr-io/crypto/core/curves/native/p256/fp"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
var ( var (

View File

@@ -6,10 +6,10 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
"github.com/sonr-io/sonr/crypto/core/curves/native/p256" "github.com/sonr-io/crypto/core/curves/native/p256"
"github.com/sonr-io/sonr/crypto/core/curves/native/p256/fp" "github.com/sonr-io/crypto/core/curves/native/p256/fp"
) )
func TestP256PointArithmetic_Double(t *testing.T) { func TestP256PointArithmetic_Double(t *testing.T) {

View File

@@ -11,7 +11,7 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
type Fp fiat_pasta_fp_montgomery_domain_field_element type Fp fiat_pasta_fp_montgomery_domain_field_element

View File

@@ -11,7 +11,7 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
type Fq fiat_pasta_fq_montgomery_domain_field_element type Fq fiat_pasta_fq_montgomery_domain_field_element

View File

@@ -16,7 +16,7 @@ import (
"math/big" "math/big"
"testing" "testing"
"github.com/sonr-io/sonr/crypto/core" "github.com/sonr-io/crypto/core"
) )
func BenchmarkP256(b *testing.B) { func BenchmarkP256(b *testing.B) {

View File

@@ -13,11 +13,11 @@ import (
"math/big" "math/big"
"sync" "sync"
"github.com/sonr-io/sonr/crypto/core/curves/native" "github.com/sonr-io/crypto/core/curves/native"
p256n "github.com/sonr-io/sonr/crypto/core/curves/native/p256" p256n "github.com/sonr-io/crypto/core/curves/native/p256"
"github.com/sonr-io/sonr/crypto/core/curves/native/p256/fp" "github.com/sonr-io/crypto/core/curves/native/p256/fp"
"github.com/sonr-io/sonr/crypto/core/curves/native/p256/fq" "github.com/sonr-io/crypto/core/curves/native/p256/fq"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
var ( var (

View File

@@ -18,8 +18,8 @@ import (
"golang.org/x/crypto/blake2b" "golang.org/x/crypto/blake2b"
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fp" "github.com/sonr-io/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/fq"
) )
var ( var (

View File

@@ -12,8 +12,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves/native/pasta/fp" "github.com/sonr-io/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/fq"
) )
func TestPointPallasAddDoubleMul(t *testing.T) { func TestPointPallasAddDoubleMul(t *testing.T) {

View File

@@ -20,7 +20,7 @@ import (
"golang.org/x/crypto/hkdf" "golang.org/x/crypto/hkdf"
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
type HashField struct { type HashField struct {

View File

@@ -16,7 +16,7 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
var ( var (

View File

@@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
var ( var (

View File

@@ -8,8 +8,8 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
subtle "github.com/sonr-io/sonr/crypto/daed" subtle "github.com/sonr-io/crypto/daed"
"github.com/sonr-io/sonr/crypto/subtle/random" "github.com/sonr-io/crypto/subtle/random"
) )
type testData struct { type testData struct {

View File

@@ -15,9 +15,9 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
"github.com/sonr-io/sonr/crypto/sharing" "github.com/sonr-io/crypto/sharing"
) )
// Round1Bcast are values that are broadcast to all other participants // Round1Bcast are values that are broadcast to all other participants

View File

@@ -9,9 +9,9 @@ package frost
import ( import (
"fmt" "fmt"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
"github.com/sonr-io/sonr/crypto/sharing" "github.com/sonr-io/crypto/sharing"
) )
// Round2Bcast are values that are broadcast to all other participants // Round2Bcast are values that are broadcast to all other participants

View File

@@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/sharing" "github.com/sonr-io/crypto/sharing"
) )
var ( var (

View File

@@ -10,9 +10,9 @@ package frost
import ( import (
"strconv" "strconv"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
"github.com/sonr-io/sonr/crypto/sharing" "github.com/sonr-io/crypto/sharing"
) )
type DkgParticipant struct { type DkgParticipant struct {

View File

@@ -11,9 +11,9 @@ import (
"crypto/elliptic" "crypto/elliptic"
"fmt" "fmt"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
v1 "github.com/sonr-io/sonr/crypto/sharing/v1" v1 "github.com/sonr-io/crypto/sharing/v1"
) )
// Participant is a DKG player that contains information needed to perform DKG rounds // Participant is a DKG player that contains information needed to perform DKG rounds

View File

@@ -13,8 +13,8 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
) )
var testGenerator, _ = curves.NewScalarBaseMult(btcec.S256(), big.NewInt(3333)) var testGenerator, _ = curves.NewScalarBaseMult(btcec.S256(), big.NewInt(3333))

View File

@@ -10,9 +10,9 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/sonr-io/sonr/crypto/core" "github.com/sonr-io/crypto/core"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
v1 "github.com/sonr-io/sonr/crypto/sharing/v1" v1 "github.com/sonr-io/crypto/sharing/v1"
) )
// Round1Bcast are the values that are broadcast to all other participants // Round1Bcast are the values that are broadcast to all other participants

View File

@@ -9,8 +9,8 @@ package gennaro
import ( import (
"fmt" "fmt"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
v1 "github.com/sonr-io/sonr/crypto/sharing/v1" v1 "github.com/sonr-io/crypto/sharing/v1"
) )
type Round2Bcast = []*v1.ShareVerifier type Round2Bcast = []*v1.ShareVerifier

View File

@@ -9,8 +9,8 @@ package gennaro
import ( import (
"fmt" "fmt"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
v1 "github.com/sonr-io/sonr/crypto/sharing/v1" v1 "github.com/sonr-io/crypto/sharing/v1"
) )
// Round3Bcast contains values that will be broadcast to other participants. // Round3Bcast contains values that will be broadcast to other participants.

View File

@@ -9,10 +9,10 @@ package gennaro
import ( import (
"math/big" "math/big"
"github.com/sonr-io/sonr/crypto/core" "github.com/sonr-io/crypto/core"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/internal" "github.com/sonr-io/crypto/internal"
v1 "github.com/sonr-io/sonr/crypto/sharing/v1" v1 "github.com/sonr-io/crypto/sharing/v1"
) )
// Round4 computes the public shares used by tECDSA during signing // Round4 computes the public shares used by tECDSA during signing

View File

@@ -13,8 +13,8 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
v1 "github.com/sonr-io/sonr/crypto/sharing/v1" v1 "github.com/sonr-io/crypto/sharing/v1"
) )
func TestParticipantRound1Works(t *testing.T) { func TestParticipantRound1Works(t *testing.T) {

View File

@@ -15,9 +15,9 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/dkg/gennaro" "github.com/sonr-io/crypto/dkg/gennaro"
v1 "github.com/sonr-io/sonr/crypto/sharing/v1" v1 "github.com/sonr-io/crypto/sharing/v1"
) )
const threshold = 2 const threshold = 2

View File

@@ -15,8 +15,8 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
v1 "github.com/sonr-io/sonr/crypto/sharing/v1" v1 "github.com/sonr-io/crypto/sharing/v1"
) )
var ( var (

View File

@@ -9,7 +9,7 @@ import (
eciesgo "github.com/ecies/go/v2" eciesgo "github.com/ecies/go/v2"
"lukechampine.com/blake3" "lukechampine.com/blake3"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
type PrivateKey = eciesgo.PrivateKey type PrivateKey = eciesgo.PrivateKey

View File

@@ -5,7 +5,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/sonr-io/sonr/crypto/ecies" "github.com/sonr-io/crypto/ecies"
) )
func TestGenerateKey(t *testing.T) { func TestGenerateKey(t *testing.T) {

2
go.mod
View File

@@ -1,4 +1,4 @@
module github.com/sonr-io/sonr/crypto module github.com/sonr-io/crypto
go 1.24.7 go 1.24.7

View File

@@ -8,7 +8,7 @@ package extra25519
import ( import (
"crypto/sha512" "crypto/sha512"
"github.com/sonr-io/sonr/crypto/internal/ed25519/edwards25519" "github.com/sonr-io/crypto/internal/ed25519/edwards25519"
) )
// PrivateKeyToCurve25519 converts an ed25519 private key into a corresponding // PrivateKeyToCurve25519 converts an ed25519 private key into a corresponding

View File

@@ -10,7 +10,7 @@ import (
"crypto/sha512" "crypto/sha512"
"testing" "testing"
"github.com/sonr-io/sonr/crypto/internal/ed25519/edwards25519" "github.com/sonr-io/crypto/internal/ed25519/edwards25519"
"golang.org/x/crypto/curve25519" "golang.org/x/crypto/curve25519"
"golang.org/x/crypto/ed25519" "golang.org/x/crypto/ed25519"
) )

View File

@@ -7,7 +7,7 @@ import (
p2pcrypto "github.com/libp2p/go-libp2p/core/crypto" p2pcrypto "github.com/libp2p/go-libp2p/core/crypto"
p2ppb "github.com/libp2p/go-libp2p/core/crypto/pb" p2ppb "github.com/libp2p/go-libp2p/core/crypto/pb"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
) )

View File

@@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
) )
// getEcdsaPoint builds an elliptic curve point from a compressed byte slice // getEcdsaPoint builds an elliptic curve point from a compressed byte slice

View File

@@ -42,7 +42,7 @@ The package is built around the concept of secure **Enclaves** that manage distr
### Installation ### Installation
```bash ```bash
go get github.com/sonr-io/sonr/crypto/mpc go get github.com/sonr-io/crypto/mpc
``` ```
### Basic Usage ### Basic Usage
@@ -54,7 +54,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/sonr-io/sonr/crypto/mpc" "github.com/sonr-io/crypto/mpc"
) )
func main() { func main() {
@@ -233,7 +233,7 @@ if err != nil {
The package includes MPC-based JWT signing for UCAN tokens: The package includes MPC-based JWT signing for UCAN tokens:
```go ```go
import "github.com/sonr-io/sonr/crypto/mpc/spec" import "github.com/sonr-io/crypto/mpc/spec"
// Create MPC-backed UCAN token source // Create MPC-backed UCAN token source
// (Implementation details in spec package) // (Implementation details in spec package)
@@ -448,10 +448,10 @@ go test -cover ./crypto/mpc
## Dependencies ## Dependencies
- **Core Cryptography**: `github.com/sonr-io/sonr/crypto/core/curves` - **Core Cryptography**: `github.com/sonr-io/crypto/core/curves`
- **Protocol Framework**: `github.com/sonr-io/sonr/crypto/core/protocol` - **Protocol Framework**: `github.com/sonr-io/crypto/core/protocol`
- **Threshold ECDSA**: `github.com/sonr-io/sonr/crypto/tecdsa/dklsv1` - **Threshold ECDSA**: `github.com/sonr-io/crypto/tecdsa/dklsv1`
- **UCAN Integration**: `github.com/sonr-io/sonr/crypto/ucan` - **UCAN Integration**: `github.com/sonr-io/crypto/ucan`
- **Standard Crypto**: `golang.org/x/crypto/sha3` - **Standard Crypto**: `golang.org/x/crypto/sha3`
- **JWT Support**: `github.com/golang-jwt/jwt` - **JWT Support**: `github.com/golang-jwt/jwt`

View File

@@ -4,9 +4,9 @@ package mpc
import ( import (
"crypto/rand" "crypto/rand"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/core/protocol" "github.com/sonr-io/crypto/core/protocol"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1/dkg" "github.com/sonr-io/crypto/tecdsa/dklsv1/dkg"
) )
type CurveName string type CurveName string

View File

@@ -7,7 +7,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
) )

View File

@@ -1,8 +1,8 @@
package mpc package mpc
import ( import (
"github.com/sonr-io/sonr/crypto/core/protocol" "github.com/sonr-io/crypto/core/protocol"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1" "github.com/sonr-io/crypto/tecdsa/dklsv1"
) )
// NewEnclave generates a new MPC keyshare // NewEnclave generates a new MPC keyshare

View File

@@ -6,7 +6,7 @@ import (
"fmt" "fmt"
"github.com/golang-jwt/jwt/v5" "github.com/golang-jwt/jwt/v5"
"github.com/sonr-io/sonr/crypto/mpc" "github.com/sonr-io/crypto/mpc"
) )
// MPCSigningMethod implements the SigningMethod interface for MPC-based signing // MPCSigningMethod implements the SigningMethod interface for MPC-based signing

View File

@@ -7,8 +7,8 @@ import (
"github.com/golang-jwt/jwt/v5" "github.com/golang-jwt/jwt/v5"
"github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/crypto"
"github.com/sonr-io/sonr/crypto/keys" "github.com/sonr-io/crypto/keys"
"github.com/sonr-io/sonr/crypto/mpc" "github.com/sonr-io/crypto/mpc"
"lukechampine.com/blake3" "lukechampine.com/blake3"
) )

View File

@@ -7,9 +7,9 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/core/protocol" "github.com/sonr-io/crypto/core/protocol"
"github.com/sonr-io/sonr/crypto/tecdsa/dklsv1" "github.com/sonr-io/crypto/tecdsa/dklsv1"
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
) )

View File

@@ -27,8 +27,8 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/zkp/schnorr" "github.com/sonr-io/crypto/zkp/schnorr"
) )
const ( const (

View File

@@ -14,9 +14,9 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/sonr-io/sonr/crypto/core/curves" "github.com/sonr-io/crypto/core/curves"
"github.com/sonr-io/sonr/crypto/ot/base/simplest" "github.com/sonr-io/crypto/ot/base/simplest"
"github.com/sonr-io/sonr/crypto/ot/ottest" "github.com/sonr-io/crypto/ot/ottest"
) )
func TestOtOnMultipleCurves(t *testing.T) { func TestOtOnMultipleCurves(t *testing.T) {

Some files were not shown because too many files have changed in this diff Show More