mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
* feat: Add Enclave Usage Examples * feat(es/ucan): Add comprehensive integration tests - Create integration.test.ts with full UCAN token lifecycle testing - Cover end-to-end token creation, parsing, and validation - Test capability attenuation and delegation chains - Validate multi-algorithm support and timestamp scenarios - Implement error recovery and performance test scenarios 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com> * No commit suggestions generated * No commit suggestions generated * chore: Remove migrated components and add migration documentation Removed all code and references for components that have been moved to separate repositories: **Moved to sonr-io/hway:** - bridge/ - HTTP service with OAuth2/OIDC/WebAuthn handlers - cmd/hway/ - Highway service binary - internal/migrations/ - PostgreSQL schema migrations **Moved to sonr-io/motr:** - cmd/motr/ - Motor worker service (WASM vault operations) - cmd/vault/ - Vault CLI tool - crypto/ - Comprehensive cryptographic library - packages/ - TypeScript SDK packages (es, sdk, ui, com, pkl) - web/auth/ - Authentication web application - web/dash/ - Dashboard web application **Updated Configuration:** - Makefile: Removed build/test/release targets for moved components - CLAUDE.md: Simplified to focus on core blockchain components - devbox.json: Removed scripts for moved services - docker-compose.yml: Removed hway, postgres, redis, auth, dash services - .github/scopes.yml: Removed CI scopes for migrated components - .goreleaser.yml: Updated release configuration **Added Migration Documentation:** - MIGRATE_HWAY.md: Comprehensive Highway service architecture and migration guide - MIGRATE_MOTR.md: Comprehensive Motor/Worker/Vault architecture and migration guide These migration documents provide complete context for setting up the new repositories including architecture diagrams, component breakdowns, API documentation, and migration checklists. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * No commit suggestions generated * chore: Remove contracts references and documentation Removed all references to the contracts directory that was migrated to a separate repository. **Changes:** - .gitignore: Removed contract-specific ignore patterns for DAO and wSNR contracts - .gitignore: Removed hway and motr binary references (already migrated) - .rgignore: Removed contracts, chains, and crypto directory references - docs/reference/contracts/: Removed DAO.mdx and wSNR.mdx documentation files This completes the cleanup of migrated components from the repository. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: add crypto library migration documentation Added comprehensive migration documentation for the crypto library that was moved to sonr-io/crypto repository. This documentation provides complete context for understanding the cryptographic primitives and protocols used throughout the Sonr ecosystem. ## Key Documentation Added ### MIGRATE_CRYPTO.md Complete documentation of the crypto library covering: **Core Cryptographic Primitives** - Elliptic curve implementations (Ed25519, Secp256k1, P-256, BLS12-381, Pallas/Vesta) - Native curve arithmetic with optimized field operations - Pairing-friendly curves for BLS signatures **Multi-Party Computation (MPC)** - MPC enclave for vault key generation and management - Threshold cryptography (TECDSA, TED25519 with FROST protocol) - Distributed Key Generation (DKG) via Gennaro and FROST protocols - Secret sharing schemes (Shamir, Feldman VSS, Pedersen VSS) **Digital Signature Schemes** - BLS signatures with aggregation support - BBS+ signatures for selective disclosure - Schnorr signatures (standard and Mina/NEM variants) - ECDSA with deterministic nonce generation **Zero-Knowledge Proofs** - Bulletproofs for range proofs - Inner Product Arguments (IPA) - Batch verification support **Advanced Cryptographic Protocols** - Cryptographic accumulators for set membership proofs - Paillier homomorphic encryption - Oblivious Transfer (OT) protocols - Verifiable Random Functions (VRF) **Key Management & Identity** - DID key management with multi-chain support - Multi-algorithm public key handling - Wallet address derivation (Bitcoin, Ethereum, Cosmos, Solana, etc.) **UCAN Integration** - User-Controlled Authorization Networks - Capability delegation and attenuation - JWT-based capability tokens - MPC-enabled UCAN signing **Security Utilities** - AEAD encryption (AES-GCM, AES-SIV) - Argon2 key derivation - ECIES encryption - Secure memory handling ### MIGRATE_MOTR.md Updates Updated Motor migration documentation to clarify that the crypto library is now a separate external dependency at github.com/sonr-io/crypto v1.0.1 ## Repository Context The crypto library has been successfully migrated to its own repository and is published as a Go module. It serves as the foundational cryptographic layer for: - Sonr blockchain (snrd) - DID signatures, vault operations - Highway service (hway) - UCAN token signing, WebAuthn - Motor/Worker (motr) - MPC vault operations, threshold signatures ## Integration Impact All Sonr ecosystem components now depend on the external crypto library: ```go require github.com/sonr-io/crypto v1.0.1 ``` The migration enables independent versioning and maintenance of cryptographic primitives while maintaining security and compatibility across the ecosystem. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * No commit suggestions generated * No commit suggestions generated * No commit suggestions generated --------- Co-authored-by: Claude <noreply@anthropic.com>
274 lines
6.7 KiB
Bash
Executable File
274 lines
6.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
# Function to detect OS and architecture
|
|
detect_platform() {
|
|
OS=$(uname -s)
|
|
ARCH=$(uname -m)
|
|
|
|
# Normalize OS names to match GitHub release naming
|
|
case "${OS}" in
|
|
Darwin) OS_NAME="darwin" ;;
|
|
Linux) OS_NAME="linux" ;;
|
|
MINGW* | MSYS* | CYGWIN*) OS_NAME="windows" ;;
|
|
*)
|
|
echo "Unsupported OS: ${OS}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Normalize architecture names
|
|
case "${ARCH}" in
|
|
x86_64) ARCH="amd64" ;;
|
|
aarch64 | arm64) ARCH="arm64" ;;
|
|
*)
|
|
echo "Unsupported architecture: ${ARCH}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# Function to check if we can build locally
|
|
can_build_locally() {
|
|
# Check if we're in the sonr project directory
|
|
if [[ -f "Makefile" ]] && [[ -f "go.mod" ]] && grep -q "module github.com/sonr-io/sonr" go.mod 2>/dev/null; then
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
# Function to build locally
|
|
build_locally() {
|
|
local INSTALL_DIR="$1"
|
|
echo "Building Sonr locally..."
|
|
|
|
# Check if make and go are available
|
|
if ! command -v make >/dev/null 2>&1; then
|
|
echo "Error: make is required to build locally"
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v go >/dev/null 2>&1; then
|
|
echo "Error: Go is required to build locally"
|
|
exit 1
|
|
fi
|
|
|
|
# Build binaries
|
|
echo "Building snrd..."
|
|
make build || {
|
|
echo "Error: Failed to build snrd"
|
|
exit 1
|
|
}
|
|
|
|
echo "Building motr..."
|
|
make motr || {
|
|
echo "Error: Failed to build motr"
|
|
exit 1
|
|
}
|
|
|
|
# Copy binaries to install directory
|
|
cp build/snrd "${INSTALL_DIR}/" || {
|
|
echo "Error: Failed to copy snrd"
|
|
exit 1
|
|
}
|
|
cp build/motr.wasm "${INSTALL_DIR}/" || {
|
|
echo "Error: Failed to copy motr.wasm"
|
|
exit 1
|
|
}
|
|
|
|
# Make binaries executable
|
|
chmod +x "${INSTALL_DIR}/snrd"
|
|
|
|
echo "Binaries built and installed successfully to ${INSTALL_DIR}"
|
|
}
|
|
|
|
# Function to get latest release version
|
|
get_latest_version() {
|
|
RELEASE_DATA=$(curl -s https://api.github.com/repos/sonr-io/sonr/releases/latest)
|
|
|
|
# Check if API returned an error (no releases available or private repo)
|
|
if echo "${RELEASE_DATA}" | grep -q '"message": "Not Found"'; then
|
|
if can_build_locally; then
|
|
echo "No public releases found, building locally..."
|
|
return 1
|
|
else
|
|
echo "Error: No releases found for sonr-io/sonr"
|
|
echo "Please build and install from source:"
|
|
echo " git clone https://github.com/sonr-io/sonr.git"
|
|
echo " cd sonr"
|
|
echo " ./scripts/install.sh"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
LATEST_VERSION=$(echo "${RELEASE_DATA}" | grep "tag_name" | cut -d '"' -f 4)
|
|
if [[ -z "${LATEST_VERSION}" ]]; then
|
|
echo "Error: Could not determine latest version"
|
|
if can_build_locally; then
|
|
echo "Falling back to local build..."
|
|
return 1
|
|
fi
|
|
exit 1
|
|
fi
|
|
|
|
LATEST_VERSION=${LATEST_VERSION#v} # Remove 'v' prefix
|
|
return 0
|
|
}
|
|
|
|
# Function to install binaries
|
|
install_binaries() {
|
|
local INSTALL_DIR="${1:-$(pwd)}"
|
|
|
|
# Check if we have a version from releases
|
|
if [[ -n "${LATEST_VERSION}" ]]; then
|
|
echo "Installing Sonr v${LATEST_VERSION} for ${OS_NAME} (${ARCH}) to ${INSTALL_DIR}..."
|
|
|
|
# Use dl.sonr.io CDN for faster downloads
|
|
BASE_URL="https://dl.sonr.io/v${LATEST_VERSION}"
|
|
|
|
# Download snrd binary
|
|
echo "Downloading snrd..."
|
|
if [[ ${OS_NAME} == "windows" ]]; then
|
|
echo "Error: snrd does not support Windows"
|
|
exit 1
|
|
else
|
|
if ! curl -L "${BASE_URL}/snrd_${OS_NAME}_${ARCH}" -o "${INSTALL_DIR}/snrd" -f; then
|
|
echo "Warning: Failed to download from CDN, trying GitHub releases..."
|
|
# Fallback to GitHub releases
|
|
GITHUB_URL="https://github.com/sonr-io/sonr/releases/download/v${LATEST_VERSION}"
|
|
if ! curl -L "${GITHUB_URL}/snrd_${OS_NAME}_${ARCH}" -o "${INSTALL_DIR}/snrd" -f; then
|
|
echo "Error: Failed to download snrd binary from both CDN and GitHub"
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Download motr.wasm (platform independent)
|
|
echo "Downloading motr.wasm..."
|
|
if ! curl -L "${BASE_URL}/motr.wasm" -o "${INSTALL_DIR}/motr.wasm" -f; then
|
|
echo "Warning: Failed to download from CDN, trying GitHub releases..."
|
|
# Fallback to GitHub releases
|
|
GITHUB_URL="https://github.com/sonr-io/sonr/releases/download/v${LATEST_VERSION}"
|
|
if ! curl -L "${GITHUB_URL}/motr.wasm" -o "${INSTALL_DIR}/motr.wasm" -f; then
|
|
echo "Error: Failed to download motr.wasm from both CDN and GitHub"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Make binaries executable
|
|
chmod +x "${INSTALL_DIR}/snrd"
|
|
|
|
echo "Binaries installed successfully to ${INSTALL_DIR}"
|
|
else
|
|
# Fall back to local build
|
|
build_locally "${INSTALL_DIR}"
|
|
fi
|
|
|
|
echo
|
|
echo "Available commands:"
|
|
echo " snrd - Blockchain daemon"
|
|
echo " motr.wasm - WebAssembly enclave"
|
|
echo
|
|
echo "Quick start:"
|
|
echo " snrd --help # Show available commands"
|
|
echo " snrd start # Start the blockchain node"
|
|
}
|
|
|
|
# Function to install system-wide
|
|
install_system() {
|
|
if [[ ${EUID} -eq 0 ]]; then
|
|
INSTALL_DIR="/usr/local/bin"
|
|
else
|
|
echo "Installing to /usr/local/bin requires sudo privileges..."
|
|
sudo -v || {
|
|
echo "Sudo access required for system-wide installation"
|
|
exit 1
|
|
}
|
|
INSTALL_DIR="/usr/local/bin"
|
|
|
|
# Create temporary directory and install there first
|
|
TMP_DIR=$(mktemp -d)
|
|
install_binaries "${TMP_DIR}"
|
|
|
|
# Move to system directory with sudo
|
|
sudo mv "${TMP_DIR}/"* "${INSTALL_DIR}/"
|
|
rm -rf "${TMP_DIR}"
|
|
|
|
echo "Binaries installed system-wide to ${INSTALL_DIR}"
|
|
return
|
|
fi
|
|
|
|
install_binaries "${INSTALL_DIR}"
|
|
}
|
|
|
|
# Function to install to user directory
|
|
install_user() {
|
|
USER_BIN_DIR="${HOME}/.local/bin"
|
|
mkdir -p "${USER_BIN_DIR}"
|
|
|
|
install_binaries "${USER_BIN_DIR}"
|
|
|
|
# Check if user bin is in PATH
|
|
if [[ ":${PATH}:" != *":${USER_BIN_DIR}:"* ]]; then
|
|
echo
|
|
echo "WARNING: ${USER_BIN_DIR} is not in your PATH"
|
|
echo "Add the following line to your shell profile (~/.bashrc, ~/.zshrc, etc.):"
|
|
echo 'export PATH="$HOME/.local/bin:$PATH"'
|
|
echo
|
|
echo "Then restart your terminal or run: source ~/.bashrc"
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
detect_platform
|
|
|
|
# Try to get latest version from releases, but don't fail if not available
|
|
if ! get_latest_version; then
|
|
# get_latest_version returned 1, meaning no releases but we can build locally
|
|
LATEST_VERSION=""
|
|
fi
|
|
|
|
# Parse command line arguments
|
|
case "${1-}" in
|
|
--system | -s)
|
|
install_system
|
|
;;
|
|
--user | -u)
|
|
install_user
|
|
;;
|
|
--current | -c)
|
|
install_binaries "$(pwd)"
|
|
;;
|
|
--help | -h)
|
|
echo "Sonr Installation Script"
|
|
echo
|
|
echo "Usage: $0 [OPTIONS]"
|
|
echo
|
|
echo "Options:"
|
|
echo " --system, -s Install system-wide to /usr/local/bin (requires sudo)"
|
|
echo " --user, -u Install to ~/.local/bin (user directory)"
|
|
echo " --current, -c Install to current directory"
|
|
echo " --help, -h Show this help message"
|
|
echo
|
|
echo "If no option is specified, defaults to --user installation"
|
|
echo
|
|
if can_build_locally; then
|
|
echo "Note: No public releases found, will build from source"
|
|
fi
|
|
exit 0
|
|
;;
|
|
"")
|
|
# Default to user installation
|
|
install_user
|
|
;;
|
|
*)
|
|
echo "Unknown option: $1"
|
|
echo "Use --help for usage information"
|
|
exit 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
main "$@"
|