mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 10:21:40 +00:00
- **refactor: move session-related code to middleware package** - **refactor: update PKL build process and adjust related configurations** - **feat: integrate base.cosmos.v1 Genesis module** - **refactor: pass session context to modal rendering functions** - **refactor: move nebula package to app directory and update templ version** - **refactor: Move home section video view to dedicated directory** - **refactor: remove unused views file** - **refactor: move styles and UI components to global scope** - **refactor: Rename images.go to cdn.go** - **feat: Add Empty State Illustrations** - **refactor: Consolidate Vault Index Logic** - **fix: References to App.wasm and remove Vault Directory embedded CDN files** - **refactor: Move CDN types to Models** - **fix: Correct line numbers in templ error messages for arch_templ.go** - **refactor: use common types for peer roles** - **refactor: move common types and ORM to a shared package** - **fix: Config import dwn** - **refactor: move nebula directory to app** - **feat: Rebuild nebula** - **fix: correct file paths in panels templates** - **feat: Remove duplicate types** - **refactor: Move dwn to pkg/core** - **refactor: Binary Structure** - **feat: Introduce Crypto Pkg** - **fix: Broken Process Start** - **feat: Update pkg/* structure** - **feat: Refactor PKL Structure** - **build: update pkl build process** - **chore: Remove Empty Files** - **refactor: remove unused macaroon package** - **feat: Add WebAwesome Components** - **refactor: consolidate build and generation tasks into a single taskfile, remove redundant makefile targets** - **refactor: refactor server and move components to pkg/core/dwn** - **build: update go modules** - **refactor: move gateway logic into dedicated hway command** - **feat: Add KSS (Krawczyk-Song-Song) MPC cryptography module** - **feat: Implement MPC-based JWT signing and UCAN token generation** - **feat: add support for MPC-based JWT signing** - **feat: Implement MPC-based UCAN capabilities for smart accounts** - **feat: add address field to keyshareSource** - **feat: Add comprehensive MPC test suite for keyshares, UCAN tokens, and token attenuations** - **refactor: improve MPC keyshare management and signing process** - **feat: enhance MPC capability hierarchy documentation** - **refactor: rename GenerateKeyshares function to NewKeyshareSource for clarity** - **refactor: remove unused Ethereum address computation** - **feat: Add HasHandle and IsAuthenticated methods to HTTPContext** - **refactor: Add context.Context support to session HTTPContext** - **refactor: Resolve context interface conflicts in HTTPContext** - **feat: Add session ID context key and helper functions** - **feat: Update WebApp Page Rendering** - **refactor: Simplify context management by using single HTTPContext key** - **refactor: Simplify HTTPContext creation and context management in session middleware** - **refactor: refactor session middleware to use a single data structure** - **refactor: Simplify HTTPContext implementation and session data handling** - **refactor: Improve session context handling and prevent nil pointer errors** - **refactor: Improve session context handling with nil safety and type support** - **refactor: improve session data injection** - **feat: add full-screen modal component and update registration flow** - **chore: add .air.toml to .gitignore** - **feat: add Air to devbox and update dependencies**
94 lines
2.9 KiB
Go
Executable File
94 lines
2.9 KiB
Go
Executable File
//
|
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package ted25519
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSigAgg(t *testing.T) {
|
|
config := ShareConfiguration{T: 2, N: 3}
|
|
pub, secretShares, _, err := GenerateSharedKey(&config)
|
|
require.NoError(t, err)
|
|
|
|
message := []byte("test message")
|
|
|
|
// Each party generates a nonce and we combine them together into an aggregate one
|
|
noncePub1, nonceShares1, _, err := GenerateSharedNonce(&config, secretShares[0], pub, message)
|
|
require.NoError(t, err)
|
|
noncePub2, nonceShares2, _, err := GenerateSharedNonce(&config, secretShares[1], pub, message)
|
|
require.NoError(t, err)
|
|
noncePub3, nonceShares3, _, err := GenerateSharedNonce(&config, secretShares[2], pub, message)
|
|
require.NoError(t, err)
|
|
nonceShares := []*NonceShare{
|
|
nonceShares1[0].Add(nonceShares2[0]).Add(nonceShares3[0]),
|
|
nonceShares1[1].Add(nonceShares2[1]).Add(nonceShares3[1]),
|
|
nonceShares1[2].Add(nonceShares2[2]).Add(nonceShares3[2]),
|
|
}
|
|
|
|
noncePub := GeAdd(GeAdd(noncePub1, noncePub2), noncePub3)
|
|
|
|
sig1 := TSign(message, secretShares[0], pub, nonceShares[0], noncePub)
|
|
sig2 := TSign(message, secretShares[1], pub, nonceShares[1], noncePub)
|
|
sig3 := TSign(message, secretShares[2], pub, nonceShares[2], noncePub)
|
|
|
|
// Test signer 1&2 verification
|
|
sig, err := Aggregate([]*PartialSignature{sig1, sig2}, &config)
|
|
require.NoError(t, err)
|
|
assertSignatureVerifies(t, pub, message, sig)
|
|
|
|
// Test signer 2&3 verification
|
|
sig, err = Aggregate([]*PartialSignature{sig2, sig3}, &config)
|
|
require.NoError(t, err)
|
|
assertSignatureVerifies(t, pub, message, sig)
|
|
|
|
// Test signer 1&3 verification
|
|
sig, err = Aggregate([]*PartialSignature{sig1, sig3}, &config)
|
|
require.NoError(t, err)
|
|
assertSignatureVerifies(t, pub, message, sig)
|
|
}
|
|
|
|
func TestSigAgg_validations(t *testing.T) {
|
|
config := ShareConfiguration{T: 2, N: 3}
|
|
_, err := Aggregate([]*PartialSignature{}, &config)
|
|
require.EqualError(t, err, "ted25519: sigs must be non-empty")
|
|
|
|
sig1bytes, _ := hex.DecodeString(
|
|
"e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e06522490155" +
|
|
"5fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b",
|
|
)
|
|
sig2bytes, _ := hex.DecodeString(
|
|
"92a009a9f0d4cab8720e820b5f642540a2b27b5416503f8fb3762223ebdb69da" +
|
|
"085ac1e43e15996e458f3613d0f11d8c387b2eaeb4302aeeb00d291612bb0c00",
|
|
)
|
|
sig1 := NewPartialSignature(1, sig1bytes)
|
|
sig2 := NewPartialSignature(2, sig2bytes)
|
|
|
|
_, err = Aggregate([]*PartialSignature{sig1, sig2}, &config)
|
|
require.EqualError(
|
|
t,
|
|
err,
|
|
fmt.Sprintf("ted25519: unexpected nonce pubkey. got: %x expected: %x", sig2bytes[:32], sig1bytes[:32]),
|
|
)
|
|
}
|
|
|
|
func assertSignatureVerifies(t *testing.T, pub, message, sig []byte) {
|
|
ok, _ := Verify(pub, message, sig)
|
|
if !ok {
|
|
t.Errorf("valid signature rejected")
|
|
}
|
|
wrongMessage := []byte("wrong message")
|
|
ok, _ = Verify(pub, wrongMessage, sig)
|
|
if ok {
|
|
t.Errorf("signature of different message accepted")
|
|
}
|
|
}
|