mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
* feat: add docs and CI workflow for publishing to onsonr.dev * (refactor): Move hway,motr executables to their own repos * feat: simplify devnet and testnet configurations * refactor: update import path for didcrypto package * docs(networks): Add README with project overview, architecture, and community links * refactor: Move network configurations to deploy directory * build: update golang version to 1.23 * refactor: move logger interface to appropriate package * refactor: Move devnet configuration to networks/devnet * chore: improve release process with date variable * (chore): Move Crypto Library * refactor: improve code structure and readability in DID module * feat: integrate Trunk CI checks * ci: optimize CI workflow by removing redundant build jobs --------- Co-authored-by: Darp Alakun <i@prad.nu>
38 lines
950 B
Go
Executable File
38 lines
950 B
Go
Executable File
package schnorr
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"golang.org/x/crypto/sha3"
|
|
|
|
"github.com/onsonr/sonr/crypto/core/curves"
|
|
)
|
|
|
|
func TestZKPOverMultipleCurves(t *testing.T) {
|
|
curveInstances := []*curves.Curve{
|
|
curves.K256(),
|
|
curves.P256(),
|
|
// TODO: the code fails on the following curves. Investigate if this is expected.
|
|
// curves.PALLAS(),
|
|
// curves.BLS12377G1(),
|
|
// curves.BLS12377G2(),
|
|
// curves.BLS12381G1(),
|
|
// curves.BLS12381G2(),
|
|
// curves.ED25519(),
|
|
}
|
|
for i, curve := range curveInstances {
|
|
uniqueSessionId := sha3.New256().Sum([]byte("random seed"))
|
|
prover := NewProver(curve, nil, uniqueSessionId)
|
|
|
|
secret := curve.Scalar.Random(rand.Reader)
|
|
proof, err := prover.Prove(secret)
|
|
require.NoError(t, err, fmt.Sprintf("failed in curve %d", i))
|
|
|
|
err = Verify(proof, curve, nil, uniqueSessionId)
|
|
require.NoError(t, err, fmt.Sprintf("failed in curve %d", i))
|
|
}
|
|
}
|