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:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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{}
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user